* [PATCH] erofs: impersonate the opener's credentials when accessing backing file
@ 2025-06-12 10:18 Tatsuyuki Ishi
2025-06-12 11:28 ` Gao Xiang
2025-06-18 1:46 ` Hongbo Li
0 siblings, 2 replies; 3+ messages in thread
From: Tatsuyuki Ishi @ 2025-06-12 10:18 UTC (permalink / raw)
To: Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale, Hongbo Li
Cc: linux-erofs, linux-kernel, shengyong1, wangshuai12, Tatsuyuki Ishi
Previously, file operations on a file-backed mount used the current
process' credentials to access the backing FD. Attempting to do so on
Android lead to SELinux denials, as ACL rules on the backing file (e.g.
/system/apex/foo.apex) is restricted to a small set of process.
Arguably, this error is redundant and leaking implementation details, as
access to files on a mount is already ACL'ed by path.
Instead, override to use the opener's cred when accessing the backing
file. This makes the behavior similar to a loop-backed mount, which
uses kworker cred when accessing the backing file and does not cause
SELinux denials.
Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
---
fs/erofs/fileio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c
index 7d81f504bff08f3d5c5d44d131460df5c3e7847d..df5cc63f2c01eb5e7ec4afab9e054ea12cea7175 100644
--- a/fs/erofs/fileio.c
+++ b/fs/erofs/fileio.c
@@ -47,6 +47,7 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
{
+ const struct cred *old_cred;
struct iov_iter iter;
int ret;
@@ -60,7 +61,9 @@ static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
rq->iocb.ki_flags = IOCB_DIRECT;
iov_iter_bvec(&iter, ITER_DEST, rq->bvecs, rq->bio.bi_vcnt,
rq->bio.bi_iter.bi_size);
+ old_cred = override_creds(rq->iocb.ki_filp->f_cred);
ret = vfs_iocb_iter_read(rq->iocb.ki_filp, &rq->iocb, &iter);
+ revert_creds(old_cred);
if (ret != -EIOCBQUEUED)
erofs_fileio_ki_complete(&rq->iocb, ret);
}
---
base-commit: cd2e103d57e5615f9bb027d772f93b9efd567224
change-id: 20250612-b4-erofs-impersonate-d6c2926c56ca
Best regards,
--
Tatsuyuki Ishi <ishitatsuyuki@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs: impersonate the opener's credentials when accessing backing file
2025-06-12 10:18 [PATCH] erofs: impersonate the opener's credentials when accessing backing file Tatsuyuki Ishi
@ 2025-06-12 11:28 ` Gao Xiang
2025-06-18 1:46 ` Hongbo Li
1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2025-06-12 11:28 UTC (permalink / raw)
To: Tatsuyuki Ishi, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu,
Sandeep Dhavale, Hongbo Li
Cc: linux-erofs, linux-kernel, shengyong1, wangshuai12
Hi Tatsuyuki,
On 2025/6/12 18:18, Tatsuyuki Ishi wrote:
> Previously, file operations on a file-backed mount used the current
> process' credentials to access the backing FD. Attempting to do so on
> Android lead to SELinux denials, as ACL rules on the backing file (e.g.
> /system/apex/foo.apex) is restricted to a small set of process.
> Arguably, this error is redundant and leaking implementation details, as
> access to files on a mount is already ACL'ed by path.
>
> Instead, override to use the opener's cred when accessing the backing
> file. This makes the behavior similar to a loop-backed mount, which
> uses kworker cred when accessing the backing file and does not cause
> SELinux denials.
>
> Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Thanks for the patch. I think overlayfs uses the similar policy
(mounter's cred), which is the same as the opener's cred here
(because it opens backing file in the mount context), so:
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs: impersonate the opener's credentials when accessing backing file
2025-06-12 10:18 [PATCH] erofs: impersonate the opener's credentials when accessing backing file Tatsuyuki Ishi
2025-06-12 11:28 ` Gao Xiang
@ 2025-06-18 1:46 ` Hongbo Li
1 sibling, 0 replies; 3+ messages in thread
From: Hongbo Li @ 2025-06-18 1:46 UTC (permalink / raw)
To: Tatsuyuki Ishi, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu, Sandeep Dhavale
Cc: linux-erofs, linux-kernel, shengyong1, wangshuai12
On 2025/6/12 18:18, Tatsuyuki Ishi wrote:
> Previously, file operations on a file-backed mount used the current
> process' credentials to access the backing FD. Attempting to do so on
> Android lead to SELinux denials, as ACL rules on the backing file (e.g.
> /system/apex/foo.apex) is restricted to a small set of process.
> Arguably, this error is redundant and leaking implementation details, as
> access to files on a mount is already ACL'ed by path.
>
> Instead, override to use the opener's cred when accessing the backing
> file. This makes the behavior similar to a loop-backed mount, which
> uses kworker cred when accessing the backing file and does not cause
> SELinux denials.
>
> Signed-off-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
> ---
> fs/erofs/fileio.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c
> index 7d81f504bff08f3d5c5d44d131460df5c3e7847d..df5cc63f2c01eb5e7ec4afab9e054ea12cea7175 100644
> --- a/fs/erofs/fileio.c
> +++ b/fs/erofs/fileio.c
> @@ -47,6 +47,7 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
>
> static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
> {
> + const struct cred *old_cred;
> struct iov_iter iter;
> int ret;
>
> @@ -60,7 +61,9 @@ static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
> rq->iocb.ki_flags = IOCB_DIRECT;
> iov_iter_bvec(&iter, ITER_DEST, rq->bvecs, rq->bio.bi_vcnt,
> rq->bio.bi_iter.bi_size);
> + old_cred = override_creds(rq->iocb.ki_filp->f_cred);Yeah, rq->iocb.ki_filp keep the opener's cred, so:
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Thanks,
Hongbo
> ret = vfs_iocb_iter_read(rq->iocb.ki_filp, &rq->iocb, &iter);
> + revert_creds(old_cred);
> if (ret != -EIOCBQUEUED)
> erofs_fileio_ki_complete(&rq->iocb, ret);
> }
>
> ---
> base-commit: cd2e103d57e5615f9bb027d772f93b9efd567224
> change-id: 20250612-b4-erofs-impersonate-d6c2926c56ca
>
> Best regards,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-18 1:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12 10:18 [PATCH] erofs: impersonate the opener's credentials when accessing backing file Tatsuyuki Ishi
2025-06-12 11:28 ` Gao Xiang
2025-06-18 1:46 ` Hongbo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®