Commit Graph

116 Commits

Author SHA1 Message Date
Paul Lawrence
08892fdf71 ANDROID: Incremental fs: Retry page faults on non-fatal errors
In order to not freeze on corrupt data, we need to turn off
FAULT_FLAG_ALLOW_RETRY. However, this means we no longer retry on EINTR,
so an interrupted read will lead to page faults.

The fault handler does not seem to allow dynamic decisions as to whether
to turn on or off this flag.

To resolve both issues, add a flag to indicate if there are corrupt
pages in a file, and only if there are turn off this flag.

Also fsanitize changed the behavior of mlock - mlock should fail if the
page reads fail, but with fsanitize it returns 0 then page faults on
access. This broke this test, and fsanitize offers little value on test
code, so disable it.

Test: incfs_test passes
Bug: 343532239
Change-Id: Id2ced4be3310109206d65dcc92dea05c05131182
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2024-07-24 16:54:57 +00:00
Lee Jones
f48a4c3b29 ANDROID: Incremental fs: Allocate data buffer based on input request size
Presently the data buffer used to return the per-UID timeout description
is created based on information provided by the user.  It is expected
that the user populates a variable called 'timeouts_array_size' which is
heavily scrutinised to ensure the value provided is appropriate i.e.
smaller than the largest possible value but large enough to contain all
of the data we wish to pass back.

The issue is that the aforementioned scrutiny is imposed on a different
variable to the one expected.  Contrary to expectation, the data buffer
is actually being allocated to the size specified in a variable named
'timeouts_array_size_out'.  A variable originally designed to only
contain the output information i.e. the size of the data actually copied
to the user for consumption.  This value is also user provided and is
not given the same level of scrutiny as the former.

The fix in this case is simple.  Ignore 'timeouts_array_size_out' until
it is time to populate (over-write) it ourselves and use
'timeouts_array_size' to shape the buffer as intended.

Bug: 281547360
Change-Id: I95e12879a33a2355f9e4bc0ce2bfc3f229141aa8
Signed-off-by: Lee Jones <joneslee@google.com>
(cherry picked from commit 5a4d20a3eb4e651f88ed2f1f08cee066639ca801)
2023-07-17 14:53:51 +01:00
Paul Lawrence
faf3626b8e ANDROID: incremental fs: Evict inodes before freeing mount data
Since evicting inodes triggers writes to the backing file, which uses
the mi_owner field from the mount_info struct, make sure inodes are
evicted before we free the mount_info data

Test: incfs_test
Bug: 270117845
Change-Id: I673b2e0e04b5adc3998caf6f22443598a30338af
Signed-off-by: Paul Lawrence <paullawrence@google.com>
(cherry picked from commit 7899985277527b29c47929a6d6a89c5c89b406ad)
2023-04-04 15:48:57 +00:00
Paul Lawrence
7fd4fbe615 ANDROID: incremental fs: Move throttling to outside page lock
Bug: 241479010
Test: incfs_test passes, play confirm behavior in bug is fixed
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ie51f2b76d0873057f54fecf7fcc793c66df20969
2023-02-22 17:37:54 +00:00
Paul Lawrence
5d9b0e83e3 ANDROID: incremental fs: Fix race between truncate and write last block
Also fix race whereby multiple providers writinig the same block would
actually write out the same block.

Note that multiple_providers_test started failing when incfs was ported
to 5.15, and these fixes are needed to make the test reliable

Bug: 264703896
Test: incfs-test passes, specifically multiple_providers_test. Ran 100
      times
Change-Id: I05ad5b2b2f62cf218256222cecb79bbe9953bd97
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2023-02-22 17:36:34 +00:00
Tadeusz Struk
bcf6dddd97 ANDROID: incfs: Add check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr
Add an explicite check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr.
Both of these attributes can not be set at the same time, otherwise
notify_change() function will check it and invoke BUG(), crashing
the system.

