Total encryption of Xavier?

Hello,

For one of my projects, my company will use some Jetson Xavier, but they want me to encrypt all data on it, and required a SSH connection to provide the passphrase to decrypt the disk at boot.

I tested on some VMs ad got it to work by installing dropbear in initramFS, but as I didn’t know the Xavier platform, I realized that it was an embedded version of Ubuntu, and i’m no embedded specialist by all means…

So I would like to know if the Xavier can be installed with a full disk encryption, like on a desktop ubuntu?
Or at least would it be possible to encrypt the /home and /var/log partitions?

I’m a little lost, when I saw the output of fdisk showing 36 parts…

Thanks in advance for your support!

1 Like

Just speculating, don’t take this too seriously…

I don’t know if it would be possible. Certainly it would be difficult. FYI, right now the non-rootfs partitions seem to use signing…meaning they could be read, but you would have some assurance they are not modified. You might see references to a factory fuse which is for enforcing a certain signature.

The desktop PC bootloader is GRUB, and GRUB gets much of the hardware already set up via BIOS/UEFI, but there is no BIOS in an embedded system, and U-Boot is used (the version is specific to NVIDIA…download U-Boot via “source_sync.sh -u tegra-l4t-r32.1”…or adjust for your release…I haven’t actually downloaded for r32.1 yet, but I know it worked with earlier releases). Embedded systems do not have this BIOS pre-boot support and everything for booting which was in a BIOS is done instead in software in U-Boot or earlier software stages. In order to use ssh in U-Boot you would need a lot of modification and driver additions (meaning compiling them in to U-Boot after porting them). Just an ethernet driver would be simpler than also adding ssh within U-Boot, and I don’t know if you’d be able to succeed at that…you’d need to be very good at working with U-Boot and low level ssh details in a bare metal environment without any ssh library support.

There is the possibility of using an initial ramdisk…if you are actually in Linux in an initrd, then you might be able to skip all that work on modifying U-Boot (other than to get the initrd). I haven’t had any luck with the R28.2 era of TX1/TX2, but I saw glimpses that it might work. Xavier should be fairly close to this, and it might work, but I don’t know. If you can do this in the initrd instead of in U-Boot, then you stand a much better chance (Linux has drivers and ssh content already…no adding it to U-Boot required). The initrd would not be encrypted unless you modify U-Boot…but it could be signed and an altered version would be rejected. If you go this route then I’ll suggest starting by experimenting with a hello world initrd.

The rootfs partition could be fully encrypted if you can get the initrd working with ssh and then be satisfied by signing of other partitions versus full encryption of all partitions. Typically the target of the other partitions being attacked is to essentially create a man-in-the-middle attack to echo what is going on, but knowing this content must be signed correctly with a secret key might be enough.

NOTE: Don’t forget to remove serial console once you have it working.

hello julinux06,

we’re now only able to support secureboot to encrypt Bootloader images.
you may refer to l4t-r32.1 documentation, Secureboot on Jetson AGX Xavier and Jetson TX2 Devices for details.
thanks

Thanks for your reply Linuxdev! But I won’t be able to mess with the system that much as I’m no dev nor embedded specialist by all means… :)

JerryChang, that for your answer too! I’ll have a look at this documentation. Does that means that when the Xavier boots, he asks for a pwd to decrypt?
That’s the wanted behavior, but as the definitive system will be on it’s own, I look for a remote way to pass the password. hopefully this will be possible with little dev :D

As I’m not familiar with terminology, is the bootloader image only the boot process thingy, or the entire OS image?

He’s speaking of the pre-boot environment, not the main partition. Basically this is only the content required to get the Linux kernel ready for boot, but does not encrypt or protect the Linux partition itself. You would need to start with the secureboot environment and then work on an initial ramdisk for setting up encrypted file system (in terms of development you’d work first on the initrd and rootfs encryption, and only then add in secureboot…secureboot would be part of what gives you confidence that your initrd isn’t altered or intercepted).

1 Like

Thanks for your answers Linuxdev!

But I still cannot figure if I can encrypt the main partition BEFORE flashing. I installed the latest SDK Manager Friday afternoon, and I was sure that the utility was doing a plain flash, erasing all the MMC on the Xavier.
But I’ll continue to read the documentation to know more.

