Similar to commit 905eeb2b7c33 ("erofs: impersonate the opener's
credentials when accessing backing file"), rw_verify_area() needs
the same too.

Fixes: 307210c262a2 ("erofs: verify metadata accesses for file-backed mounts")
Cc: Carlos Llamas <[email protected]>
Cc: Sandeep Dhavale <[email protected]>
Cc: Tatsuyuki Ishi <[email protected]>
Signed-off-by: Gao Xiang <[email protected]>
---
Can we verify this patch resolve the android-mainline issue?

 fs/erofs/data.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index b2c12c5856ac..51b8e860b6b2 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -40,9 +40,11 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, 
bool need_kmap)
         */
        if (buf->file) {
                fpos = (loff_t)index << PAGE_SHIFT;
-               err = rw_verify_area(READ, buf->file, &fpos, PAGE_SIZE);
-               if (err < 0)
-                       return ERR_PTR(err);
+               scoped_with_creds(buf->file->f_cred) {
+                       err = rw_verify_area(READ, buf->file, &fpos, PAGE_SIZE);
+                       if (err < 0)
+                               return ERR_PTR(err);
+               }
        }
 
        if (buf->page) {
-- 
2.43.5


Reply via email to