Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

erofs: verify metadata accesses for file-backed mounts

For file-backed mounts, metadata is fetched via the page cache of
backing inodes to avoid double caching and redundant copy ops out
of RO uptodate folios, which is used by Android APEXes, ComposeFS,
containerd. However, rw_verify_area() was missing prior to
metadata accesses.

Similar to vfs_iocb_iter_read(), fix this by:
- Enabling fanotify pre-content hooks on metadata accesses;
- security_file_permission() for security modules.

Verified that fanotify pre-content hooks now works correctly.

Fixes: fb176750266a ("erofs: add file-backed mount support")
Acked-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Chunhai Guo <guochunhai@vivo.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Gao Xiang 307210c2 6a01f547

+14
+14
fs/erofs/data.c
··· 30 30 { 31 31 pgoff_t index = (buf->off + offset) >> PAGE_SHIFT; 32 32 struct folio *folio = NULL; 33 + loff_t fpos; 34 + int err; 35 + 36 + /* 37 + * Metadata access for file-backed mounts reuses page cache of backing 38 + * fs inodes (only folio data will be needed) to prevent double caching. 39 + * However, the data access range must be verified here in advance. 40 + */ 41 + if (buf->file) { 42 + fpos = index << PAGE_SHIFT; 43 + err = rw_verify_area(READ, buf->file, &fpos, PAGE_SIZE); 44 + if (err < 0) 45 + return ERR_PTR(err); 46 + } 33 47 34 48 if (buf->page) { 35 49 folio = page_folio(buf->page);