[PATCH 0/3] Fix incorrect overlayfs mmap() and mprotect() LSM access controls
Amir Goldstein
amir73il at gmail.com
Tue Mar 17 18:25:58 AEDT 2026
On Mon, Mar 16, 2026 at 10:59 PM Paul Moore <paul at paul-moore.com> wrote:
>
> On Mon, Mar 16, 2026 at 5:36 PM Paul Moore <paul at paul-moore.com> wrote:
> >
> > The existing mmap() and mprotect() LSM access control points for the
> > overlayfs filesystem are incomplete in that they do not cover both the
> > user and backing files. This patchset corrects this through the addition
> > of a new backing file specific LSM hook, security_mmap_backing_file(),
> > a new user path file associated with a backing file that can be used by
> > LSMs in the security_file_mprotect() code path, and the associated
> > SELinux code changes.
> >
> > The security_mmap_backing_file() hook is intended to allow LSMs to apply
> > access controls on mmap() operations accessing a backing file, similar to
> > the security_mmap_file() for user files. Due to the details around the
> > accesses and the desire to distinguish between the two types of accesses,
> > a new LSM hook was needed. More information on this new hook can be
> > found in the associated patch.
> >
> > The new user path file replaces the existing user path stored in the
> > backing file. This change was necessary to support LSM based access
> > controls in the mprotect() code path where only one file is accessible
> > via the vma->vm_file field. Unfortunately, storing a reference to the
> > user file inside the backing file does not work due to the cyclic
> > ref counting so a stand-in was necessary, the new user O_PATH file.
> > This new O_PATH file is intended to be representative of the original
> > user file and can be used by LSMs to make access control decisions based
> > on both the backing and user files.
> >
> > The SELinux changes in this patchset involve making use of the new
> > security_mmap_backing_file() hook and updating the existing mprotect()
> > access controls to take into account both the backing and user files.
> > These changes preserve the existing SELinux approach of allowing access
> > on overlayfs files if the current task has the necessary rights to the
> > user file and the mounting process has the necessary rights to the
> > underlying backing file.
> >
> > --
> > Amir Goldstein (1):
> > backing_file: store user_path_file
> >
> > Paul Moore (2):
> > lsm: add the security_mmap_backing_file() hook
> > selinux: fix overlayfs mmap() and mprotect() access checks
> >
> > fs/backing-file.c | 28 +++++---
> > fs/erofs/ishare.c | 12 ++-
> > fs/file_table.c | 53 +++++++++++++---
> > fs/fuse/passthrough.c | 3
> > fs/internal.h | 5 -
> > fs/overlayfs/dir.c | 3
> > fs/overlayfs/file.c | 1
> > include/linux/backing-file.h | 29 ++++++++-
> > include/linux/file_ref.h | 10 ---
> > include/linux/lsm_audit.h | 2
> > include/linux/lsm_hook_defs.h | 2
> > include/linux/security.h | 10 +++
> > security/security.c | 25 +++++++
> > security/selinux/hooks.c | 108 ++++++++++++++++++++++++++++------
> > 14 files changed, 231 insertions(+), 60 deletions(-)
>
> Due to the nature of the issue, I'm going to merge this into
> lsm/stable-7.0 in a few moments so the changes can get some testing in
> linux-next with the idea of sending this up to Linus' later in the
> week. If anyone has any concerns over this patchset, please let me
> know as soon as possible.
>
Since previous 4 revisions were not posted to public list,
let me repeat my concern from v4:
On Fri, Mar 6, 2026 at 5:24 PM Paul Moore <paul at paul-moore.com> wrote:
>
> On Fri, Mar 6, 2026 at 3:24 AM Amir Goldstein <amir73il at gmail.com> wrote:
...
> > My expectation is that the merge of this patch will be collaborated
> > with Christian ...
>
> Of course, that is one reason he is on the To/CC line. More on this
> in my reply to your 0/4 comments.
>
I am sorry Paul. This must be a misunderstanding.
My expectation for collaborating the merge of my patch with
Christian was that an agreement would be reached regarding
which way it would be routed to Linus.
CC to Christian and sending the patch to Linus without getting any
ACK from Christian was not the way I expected this to go.
> > and that it will NOT be auto selected or rushed into stable.
>
> I haven't marked it with a 'Fixes:' tag or a stable Cc which in my
> experience are the two quickest ways to get pulled into a stable tree.
> I'm not sure what stable policy Al or Christian have for the VFS tree,
> but LSM and SELinux commits are not pulled into the stable trees
> unless explicitly marked with a stable Cc or requested by a dev after
> the fact.
>
> > I don't mind if you want to route the security_mmap_backing_file() hooks to
> > stable to use it for some simpler bandaid for stable, but rushing this
> > one to stable is not a good idea IMO.
>
> Once again, see my (upcoming) reply to your 0/4 comments.
>
TBH, I don't understand the logic of placing patches in lsm/stable-7.0
without the intent of backporting them to stable.
I perceive my patch as a risky patch for overlayfs and the vfs
this is why I wanted Christian do be part of the decision if and when
my patch is sent to Linus.
Thanks,
Amir.
More information about the Linux-erofs
mailing list