All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH] cachefiles: Use the cache's credentials for reads and writes
Date: Thu, 03 Dec 2026 12:23:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-247715@kernel.org> (raw)
In-Reply-To: <20261203120210.2-1-kim@sondrup.io>

> When a confined task (such as a container or VM running under
> container_t) reads from a network filesystem with fscache under SELinux
> enforcing, every cache read fails and data is refetched from the server.
> Furthermore, since commit e2d46f2ec332 ("netfs: Change the read result
> collector to only use one work item"), in-task copy-to-cache writes
> (such as through memory mappings) are denied as well. Each failure logs
> an SELinux denial:
> 
>   avc:  denied  { read } for  pid=... comm=...
>     scontext=system_u:system_r:container_t:s0:c355,c657
>     tcontext=system_u:object_r:cachefiles_var_t:s0 tclass=file
> 
> Cachefiles opens backing cache files with the cache's credentials, and
> Documentation/filesystems/caching/cachefiles.rst ("Security Model and
> SELinux") specifies that it should switch to those credentials when
> accessing the cache. However, cachefiles_read() and __cachefiles_write()
> do not switch, so vfs_iocb_iter_read() and vfs_iocb_iter_write()
> revalidate access against the calling task's SID via
> security_file_permission(), which gets denied.
> 
> Switch to the cache's credentials around the read and write operations,
> matching cachefiles_prepare_write() and cachefiles_issue_write(). Primary
> access checks remain enforced on the network filesystem inode, so the
> task gains no unauthorized access. With this change, cache reads and
> writes succeed under SELinux enforcing with zero denials.
> 
> Fixes: 047487c947e8 ("cachefiles: Implement the I/O routines")
> Cc: stable@vger.kernel.org
> Signed-off-by: Kim Sondrup <kim@sondrup.io>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203120210.2-1-kim@sondrup.io?part=1

      reply	other threads:[~2026-12-03 12:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 12:02 [PATCH] cachefiles: Use the cache's credentials for reads and writes Kim Sondrup
2026-12-03 12:23 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-247715@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.