From: David Howells Date: Fri, 19 May 2023 17:21:20 +0000 (+0100) Subject: cachefiles: Allow the cache to be non-root X-Git-Tag: v6.6.17~4638^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79aa28494638f03a9e664163cb4620eb0482aaa2;p=platform%2Fkernel%2Flinux-rpi.git cachefiles: Allow the cache to be non-root Set mode 0600 on files in the cache so that cachefilesd can run as an unprivileged user rather than leaving the files all with 0. Directories are already set to 0700. Userspace then needs to set the uid and gid before issuing the "bind" command and the cache must've been chown'd to those IDs. Signed-off-by: David Howells Reviewed-by: Jeff Layton Reviewed-by: Gao Xiang cc: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-erofs@lists.ozlabs.org cc: linux-fsdevel@vger.kernel.org Message-Id: <1853230.1684516880@warthog.procyon.org.uk> Signed-off-by: Christian Brauner --- diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 82219a8..66482c1 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -451,7 +451,8 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) ret = cachefiles_inject_write_error(); if (ret == 0) { - file = vfs_tmpfile_open(&nop_mnt_idmap, &parentpath, S_IFREG, + file = vfs_tmpfile_open(&nop_mnt_idmap, &parentpath, + S_IFREG | 0600, O_RDWR | O_LARGEFILE | O_DIRECT, cache->cache_cred); ret = PTR_ERR_OR_ZERO(file);