Commit Graph

126 Commits

Author SHA1 Message Date
Paul Lawrence
e302f3a21b ANDROID: incremental-fs: Make work with 16k pages
Bug: 260919895
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ia4fbb6011930b085bc00a36851e9b0e8559d3dc5
(cherry picked from commit 5ac10739bcf2dae9220a7a39392aa41235bc64c2)
2024-05-29 13:21:53 +00:00
Lee Jones
9b655e9328 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-18 17:21:16 +00:00
Matthias Maennich
73185e2d4e ANDROID: Remove all but top-level OWNERS
Now that the branch is used to create production GKI
images, need to institute ACK DrNo for all commits.

The DrNo approvers are in the android-mainline branch
at /OWNERS_DrNo.

Bug: 287162457
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: Id5bb83d7add5f314df6816c1c51b4bf2d8018e79
2023-06-15 09:54:33 +01:00
Paul Lawrence
8ff940b351 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 22:27:50 +00:00
Paul Lawrence
ae068d4b32 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 19:22:01 +00:00
Paul Lawrence
96e377f2cd 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 19:22:01 +00:00
Tadeusz Struk
7eaac3e1c5 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-21 00:48:25 +00:00
Greg Kroah-Hartman
63fd983e4f ANDROID: Incremental fs: fix setxattr callbacks due to upstream changes
In commit 0c5fd887d2 ("acl: move idmapped mount fixup into
vfs_{g,s}etxattr()") the signature of setxattr has changed, so fixup
incfs so that it continues to build properly.

Someday this will be merged upstream and this type of maintenance will
happen automagically...

Fixes: 0c5fd887d2 ("acl: move idmapped mount fixup into vfs_{g,s}etxattr()")
Cc: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I78e4af3fb999cf0ffc1128ccc15d6af6a3b1f591
2022-08-03 16:37:31 +02:00
Nathan Chancellor
483887d651
ANDROID: Incremental fs: Use ERR_CAST in handle_mapped_file()
When building android-mainline with a version of clang that supports
CONFIG_RANDSTRUCT, there are errors about casts from randomized
structures to non-randomized structures:

  fs/incfs/data_mgmt.c:240:10: error: casting from randomized structure pointer type 'struct dentry *' to 'struct data_file *'
                  return (struct data_file *)index_file_dentry;
                         ^
  fs/incfs/data_mgmt.c:257:12: error: casting from randomized structure pointer type 'struct file *' to 'struct data_file *'
                  result = (struct data_file *)bf;
                           ^
  2 errors generated.

As suggested by Kees on aosp/1995750, these casts should actually be
using the ERR_CAST macro, which is a more proper way to pass error
pointers around.

Change-Id: Iab73ac7503235f1147154a01a22ab8608e3daf8b
Fixes: 3f4938108a ("ANDROID: Incremental fs: Create mapped file")
Link: https://github.com/ClangBuiltLinux/linux/issues/1652
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2022-06-23 12:54:22 -07:00
Greg Kroah-Hartman
080d4caf55 ANDROID: incremental-fs: convert to read_folio
This is a "weak" conversion which converts straight back to using pages
to keep the build working properly.

A full conversion should be performed at some point, hopefully by
someone familiar with the filesystem.

Fixes: 7e0a126519 ("mm,fs: Remove aops->readpage")
CC: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Id34db2c71743731d6a69b7b566a1f3a0a12dffe1
2022-06-08 12:57:59 +02:00
Paul Lawrence
9d2f688e65 ANDROID: Incremental fs: Mark merkle tree pages uptodate
The merkle tree pages at the end of the incremental files were being
zero'd and marked uptodate on 5.15. Mark uptodate on creation to prevent
this.

Bug: 197663427
Test: The test in that bug now passes on 5.15 kernel
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I5c0781c51bfbc64929e7a465db1ae975ce5928f9
(cherry picked from commit 68d2a58b28ecad58340643ebab511ecd2689c2b1)
2022-04-18 17:46:43 +00:00
Tadeusz Struk
05e060a157 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 20:10:49 +00:00
Tadeusz Struk
185610e38e Revert "ANDROID: incremental-fs: fix mount_fs issue"
This reverts commit f35524a260.

This is to fix the incrementalinstall test.
This is the second revert required on android-mainline
Can now install the same apk twice, and repeated installs are stable.

Bug: 217661925
Bug: 219731048

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I941faf5420dbdcaaac13064542f627bb1dd1a572
2022-03-17 15:40:23 -07:00
Tadeusz Struk
d28e72df1d Revert "ANDROID: incremental-fs: remove index and incomplete dir on umount"
This reverts commit 8f40a6318c.

Two reverts needed on android-mainline to fix increment-fs regression.
This is the first one.
Test: Can now install the same apk twice, and repeated installs are
stable.

Bug: 217661925
Bug: 218732047
Bug: 219731048

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: I7a72bba7e44b039ef0383af1fcc8edadab8c5b5c
2022-03-17 15:37:34 -07:00
Tadeusz Struk
5dead96542 ANDROID: incremental-fs: populate userns before calling vfs_rename
The old and new mount user name spaces need to be populated
before calling vfs_rename().

Bug: 211066171

Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org>
Change-Id: Ieac6975abb4131c8f5bdefe25b5f241c80023e38
2022-02-01 16:47:58 +00:00
Tadeusz Struk
8f40a6318c 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-01 16:47:39 +00:00
Tadeusz Struk
44efc592e5 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-21 16:24:30 +00:00
Tadeusz Struk
f35524a260 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-20 03:23:16 +00:00
Greg Kroah-Hartman
b258009529 ANDROID: Incremental fs: fix build due to zstd api changes
Commit cf30f6a5f0 ("lib: zstd: Add kernel-specific API") changed the
zstd api.  Given that the incfs code is not in the kernel tree, it was
not also converted so do that here to keep the build working properly.

Fixes: cf30f6a5f0 ("lib: zstd: Add kernel-specific API")
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I2e786a5e032adf104c0f3778bfb516a58c134047
2021-11-23 11:46:06 +01:00
Lee Jones
a7e3180850 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-10-26 15:08:40 +00:00
Greg Kroah-Hartman
e446554f63 ANDROID: Incremental fs: fix up the build for 5.15-rc1
In commit edb0872f44 ("block: move the bdi from the request_queue to
the gendisk"), the backing device info moved .h files which breaks the
building of incfs.  Fix this up like was done for fat, just include the
correct .h file.

Fixes: edb0872f44 ("block: move the bdi from the request_queue to the gendisk")
CC: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iccc990b1b01af4580192921410b915b91dc6a155
2021-09-06 13:50:51 +02:00
Paul Lawrence
3660078a6b 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-18 19:36:39 +00:00
Paul Lawrence
db66181a42 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-18 19:36:32 +00:00
Paul Lawrence
f3008737e7 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-18 19:36:23 +00:00
Lee Jones
48937ca428 ANDROID: Incremental fs: Explicitly include <linux/pagemap.h>
<linux/blkdev.h> no longer includes <linux/pagemap.h>.

Besides, source files should explicitly include headers providing used
functionality anyway.

Fixes: 4ee60ec156 ("include: remove pagemap.h from blkdev.h")
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Change-Id: I6d28e5cc100780ecd74f5d772f08fd4b0f977898
2021-05-11 18:02:00 +00:00
Paul Lawrence
9d00e67d8b 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
2021-04-27 21:37:16 +00:00
Paul Lawrence
c9a0b73d25 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-22 16:33:00 +00:00
Paul Lawrence
c52d623f04 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-21 20:26:00 +00:00
Paul Lawrence
bfee974e81 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-21 14:35:45 +00:00
Carlos Llamas
dc7b23f23c 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-16 00:34:51 +00:00
Carlos Llamas
d83b0684e1 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
2021-04-15 15:18:35 +00:00
Paul Lawrence
30f7628830 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-13 19:43:44 +00:00
Paul Lawrence
d434336cff 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-13 15:22:56 +00:00
Paul Lawrence
f75e40b0c7 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-03-24 16:10:08 +00:00
Paul Lawrence
dc07a7efb6 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-03-24 16:09:51 +00:00
Paul Lawrence
fe2917fdb9 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-03-11 08:42:18 -08:00
Paul Lawrence
bc5c0903a7 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-03-11 08:42:18 -08:00
Greg Kroah-Hartman
2fec063693 ANDROID: Incremental fs: fix up for recent vfs changes
Lots of different vfs changes happened in 7d6beb71da ("Merge tag
'idmapped-mounts-v5.12' of
git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux") which were
not made to incfs as it is out-of-tree :(

So fix it up by doing a quick port to the initial user namespace and
hopefully all works properly now, at least it builds :)

Fixes: 7d6beb71da ("Merge tag 'idmapped-mounts-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux")
Cc: Paul Lawrence <paullawrence@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I32899a792fbfad9455d504868e7a02d30a0a6049
2021-03-06 19:50:59 +01:00
Greg Kroah-Hartman
c4299f9857 Revert "FROMLIST: Add flags option to get xattr method paired to __vfs_getxattr"
This reverts commit 3484eba91d.

It's causing too many merge issues, so revert it for now and hopefully
bring it back later...

Cc: Mark Salyzyn <salyzyn@android.com>
Bug: 133515582
Bug: 136124883
Bug: 129319403
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Id70a37d9471eff58f0027a1371538858136604d3
2021-03-06 12:51:05 +01:00
Matthias Maennich
1d1197098c ANDROID: add initial set of OWNERS
In order to provide better reviewer suggestions and to introduce fine
grained additional approval permissions, sprinkle some OWNERS files over
the tree.

This essentially grants additional OWNERS permissions in
  - net/
  - arch/arm*/net
  - arch/x86/net
  - drivers/net
  - fs/crypto
  - fs/f2fs
  - fs/verity

All other permissions are already covered by ref/meta/config:OWNERS.

Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: I02a6563e4dd63842af37c50f7180bf38e9b9b4be
2021-02-25 13:58:58 +00:00
Yurii Zubrytskyi
5bf1af0c98 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-02-22 18:50:56 +00:00
Paul Lawrence
6d18d83e6c 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-02-10 14:46:45 -08:00
Paul Lawrence
822f25ac84 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-02-10 14:41:17 -08:00
Paul Lawrence
ab6055cb62 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-02-10 14:41:14 -08:00
Paul Lawrence
ab19218f50 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-02-10 14:19:46 -08:00
Paul Lawrence
ca9597811d 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-02-10 14:19:46 -08:00
Paul Lawrence
5743e27cb8 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-02-03 18:56:46 +00:00
Paul Lawrence
d52341bb66 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-02-01 09:51:06 -08:00
Paul Lawrence
fe9f1726b2 ANDROID: Incremental fs: inotify support
Bug: 175323815
Test: incfs_test passes
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ife372fa2f10dd51f61def9feb461e965d276c6bf
2021-01-27 16:31:47 +00:00
Paul Lawrence
4ca9a3c4d7 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-12 22:18:33 +00:00