Bug: 243394930

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I91080d68efbd62f1441e20a5c02feef3d1b06e4e
2022-09-19 16:16:16 +00:00
Tadeusz Struk
3e45af8a72 ANDROID: incremental-fs: limit mount stack depth
Syzbot recently found a number of issues related to incremental-fs
(see bug numbers below). All have to do with the fact that incr-fs
allows mounts of the same source and target multiple times.
This is a design decision and the user space component "Data Loader"
expects this to work for app re-install use case.
The mounting depth needs to be controlled, however, and only allowed
to be two levels deep. In case of more than two mount attempts the
driver needs to return an error.
In case of the issues listed below the common pattern is that the
reproducer calls:

mount("./file0", "./file0", "incremental-fs", 0, NULL)

many times and then invokes a file operation like chmod, setxattr,
or open on the ./file0. This causes a recursive call for all the
mounted instances, which eventually causes a stack overflow and
a kernel crash:

BUG: stack guard page was hit at ffffc90000c0fff8
kernel stack overflow (double-fault): 0000 [#1] PREEMPT SMP KASAN

This change also cleans up the mount error path to properly clean
allocated resources and call deactivate_locked_super(), which
causes the incfs_kill_sb() to be called, where the sb is freed.

Bug: 211066171
Bug: 213140206
Bug: 213215835
Bug: 211914587
Bug: 211213635
Bug: 213137376
Bug: 211161296

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I08d9b545a2715423296bf4beb67bdbbed78d1be1
2022-04-06 17:24:59 +00:00
Steve Muckle
3b9fe10e46 ANDROID: incremental-fs: remove spurious kfree()
The reverts in commits 07630c8073 (Revert "ANDROID: incremental-fs:
fix mount_fs issue") and 5db3e72c57 (Revert "ANDROID: incremental-fs:
remove index and incomplete dir on umount") were applied out of order,
resulting in a spurious call to kfree() being left over. Remove it.

Bug: 218732047
Signed-off-by: Steve Muckle <smuckle@google.com>
Change-Id: I6ae8d8a9775981a88d28e462b64b259bca905ffb
2022-02-28 20:49:55 +00:00
Tadeusz Struk
5db3e72c57 Revert "ANDROID: incremental-fs: remove index and incomplete dir on umount"
This reverts commit 6f915dd2af.

This is follow up cleanup after revert of:
"Revert "ANDROID: incremental-fs: fix mount_fs issue"

Bug: 220805927

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I2ff42145dd586ae6ae4c76c3136e1fad14c08952
2022-02-23 10:53:30 -08:00
Paul Lawrence
07630c8073 Revert "ANDROID: incremental-fs: fix mount_fs issue"
This reverts commit 93717b608dd30f9d41b15a72e809238807c68026.

Test: Can now install the same apk twice, and repeated installs are
stable
Bug: 217661925
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I86871c364c17a0d1107b3891a574b72edcf04ea2
(cherry picked from commit d107cd06f26b4d45b1079c7eb857815905198076)
Signed-off-by: Steve Muckle <smuckle@google.com>
2022-02-23 06:35:37 +00:00
Tadeusz Struk
6f915dd2af ANDROID: incremental-fs: remove index and incomplete dir on umount
Cleanup incremental-fs left overs on umount, otherwise incr-fs will
complain as below:

BUG: Dentry {i=47a,n=.incomplete} still in use [unmount of incremental-fs]

This requires vfs_rmdir() of the special index and incomplete dirs.
Also free options.sysfs_name in incfs_mount_fs() instead of in
incfs_free_mount_info() to make it consistent with incfs_remount_fs().

Since set_anon_super() was used in incfs_mount_fs() the incfs_kill_sb()
should use kill_anon_super() instead of generic_shutdown_super()
otherwise it will leak the pseudo dev_t that set_anon_super() allocates.

Bug: 211066171

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I7ea54db63513fc130e1997cbf79121015ee12405
2022-02-14 18:36:59 +00:00
Tadeusz Struk
4b1862e4fc ANDROID: incremental-fs: fix GPF in pending_reads_dispatch_ioctl
It is possible that fget returns NULL. This needs to be handled
correctly in ioctl_permit_fill.

Bug: 212821226

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: Iec8be21982afeab6794b78ab1a542671c52acea2
2022-01-26 11:31:08 +00:00
Tadeusz Struk
fd4c6594f5 ANDROID: incremental-fs: fix mount_fs issue
Syzbot recently found a number of issues related to incremental-fs
(see bug numbers below). All have to do with the fact that incr-fs
allows mounts of the same source and target multiple times.
The correct behavior for a file system is to allow only one such
mount, and then every subsequent attempt should fail with a -EBUSY
error code. In case of the issues listed below the common pattern
is that the reproducer calls:

mount("./file0", "./file0", "incremental-fs", 0, NULL)

many times and then invokes a file operation like chmod, setxattr,
or open on the ./file0. This causes a recursive call for all the
mounted instances, which eventually causes a stack overflow and
a kernel crash:

BUG: stack guard page was hit at ffffc90000c0fff8
kernel stack overflow (double-fault): 0000 [#1] PREEMPT SMP KASAN

The reason why many mounts with the same source and target are
possible is because the incfs_mount_fs() as it is allocates a new
super_block for every call, regardless of whether a given mount already
exists or not. This happens every time the sget() function is called
with a test param equal to NULL.
The correct behavior for an FS mount implementation is to call
appropriate mount vfs call for it's type, i.e. mount_bdev() for
a block device backed FS, mount_single() for a pseudo file system,
like sysfs that is mounted in a single, well know location, or
mount_nodev() for other special purpose FS like overlayfs.
In case of incremental-fs the open coded mount logic doesn't check
for abusive mount attempts such as overlays.
To fix this issue the logic needs to be changed to pass a proper
test function to sget() call, which then checks if a super_block
for a mount instance has already been allocated and also allows
the VFS to properly verify invalid mount attempts.

Bug: 211066171
Bug: 213140206
Bug: 213215835
Bug: 211914587
Bug: 211213635
Bug: 213137376
Bug: 211161296

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I66cfc3f1b5aaffb32b0845b2dad3ff26fe952e27
2022-01-24 21:39:27 +00:00
Greg Kroah-Hartman
d483eed85f ANDROID: GKI: set vfs-only exports into their own namespace
We have namespaces, so use them for all vfs-exported namespaces so that
filesystems can use them, but not anything else.

Some in-kernel drivers that do direct filesystem accesses (because they
serve up files) are also allowed access to these symbols to keep 'make
allmodconfig' builds working properly, but it is not needed for Android
kernel images.

Bug: 157965270
Bug: 210074446
Cc: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iaf6140baf3a18a516ab2d5c3966235c42f3f70de
2022-01-11 09:30:47 +01:00
Lee Jones
aee113fcef ANDROID: Incremental fs: Fix dentry get/put imbalance on vfs_mkdir() failure
Syz{bot,kaller} reports[0]:

  BUG: Dentry ffff888119d8a000{i=0,n=.index}  still in use (1) [unmount of ramfs ramfs]
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 367 at fs/dcache.c:1616 umount_check+0x18d/0x1d0 fs/dcache.c:1607
  Modules linked in:
  CPU: 0 PID: 367 Comm: syz-executor388 Not tainted 5.10.75-syzkaller-01082-g234d53d2bb60 #0
  Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
  RIP: 0010:umount_check+0x18d/0x1d0 fs/dcache.c:1607
  Code: 8b 0b 49 81 c6 f8 03 00 00 48 c7 c7 00 40 2e 85 4c 89 e6 48 8b 55 d0 4c 89 e1 45 89 f8 31 c0 41 56 e8 ae d9 9e ff 48 83 c4 08 <0f> 0b e9 f1 fe ff ff 89 d9 80 e1 07 80 c1 03 38 c1 0f 8c c9 fe ff
  RSP: 0018:ffffc9000096f770 EFLAGS: 00010292
  RAX: 0000000000000055 RBX: ffffffff866af200 RCX: 1ad6b89836e5b500
  RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000000
  RBP: ffffc9000096f7a0 R08: ffffffff81545368 R09: 0000000000000003
  R10: fffff5200012de41 R11: 0000000000000004 R12: ffff888119d8a000
  R13: dffffc0000000000 R14: ffff88811d7373f8 R15: 0000000000000001
  FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 00007f01b7bddb68 CR3: 000000010c4f0000 CR4: 00000000003506b0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
  Call Trace:
   d_walk+0x309/0x540 fs/dcache.c:1326
   do_one_tree fs/dcache.c:1623 [inline]
   shrink_dcache_for_umount+0x8e/0x1b0 fs/dcache.c:1639
   generic_shutdown_super+0x66/0x2c0 fs/super.c:447
   kill_anon_super fs/super.c:1108 [inline]
   kill_litter_super+0x75/0xa0 fs/super.c:1117
   ramfs_kill_sb+0x44/0x50 fs/ramfs/inode.c:270
   deactivate_locked_super+0xb0/0x100 fs/super.c:335
   deactivate_super+0xa5/0xd0 fs/super.c:366
   cleanup_mnt+0x45f/0x510 fs/namespace.c:1118
   __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
   task_work_run+0x147/0x1b0 kernel/task_work.c:154
   exit_task_work include/linux/task_work.h:30 [inline]
   do_exit+0x70e/0x23a0 kernel/exit.c:813
   do_group_exit+0x16a/0x2d0 kernel/exit.c:910
   get_signal+0x133e/0x1f80 kernel/signal.c:2790
   arch_do_signal+0x8d/0x620 arch/x86/kernel/signal.c:805
   exit_to_user_mode_loop kernel/entry/common.c:161 [inline]
   exit_to_user_mode_prepare+0xaa/0xe0 kernel/entry/common.c:191
   syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266
   do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56
   entry_SYSCALL_64_after_hwframe+0x44/0xa9
  RIP: 0033:0x7f01b7b884f9
  Code: Unable to access opcode bytes at RIP 0x7f01b7b884cf.
  RSP: 002b:00007f01b7b19308 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
  RAX: fffffffffffffe00 RBX: 00007f01b7c103f8 RCX: 00007f

Which was due to a missing dput() before returning from a vfs_mkdir() failure.

Bug: 203827798
Link: [0] https://syzkaller.appspot.com/bug?extid=81b5ca9b2848f4dad8fa
Reported-by: syzbot+81b5ca9b2848f4dad8fa@syzkaller.appspotmail.com
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Change-Id: Iaef9aa0aecc964645aaca5fe8d79388ae28527bd
2021-11-02 09:01:06 +00:00
Matthias Maennich
d0a88ae479 ANDROID: Enable GKI Dr. No Enforcement
This effectively locks down OWNERS approval to a small group to guard
the code base against unintentional breakages.

Bug: 194314089
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: Ifd1ea97639a622320ea83f901f6451e2e52b38d4
2021-07-21 20:51:47 +01:00
Paul Lawrence
b6e60f0673 ANDROID: Incremental fs: Add uid to INCFS_IOC_GET_LAST_READ_ERROR
Bug: 186796876
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I552cae5e87b004202364ba5c9c5f9febb9e106f2
2021-05-17 20:08:43 +00:00
Paul Lawrence
25c3b9e0fe ANDROID: Incremental fs: Make sysfs_name changeable on remount
Bug: 187829246
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I1762f170c8a8a2fb7672f65c402e82ab95aeef8a
2021-05-17 20:08:37 +00:00
Paul Lawrence
ed8f5159f0 ANDROID: Incremental fs: Count pending_reads even when very short
Bug: 187836970
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Id4fe5fe2b60a76fb81ca85f8889a53a11bd7a4d4
2021-05-17 20:08:28 +00:00
Paul Lawrence
327b2266d2 ANDROID: Incremental fs: Fix pseudo-file attributes
Prior change

ANDROID: Incremental fs: stat should return actual used blocks

adds blocks to getattr. Unfortunately the code always looks for the
backing file, and pseudo files don't have backing files, so getattr
fails for pseudo files.

Bug: 186567511
Test: incfs_test passes, can do incremental installs on test device
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ia3df87f3683e095d05c822b69747515963c95f1c
(cherry picked from commit 9d00e67d8b1145d0dff809b6194faa3c11e10615)
2021-04-28 22:07:07 +00:00
Paul Lawrence
acc13a8440 ANDROID: Incremental fs: Add INCFS_IOC_GET_LAST_READ_ERROR
Bug: 184291759
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: If46e91f9c992337d53970573c238be965187761e
2021-04-23 15:16:39 +00:00
Paul Lawrence
6cce4fa251 ANDROID: Incremental fs: Fix INCFS_MAGIC_NUMBER casts
Sparse complains about casting a five byte number to a ulong on 32-bit
platorms. Fix by anding the constant with ULONG_MAX

Bug: 186015158
Test: incfs_test passes, sparse reports no warnings on 32 & 64 bit builds
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ic83e03626b7f290370d75b3aaba187b8392fb344
2021-04-23 15:16:32 +00:00
Paul Lawrence
44ffa65110 ANDROID: Incremental fs: Add status to sysfs
Adding seven sysfs entries per mount:

reads_failed_timed_out
reads_failed_hash_verification
reads_failed_other
reads_delayed_pending
reads_delayed_pending_us
reads_delayed_min
reads_delayed_min_us

to allow for status monitoring from userland

Change-Id: I50677511c2af4778ba0c574bb80323f31425b4d0
Test: incfs_test passes
Bug: 160634343
Bug: 184291759
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2021-04-23 15:16:25 +00:00
Carlos Llamas
3d471f0108 ANDROID: Incremental fs: fix u64 integer cast to pointer
Compiler (arm-linux-gnueabihf-gcc 8.3.0) complains about an invalid cast
of an __aligned_u64 integer to a pointer on 32-bit architectures. Using
u64_to_user_ptr() for the cast fixes the following warning:

fs/incfs/pseudo_files.c: In function ‘ioctl_create_file’:
fs/incfs/pseudo_files.c:656:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  656 |          (u8 __user *)args.signature_info,
      |          ^

Bug: 183339614
Fixes: bc6a70e849 (ANDROID: Incremental fs: Remove signature checks from kernel)
Reported-by: kernelci.org bot <bot@kernelci.org>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Change-Id: I98a987fb83c160740796c0b4b3fdd7551880e12a
2021-04-23 15:16:19 +00:00
Paul Lawrence
ba9602b155 ANDROID: Incremental fs: stat should return actual used blocks
Test: incfs_test passes
Bug: 182182100
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I4c9e5f111fbb659798ef79bc20d8a65b64b44ded
2021-04-23 15:16:12 +00:00
Paul Lawrence
f4c368a3f9 ANDROID: Incremental fs: Add FS_IOC_READ_VERITY_METADATA
Bug: 180942327
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I6d6532496c072145f22bcf9ff4499ec3f52e94b5
2021-04-23 15:16:03 +00:00
Carlos Llamas
fc380a2a73 ANDROID: Incremental fs: fix minor printk format warning
Use the correct printk specifier [%zu] for size_t variable.
This fixes the following warning:

fs/incfs/format.c: In function ‘incfs_read_next_metadata_record’:
./include/linux/kern_levels.h:5:18: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
fs/incfs/format.c:669:3: note: in expansion of macro ‘pr_warn’
  669 |   pr_warn("incfs: The record is too large. Size: %ld",
      |   ^~~~~~~

Bug: 183339614
Fixes: c6819dd778 (ANDROID: Initial commit of Incremental FS)
Reported-by: kernelci.org bot <bot@kernelci.org>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Change-Id: Ia784a9ced9fb6bc76e2f1baa495b3ccf568e3b1d
(cherry picked from commit d83b0684e15113d6053ba2dfdcac903d7038f707)
2021-04-15 15:22:01 +00:00
Matthias Maennich
2e4b322b06 ANDROID: Add OWNERS files referring to the respective android-mainline OWNERS
This was generated with
  $ build/synchronize_owners common-mainline/ android-mainline common12-5.10/

Bug: 184248201
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: I5e56eb34fcbb5a2a013dd03bc9dcc4f159fb90de
2021-04-03 14:11:30 +00:00
Paul Lawrence
16ce7f9c5e ANDROID: Incremental fs: Truncate file when complete
Bug: 182185202
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I96a192011f19efa1c597275dafc6c216f8ed0b56
2021-04-01 11:10:22 -07:00
Paul Lawrence
38d8cfc0bd ANDROID: Incremental fs: Fix mlock to fail gracefully on corrupt files
Test: incfs_test passes
Bug: 174875107
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I93ce3600e88ddd89cf69f032ea858d169b0a7bec
2021-04-01 11:10:22 -07:00
Paul Lawrence
2a8c6b0f30 ANDROID: Incremental fs: Finer readlog compression internally
Bug: 182196484
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Icad395115ad81cc267046f7a41b41046077bb78b
2021-04-01 11:10:22 -07:00
Paul Lawrence
5c023f6fd1 ANDROID: Incremental fs: Support STATX_ATTR_VERITY
Bug: 181242243
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Id996e0d5d95c8b42254d1e1e0c1dad9317183a17
2021-04-01 11:10:22 -07:00
Yurii Zubrytskyi
de43680982 ANDROID: Incremental fs: set the correct access to mapped files
Backing file needs to have write permissions for all users
even though the mounted view doesn't - otherwise incfs can't
change the internal file data.

Bug: 180535478
Test: adb install <apk>
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I5d7915b28072cff1508ba45b56e844cb678ca466
2021-03-01 16:16:08 +00:00
Paul Lawrence
0b62157672 ANDROID: Incremental fs: Build merkle tree when enabling verity
For incfs files that were created without a merkle tree, enabling verity
requires building a merkle tree first. Although this is the same logic
as verity performs, it is not that easy to reconcile the two given that
incfs has the merkle tree potentially when verity is not enabled.

Bug: 160634504
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>

Change-Id: Ia15a4051fa3362820846d65859e3af76b77f8cc4
2021-03-01 16:16:01 +00:00
Paul Lawrence
850059da54 ANDROID: Incremental fs: Add FS_IOC_MEASURE_VERITY
Add ioctl to return the verity file digest, compatible with the identical
ioctl in fs/verity/.

Bug: 160634504
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I1bc2dc975b9be122e1c831a25a1d44f27a360f3c
2021-03-01 16:15:54 +00:00
Paul Lawrence
c630401723 ANDROID: Incremental fs: Store fs-verity state in backing file
Now fsverity state is preserved across inode eviction.

Added incfs.verity xattr to track when a file is fs-verity enabled.

Bug: 160634504
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I41d90abd55527884d9eff642c9834ad837ff6918
2021-03-01 16:15:46 +00:00
Paul Lawrence
cf76ed2f0c ANDROID: Incremental fs: Add FS_IOC_GETFLAGS
Add FS_IOC_GETFLAGS ioctl to incfs. Currently this will only get the
S_VERITY flag.

Bug: 160634504
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Id79add0db0d66f604ca0f222fe5faec91450ade5
2021-03-01 16:15:39 +00:00
Paul Lawrence
5bb92dffc9 ANDROID: Incremental fs: Add FS_IOC_ENABLE_VERITY
Add FS_IOC_ENABLE_VERITY ioctl

When called, calculate measurement, validate signature against fsverity,
and set S_VERITY flag.

This does not (yet) preserve the verity status once the inode is
evicted.

Bug: 160634504
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I88af2721f650098accc72a64528c7d85b753c7f6
2021-03-01 16:15:32 +00:00
Paul Lawrence
695e0c5423 ANDROID: Incremental fs: Fix memory leak on closing file
Bug: 179271514
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Idc42d02b1df5ac84bdd04e728bfcca5f4cc5d07b
2021-03-01 16:15:18 +00:00
Paul Lawrence
400d6734bb ANDROID: Incremental fs: inotify on create mapped file
Bug: 175323815
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I670e8a7f4a68012d68718a431be3450646a614c0
2021-03-01 16:15:11 +00:00
Paul Lawrence
a699d0a2ab ANDROID: Incremental fs: inotify support
Bug: 175323815
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ife372fa2f10dd51f61def9feb461e965d276c6bf
2021-03-01 16:15:03 +00:00
Paul Lawrence
3d04fb2c95 ANDROID: Incremental fs: Make data validation failure a warn
Bug: 177234986
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I79b4273a050b8695b5810abd618fcb4437a05ce5
2021-01-14 16:03:13 +00:00
Paul Lawrence
4994a7321f ANDROID: Incremental fs: Free mount info after files are flushed
Bug: 177280103
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I24b0d4bf5353834900f868f65e7510529867b615
2021-01-14 16:03:02 +00:00
Paul Lawrence
a3c935a490 ANDROID: Incremental fs: Fix selinux issues
Bug: 177075428
Test: incfs_test passes
      atest GtsIncrementalInstallTestCases has only 8 failures
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I73accfc1982aec1cd7947996c25a23e4a97cfdac
2021-01-14 16:02:51 +00:00
Yurii Zubrytskyi
b79605a904 ANDROID: Incremental fs: fix .blocks_written
.blocks_writen file handling was missing some operations:
SELinux xattr handlers, safety checks for it being a
pseudo file etc.

This CL generalizes pseudo file handling so that all such
files work in a generic way and next time it should be
easier to add all operations at once.

Bug: 175823975
Test: incfs_tests pass
Change-Id: Id2b1936018c81c62c8ab4cdbaa8827e2679b513f
Signed-off-by: Yurii Zubrytskyi <zyy@google.com>
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2021-01-14 16:02:38 +00:00
Paul Lawrence
dedf46b2a7 ANDROID: Incremental fs: Set credentials before reading/writing
Bug: 174692664
Test: incfs_test passes, incremental installs work with ag/13082306
Signed-off-by: Paul Lawrence <paullawrence@google.com>

Change-Id: Ib1c924bbaff759f58f7d83bad8e23d7224ba7ed9
2020-12-10 20:16:16 +00:00
Paul Lawrence
5ef8ab7172 ANDROID: Incremental fs: Change per UID timeouts to microseconds
Bug: 174495152
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Id76d2fec83a0eb7b70ad85f1fac81bf319563a66
2020-12-10 20:16:01 +00:00
Paul Lawrence
6fb25c4252 ANDROID: Incremental fs: Add v2 feature flag
Roll report_uid feature flag into v2 feature flag

Bug: 174478527
Test: Feature flag present on boot
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I41ee9715904560004e25cc83a5ccc1eb1bdd2b1f
2020-12-10 20:15:54 +00:00
Paul Lawrence
affa585cc0 ANDROID: Incremental fs: Add zstd feature flag
Bug: 174478527
Test: Boot, look for flag
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ib573b5420143bd177b50311a3e8cc3a7e8541b96
2020-12-10 20:15:46 +00:00
Paul Lawrence
95a43fc99f ANDROID: Incremental fs: Add zstd compression support
Bug: 160634783
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Iba28b535d2d5183859ffc721204b036434132d9b
2020-11-05 23:00:32 +00:00