If you flash on command line, then the “flash.sh” script has an option “-r” to “reuse” the existing image. That image is “bootloader/system.img”.

If you happen to have a file which has been ext4 formatted via loopback, then that can be manipulated (including encryption) as if it is a partition simply by referring to the loopback device instead of directly naming the file. Once that is in place as file “bootloader/system.img”, and using command line with the “-r” option, then it would put that exact encrypted partition in place.

If you are not familiar with loopback, then it is useful to know that it is a way to make a file appear as if it is a disk partition. The tools operating on the loopback device don’t care if the content behind the device is a hard drive or a file.

The real trick is that U-Boot can’t handle the encryption…this is why I mention that you have to start with the initrd (initial ramdisk). You can boot into Linux via a temporary initrd, and this can mount an encrypted partition and can handle ssh. However, getting the initrd itself to work won’t be as easy as on a desktop PC using GRUB…you’ll need to become somewhat expert in custom initrd design.

  1. Learn to build a basic initrd.
  2. Learn to modify the initrd to handle ssh.
  3. Learn to mount an ext4 encrypted partition with the password built in to the initrd.
  4. Learn to replace the hard coded password with an ssh-provided interactive password.
  5. Learn how to use the secure boot environment so that none of the boot content can be modified without a correct signature.

That will be nigh impossible I’m afraid, It’ll have to work by the end of the week :)

But thanks for all your time and answers. For now i’ll go with a simpler solution: i’m trying to flash the Xavier using a smaller ROOTFS, then adding some parts which will be crypted. That’s much I can do for friday :D

Me again,

I found the way to have a blank space in which I can do whatever I want. But when I try to crypt a partition, II ger an error:

device-mapper: reload ioctl on failed: Invalid argument
Failed to setup dm-crypt key mapping for device /dev/mmcblk0p36.
Check that kernel supports aes-xts-plain64 cipher (check syslog for more info).

And when I do a lsmod:

Module Size Used by
fuse 103334 7
bnep 16619 2
hid_microsoft 4798 0
nvs_bmi160 22076 0
nvs 53924 1 nvs_bmi160
bluedroid_pm 14104 0
ip_tables 18922 0
x_tables 29079 1 ip_tables

Would it be possible to add the crypt module to this custom kernel?

Thanks :)

I don’t know which module you might need, but I suspect that is the correct way to proceed. Most file operations are standard, but when a file is really talking to a device driver it uses an IOCTL call…and not understanding that IOCTL implies you’re either missing the driver or some dependency of the driver.

The official documents with the particular release have a customization section which describes cross compiling from an Ubuntu host and installing either the kernel or the module to the host.

Not all kernel features can be a module, but many can. Examples of features which must be integrated are those which are needed for boot when an initial ramdisk can’t provide them, or for features which are quite invasive (swap and virtual memory options are in that category). As long as mounting the encrypted partition does not matter until after Linux is running, then this can be a module.

FYI, your current kernel config is in “/proc/config.gz”. You can see the running system’s options via “zcat /proc/config.gz”.

Thanks!
I downloaded and compiled the kernel source yesterday, and found a doc to help me insert some modules (I hope).

I looked the config.gz file, there is some crypto entries set to “y”, but not all of them. Maybe i’ll try to change the Luks cipher to see if I can get something to work without installing any modules.

I’ve done a cat /proc/crypto to see already installed modules, and it appears that I have some. I’ll let you know :)

EDIT: with the kernel headers I downloaded it didn’t work, the Xavier doesn’t even boot… The kernel is newer on Jetpack 4.1.1, that’s maybe why.
I tried to flash the rootfs with the modules, the kernel AND the dtb partition. The search continues :)

Update:
I succeeded in building a kernel from sources and flash the Xavier.
But I have another concern: I thought that this kernel from sources had more modules to work with, but I still miss the crypt modules, and cryptsetup is still not working.
I also tried to install the toolchain on my Ubuntu VM to no avail.

EDIT: At last! I completely forgot to do a menuconfig in order to activate all crypt options. And I have succeeded in crypting a partition!

Last concern is to add crypt support to device mapper as i’m not able to OPEN my encrypted partition :p

I couldn’t help with that (I have not worked on encrypted partitions in a long time), but most likely it is a case of adding the right user space packages (I imagine there is some sort of utility or tool package for working with encrypted partitions).

I found the solution: I had to add the crypt support to device mapper when building the kernel.

Now everything is OK, but I still need to unlock the partition remotely. Dropbear in initramFS doesn’t seem to work with Xavier. For now :)

Hi,

I have tried and installed ecryptfs on my xavier. I can encrypt home directory and everything seems to be working fine. Although, there is no swap encryption as ecryptfs-setup-swap ignores zram. Here is the output of $sudo ecryptfs-setup-swap:

WARNING: [/dev/zram0] is a RAM device, skipping.
WARNING: [/dev/zram1] is a RAM device, skipping.
WARNING: [/dev/zram2] is a RAM device, skipping.
WARNING: [/dev/zram3] is a RAM device, skipping.
WARNING: [/dev/zram4] is a RAM device, skipping.
WARNING: [/dev/zram5] is a RAM device, skipping.
WARNING: [/dev/zram6] is a RAM device, skipping.
WARNING: [/dev/zram7] is a RAM device, skipping.
WARNING: There were no usable swap devices to be encrypted. Exiting.

I can easily work with my home directory, but for example when I try to copy a large file or extract a very big tar file I get errors. Weirdly, when I try to edit a text file, I get this error from vim: Error 297: Write error in swap file!
I mean I did not encrypt the swap file, but how come I get this error? Did I do something wrong?

This is how I encrypted home directory:

  1. I built the kernel (4.2.2) with ECRYPT_FS module installed and flashed xavier (on default installation ecryptfs module is not peresent so modprobe ecryptfs returns an error)
  2. Installed ecryptfs (sudo apt update && apt install ecryptfs-utils)
  3. Added a new user with home directory encrypted. (Tried encrypting with different methods, e.g. ecryptfs-migrate-home, adduser --encrypt-home test, …)
  4. Logged outof the current user and logged in with the new user.
  5. Made a record of the passphrase and rebooted.

I would appreciate your help :)

Thanks in advance!

I probably can’t help, but one suggestion is to first make sure the partition is not full. Run “df -H -T” and see which partitions are close to full. I suppose that wherever the temp file is during the edit that this could be a permission denied issue rather than a full partition. I have no clue as to what other file system changes might be present from full encryption, e.g., perhaps it changes “/tmp”…don’t know.

Thank you for your reply linuxdev.

The paritions are not full:

Filesystem Type Size Used Avail Use% Mounted on
/dev/mmcblk0p1 ext4 30G 5.7G 23G 21% /
none devtmpfs 8.2G 0 8.2G 0% /dev
tmpfs tmpfs 8.3G 4.1k 8.3G 1% /dev/shm
tmpfs tmpfs 8.3G 22M 8.3G 1% /run
tmpfs tmpfs 5.3M 4.1k 5.3M 1% /run/lock
tmpfs tmpfs 8.3G 0 8.3G 0% /sys/fs/cgroup
tmpfs tmpfs 1.7G 13k 1.7G 1% /run/user/120
tmpfs tmpfs 1.7G 0 1.7G 0% /run/user/1001
/home/test/.Private ecryptfs 30G 5.7G 23G 21% /home/test

As far as the permission is concerned, I must say that right after I setup encryption or after I reboot, I can create files and edit them without any problem. For example, I am able to create a text file and write into it. So I suspect if there was a permission issue I would not be able to edit the text file in the first place? Am I right?

The issue arises when I try to extract a tar file, which is 75MB by the way (I don’t think this issue is tied to this case only but I can reproduce it this way). The wierd part is that the first few files are extracted just fine but suddenly tar complains and returns an error:

$ tar -xvf test.tar.bz2
test/1/err.cpython-36.pyc
test/1/optionfile.cpython-36.pyc
test/1/connections.cpython-36.pyc
test/1/protocol.cpython-36.pyc
test/1/_compat.cpython-36.pyc
test/2/converters.cpython-36.pyc
test/2/connections.cpython-36.pyc
test/1/_socketio.cpython-36.pyc
test/2/_auth.cpython-36.pyc
test/2/_compat.cpython-36.pyc
test/2/err.cpython-36.pyc
test/2/times.cpython-36.pyc
test/2/optionfile.cpython-36.pyc
test/2/util.cpython-36.pyc
test/2/protocol.cpython-36.pyc
test/1/times.cpython-36.pyc
test/2/_socketio.cpython-36.pyc
test/2/
test/1/
test/1/util.cpython-36.pyc
test/
test/2/init.cpython-36.pyc
test/1/charset.cpython-36.pyc
test/1/converters.cpython-36.pyc
test/1/cursors.cpython-36.pyc
test/2/charset.cpython-36.pyc
test/2/cursors.cpython-36.pyc
tar: test/2/cursors.cpython-36.pyc: Cannot write: Invalid argument
test/1/_auth.cpython-36.pyc
tar: test/1/_auth.cpython-36.pyc: Cannot write: Invalid argument
test/1/init.cpython-36.pyc
tar: test/1/init.cpython-36.pyc: Cannot write: Invalid argument
tar: Exiting with failure status due to previous errors

From now on, I cannot copy/move any file in home directory nor can I edit a text file and etc.

Still the output of df is as follows:

$ df -H -T
Filesystem Type Size Used Avail Use% Mounted on
/dev/mmcblk0p1 ext4 30G 5.7G 23G 21% /
none devtmpfs 8.2G 0 8.2G 0% /dev
tmpfs tmpfs 8.3G 4.1k 8.3G 1% /dev/shm
tmpfs tmpfs 8.3G 22M 8.3G 1% /run
tmpfs tmpfs 5.3M 4.1k 5.3M 1% /run/lock
tmpfs tmpfs 8.3G 0 8.3G 0% /sys/fs/cgroup
tmpfs tmpfs 1.7G 13k 1.7G 1% /run/user/120
tmpfs tmpfs 1.7G 0 1.7G 0% /run/user/1001
/home/test/.Private ecryptfs 30G 5.7G 23G 21% /home/test

After I examined the test folder, the files that were extracted are there but the files with error are empty, they are there but with no content. Now if I remove the test folder I am able to edit a text file again or copy a files and so on!

I have no idea what’s happening here!

The trick with permissions is that it is talking about the temp space for the vim buffer, not the file being edited. So for example, when you use “yy” to yank a line, there is a buffer. There is also the backup temp file in case of crash, and although I do not believe this particular file is the cause, it illustrates that vim is opening more than just the file in question. Typically applications (perhaps vim, not sure) have temp files in “/tmp”, and possibly some applications have gvfs files as well (this is more for some desktop environment sharing functions or messaging).

This would create a lot of spam log, but only the log near the end would matter:

strace -o TraceLog.txt vi
# OR:
cd /where/ever
strace -o TraceLog.txt vi theFileName

As soon as you get the permission denied you should immediately exit. I say this due only to the extreme amount of log which strace generates.

This log is in the format of human readable “C-like” text. The function names are system calls…these calls went to the kernel itself, and the kernel replies with a return status. Most system calls look just like a C statement.

All kinds of defaults and things unrelated to the application will be logged, e.g., checking for all kinds of character encodings and looking like an error till it finds an encoding. What you’re really interested in is finding where the first line is with the name of the file you were to edit, or if you get this error prior to the file name (meaning you don’t even need to open a file), then you are looking for some sort of message matching “Error 297” (or “= 297”, which is a return value), or “Write error in swap file”.

I don’t know about the tar issue, this could be an issue of the tar file, or an issue unrelated to the file system. On the other hand, you could also run the strace command with a log for the tar command. The error will be very near the end, and most of the file can be deleted (I’d save a few lines above where the error shows up in order have some context, but delete from that point to the start of the log).

For this use case I can think of a simple procedure of using for onsite work with device a separate storage like sdcard of nvme that will be completely encrypted
For example:

  1. There is a Xavier and it has blank OS on it with no data
  2. There is an encrypted OS image at sdcard which has development environment
  3. Worker comes to work, in 5 minutes deploys image from sdcard to Xavier; Then works, and then after the end of the day they blank OS at Xavier

I would just use dd here.

that is more complicated, in my opinion;
but the same procedure of using of an encrypted OS at sdcard in order to restore it to the Xavier eMMC might work out for ssh conenction

Again, thank you for your help linuxdev,

The thing is I dont have any problem with vim by itself. I can open a text file and edit it and save it and etc (even a very big file), only if I do not use tar. what I mean is if I clean the home directory, like remove the files I copied over, and use vim to edit a file it works fine. but the problem is when I try tar -xvf test.tar.bz2, then not only does tar return an error but also vim starts complaining about the swap file too.

I did what you suggested, unfortunately the strace log file does contain any message related to error 297 or something similar. but I found something strange, at some point the .swp file path is changed.

strace output when there is no issue:

newfstatat(AT_FDCWD, “test_file.txt”, {st_mode=S_IFREG|0664, st_size=0, …}, 0) = 0
newfstatat(AT_FDCWD, “test_file.txt”, {st_mode=S_IFREG|0664, st_size=0, …}, 0) = 0
faccessat(AT_FDCWD, “test_file.txt”, W_OK) = 0
openat(AT_FDCWD, “test_file.txt”, O_RDONLY) = 3
readlinkat(AT_FDCWD, “test_file.txt”, 0x7fe4afaa98, 4095) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, “.test_file.txt.swp”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “.test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL, 0600) = 4
openat(AT_FDCWD, “.test_file.txt.swx”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “.test_file.txt.swx”, O_RDWR|O_CREAT|O_EXCL, 0600) = 5
fstat(4, {st_mode=S_IFREG|0600, st_size=0, …}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=0, …}) = 0
close(5) = 0
unlinkat(AT_FDCWD, “.test_file.txt.swx”, 0) = 0
close(4) = 0
unlinkat(AT_FDCWD, “.test_file.txt.swp”, 0) = 0
newfstatat(AT_FDCWD, “.test_file.txt.swp”, 0x7fe4afba18, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “.test_file.txt.swp”, 0x7fe4afbbb8, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
getcwd("/home/test", 4096) = 11
newfstatat(AT_FDCWD, “.test_file.txt.swp”, 0x7fe4afbf18, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “.test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600) = 4
fcntl(4, F_GETFD) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
getcwd("/home/test", 4096) = 11
lseek(4, 0, SEEK_SET) = 0
write(4, “b0VIM 8.0\0\0\0\0\20\0\0sN+^\216/\20\0\0269\0\0test”…, 4096) = 4096
pselect6(1, [0], , [0], {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
fchmodat(AT_FDCWD, “.test_file.txt.swp”, 0644) = 0
close(3) = 0
pselect6(1, [0], , [0], {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
openat(AT_FDCWD, “test_file.txt”, O_RDONLY) = 3
write(1, “\33[1;67r\33[?12h\33[?12l\33[27m\33[23m\33[2”…, 72) = 72
read(3, “”, 8192) = 0
close(3) = 0
write(1, " 0L, 0C", 7) = 7
openat(AT_FDCWD, “/home/test/.viminfo”, O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=6534, …}) = 0
read(3, “# This viminfo file was generate”…, 4096) = 4096
read(3, " 0 ~/test\n|4,39,8,0,1579895942"…, 4096) = 2438
close(3)

strace output when I get the Error 297 on vim:

newfstatat(AT_FDCWD, “test_file.txt”, {st_mode=S_IFREG|0664, st_size=0, …}, 0) = 0
newfstatat(AT_FDCWD, “test_file.txt”, {st_mode=S_IFREG|0664, st_size=0, …}, 0) = 0
faccessat(AT_FDCWD, “test_file.txt”, W_OK) = 0
openat(AT_FDCWD, “test_file.txt”, O_RDONLY) = 3
readlinkat(AT_FDCWD, “test_file.txt”, 0x7fc16550e8, 4095) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, “.test_file.txt.swp”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “.test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL, 0600) = 4
openat(AT_FDCWD, “.test_file.txt.swx”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “.test_file.txt.swx”, O_RDWR|O_CREAT|O_EXCL, 0600) = 5
fstat(4, {st_mode=S_IFREG|0600, st_size=0, …}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=0, …}) = 0
close(5) = 0
unlinkat(AT_FDCWD, “.test_file.txt.swx”, 0) = 0
close(4) = 0
unlinkat(AT_FDCWD, “.test_file.txt.swp”, 0) = 0
newfstatat(AT_FDCWD, “.test_file.txt.swp”, 0x7fc1656068, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “.test_file.txt.swp”, 0x7fc1656208, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
getcwd("/home/test", 4096) = 11
newfstatat(AT_FDCWD, “.test_file.txt.swp”, 0x7fc1656568, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “.test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600) = 4
fcntl(4, F_GETFD) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
getcwd("/home/test", 4096) = 11
lseek(4, 0, SEEK_SET) = 0
write(4, “b0VIM 8.0\0\0\0\0\20\0\0CM+^t.\20\00018\0\0test”…, 4096) = -1 EINVAL (Invalid argument)
write(1, “\33[1;67r\33[?12h\33[?12l\33[27m\33[23m\33[2”…, 97) = 97
pselect6(1, [0], , [0], {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
close(4) = 0
unlinkat(AT_FDCWD, “.test_file.txt.swp”, 0) = 0
readlinkat(AT_FDCWD, “test_file.txt”, 0x7fc16550e8, 4095) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, “/home/test/tmp/test_file.txt.swp”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/home/test/tmp/test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL, 0600) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/home/test/tmp/test_file.txt.swp”, 0x7fc1656068, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/home/test/tmp/test_file.txt.swp”, 0x7fc1656208, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/home/test/tmp/test_file.txt.swp”, 0x7fc1656568, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/home/test/tmp/test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600) = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, “test_file.txt”, 0x7fc16550e8, 4095) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL, 0600) = 4
openat(AT_FDCWD, “/var/tmp/test_file.txt.swx”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/var/tmp/test_file.txt.swx”, O_RDWR|O_CREAT|O_EXCL, 0600) = 5
fstat(4, {st_mode=S_IFREG|0600, st_size=0, …}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=0, …}) = 0
close(5) = 0
unlinkat(AT_FDCWD, “/var/tmp/test_file.txt.swx”, 0) = 0
close(4) = 0
unlinkat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, 0) = 0
newfstatat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, 0x7fc1656068, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, 0x7fc1656208, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, 0x7fc1656568, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600) = 4
fcntl(4, F_GETFD) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
lseek(4, 0, SEEK_SET) = 0
write(4, “b0VIM 8.0\0\0\0\0\20\0\0CM+^t.\20\00018\0\0test”…, 4096) = 4096
pselect6(1, [0], , [0], {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
fchmodat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, 0644) = 0
close(3) = 0
pselect6(1, [0], , [0], {tv_sec=0, tv_nsec=0}, NULL) = 0 (Timeout)
openat(AT_FDCWD, “test_file.txt”, O_RDONLY) = 3
write(1, “\33[?2004l”, 8) = 8
ioctl(0, TCGETS, {B38400 opost -isig -icanon -echo …}) = 0
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost isig -icanon -echo …}) = 0
ioctl(0, TCGETS, {B38400 opost isig -icanon -echo …}) = 0
nanosleep({tv_sec=1, tv_nsec=0}, NULL) = 0
ioctl(0, TCGETS, {B38400 opost isig -icanon -echo …}) = 0
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost -isig -icanon -echo …}) = 0
ioctl(0, TCGETS, {B38400 opost -isig -icanon -echo …}) = 0
write(1, “\33[?2004h”, 8) = 8
ioctl(1, TCGETS, {B38400 opost -isig -icanon -echo …}) = 0
ioctl(0, TCGETS, {B38400 opost -isig -icanon -echo …}) = 0
write(1, “\33[m\r"test_file.txt” \33[67;17H\33[K", 31) = 31
read(3, “”, 8192) = 0
close(3) = 0
write(1, “\33[67;17H0L, 0C”, 14) = 14
openat(AT_FDCWD, “/home/test/.viminfo”, O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=6472, …}) = 0
read(3, “# This viminfo file was generate”…, 4096) = 4096
read(3, “e\n|4,39,1,0,1579895517,”~/file"\n"…, 4096) = 2376
close(3)

And at the end of both files the path to swp file is different:

unlinkat(AT_FDCWD, “/home/test/.test_file.txt.swp”, 0) = 0

unlinkat(AT_FDCWD, “/var/tmp/test_file.txt.swp”, 0) = 0

I also tried two different tar files with different sizes. tar file that is 40KB can be extracted with no issue but the one that is 47KB reuturn errors towards the end of the extraction. Where you see the (Invalid argument) that’s where the error happens and extraction fails. After that I will have issue with copying, moving files and editing files with vim:

write(1, “test/2/optionfile.cpython-36.pyc”…, 33) = 33
openat(AT_FDCWD, “test/2/optionfile.cpython-36.pyc”, O_WRONLY|O_CREAT|O_EXCL|O_NOCTTY|O_NONBLOCK|O_CLOEXEC, 0664) = 4
write(4, “3\r\r\n\2E\323]\222\2\0\0\343\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0@\0\0”…, 1029) = 1029
fstat(4, {st_mode=S_IFREG|0664, st_size=1029, …}) = 0
utimensat(4, NULL, [{tv_sec=1579898495, tv_nsec=557481862} /* 2020-01-24T12:41:35.557481862-0800 /, {tv_sec=1579312391, tv_nsec=0} / 2020-01-17T17:53:11-0800 /], 0) = 0
close(4) = 0
write(1, “test/2/util.cpython-36.pyc\n”, 27) = 27
openat(AT_FDCWD, “test/2/util.cpython-36.pyc”, O_WRONLY|O_CREAT|O_EXCL|O_NOCTTY|O_NONBLOCK|O_CLOEXEC, 0664) = 4
write(4, “3\r\r\n\2E\323]\264\0\0\0\343\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0@\0\0”…, 435) = 435
fstat(4, {st_mode=S_IFREG|0664, st_size=435, …}) = 0
utimensat(4, NULL, [{tv_sec=1579898495, tv_nsec=561482095} /
2020-01-24T12:41:35.561482095-0800 /, {tv_sec=1579312391, tv_nsec=0} / 2020-01-17T17:53:11-0800 /], 0) = 0
close(4) = 0
write(1, “test/2/protocol.cpython-36.pyc\n”, 31) = 31
openat(AT_FDCWD, “test/2/protocol.cpython-36.pyc”, O_WRONLY|O_CREAT|O_EXCL|O_NOCTTY|O_NONBLOCK|O_CLOEXEC, 0664) = 4
write(4, “3\r\r\n\2E\323]\370.\0\0\343\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0@\0\0”…, 3584) = -1 EINVAL (Invalid argument)
openat(AT_FDCWD, “/usr/share/locale/locale.alias”, O_RDONLY|O_CLOEXEC) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=2995, …}) = 0
read(5, “# Locale name alias data base.\n#”…, 4096) = 2995
read(5, “”, 4096) = 0
close(5) = 0
openat(AT_FDCWD, “/usr/share/locale/en_CA/LC_MESSAGES/tar.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/share/locale/en/LC_MESSAGES/tar.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/share/locale-langpack/en_CA/LC_MESSAGES/tar.mo”, O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=474, …}) = 0
mmap(NULL, 474, PROT_READ, MAP_PRIVATE, 5, 0) = 0x7f88715000
close(5) = 0
openat(AT_FDCWD, “/usr/share/locale-langpack/en/LC_MESSAGES/tar.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "tar: ", 5) = 5
write(2, "test/2/protocol.cpython-36.pyc: "…, 44) = 44
openat(AT_FDCWD, “/usr/share/locale/en_CA/LC_MESSAGES/libc.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/share/locale/en/LC_MESSAGES/libc.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/share/locale-langpack/en_CA/LC_MESSAGES/libc.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, “/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo”, O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, “: Invalid argument”, 18) = 18
write(2, “\n”, 1) = 1
read(3, “\3\0\0\0\0\0\0\0\3\0\0\0\4\0\0\0C\0\0\0s\22\0\0\0|\0j\0|\1|”…, 10240) = 10240
fstat(4, {st_mode=S_IFREG|0664, st_size=0, …}) = 0
utimensat(4, NULL, [{tv_sec=1579898495, tv_nsec=565482329} /
2020-01-24T12:41:35.565482329-0800 /, {tv_sec=1579312391, tv_nsec=0} / 2020-01-17T17:53:11-0800 */], 0) = 0
close(4)

Any idea?