From: Jori Koolstra <jkoolstra@xs4all.nl>
To: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Al Viro <viro@zeniv.linux.org.uk>, NeilBrown <neil@brown.name>,
Paul Moore <paul@paul-moore.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
"audit@vger.kernel.org" <audit@vger.kernel.org>
Subject: Re: [PATCH 04/12] fs/namei.c: lookup_open(): move audit_inode_child() up
Date: Mon, 15 Jun 2026 23:43:01 +0200 (CEST) [thread overview]
Message-ID: <526417482.1849950.1781559782000@kpc.webmail.kpnmail.nl> (raw)
In-Reply-To: <20260614164438.2980769-5-jkoolstra@xs4all.nl>
> Op 14-06-2026 18:44 CEST schreef Jori Koolstra <jkoolstra@xs4all.nl>:
>
>
> In the mknod(2) path of calling vfs_create() we call audit_inode_child()
> before permission checks in may_create_dentry() (but after path-based
> LSM check). Copy this behaviour to lookup_open() and move
> audit_inode_child() to may_o_create().
>
> Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
> ---
> fs/namei.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 6bf1ded26377..a4a8cdbb48e2 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -4345,6 +4345,8 @@ static int may_o_create(struct mnt_idmap *idmap,
> if (error)
> return error;
>
> + audit_inode_child(dir->dentry->d_inode, dentry, AUDIT_TYPE_CHILD_CREATE);
> +
> if (!fsuidgid_has_mapping(dir->dentry->d_sb, idmap))
> return -EOVERFLOW;
>
> @@ -4532,7 +4534,6 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
> goto out_dput;
>
> file->f_mode |= FMODE_CREATED;
> - audit_inode_child(dir_inode, dentry, AUDIT_TYPE_CHILD_CREATE);
> if (!dir_inode->i_op->create) {
> error = -EACCES;
> goto out_dput;
> --
> 2.54.0
CC, audit@vger.kernel.org
Went too quick with this one... audit_inode_child() probably shouldn't be called
if we are in the lookup case. So there isn't really a way to do this exactly
symmetrical to the vfs_create()/vfs_mkdir() paths.
But certainly the current implementation is also wrong. In the atomic_open case
audit_inode_child() is called only once (in the final fsnotify call in
open_last_lookups()), but in the regular ->create case audit_inode_child() is
called twice.
What behavior is actually wanted here?
next prev parent reply other threads:[~2026-06-15 21:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-14 16:44 [PATCH 00/12] vfs: add O_CREAT|O_DIRECTORY to open*(2) Jori Koolstra
2026-06-14 16:44 ` [PATCH 01/12] fs/namei.c: use trailing_slashes() Jori Koolstra
2026-06-15 9:26 ` David Laight
2026-06-14 16:44 ` [PATCH 02/12] fs/namei.c: move create error && negative dentry case in lookup_open up Jori Koolstra
2026-06-15 9:37 ` David Laight
2026-06-14 16:44 ` [PATCH 03/12] vfs: prepare vfs_creat|mkdir_no_perm for reuse in lookup_open() Jori Koolstra
2026-06-14 16:44 ` [PATCH 04/12] fs/namei.c: lookup_open(): move audit_inode_child() up Jori Koolstra
2026-06-15 21:43 ` Jori Koolstra [this message]
2026-06-17 2:32 ` Paul Moore
2026-06-17 8:55 ` Jori Koolstra
2026-06-14 16:44 ` [PATCH 05/12] vfs: lookup_open(): move setting FMODE_CREATED up when calling create() Jori Koolstra
2026-06-14 16:44 ` [PATCH 06/12] vfs: lookup_open(): move i_op->create check to before try_break_deleg() Jori Koolstra
2026-06-14 16:44 ` [PATCH 07/12] vfs: lookup_open(): use vfs_create_no_perm() Jori Koolstra
2026-06-14 16:44 ` [PATCH 08/12] vfs: add O_CREAT|O_DIRECTORY to open*(2) Jori Koolstra
2026-06-14 16:44 ` [PATCH 09/12] vfs: move O_IS_MKDIR check out atomic_open() to individual filesystems Jori Koolstra
2026-06-14 16:44 ` [PATCH 10/12] vfs: refuse O_CREAT for directories through a dangling symlink Jori Koolstra
2026-06-14 16:44 ` [PATCH 11/12] vfs: short-circuit MAY_WRITE access for O_DIRECTORY opens Jori Koolstra
2026-06-14 17:01 ` Jori Koolstra
2026-06-15 12:56 ` Jori Koolstra
2026-06-14 16:44 ` [PATCH 12/12] selftest: add tests for open*(O_CREAT|O_DIRECTORY) Jori Koolstra
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=526417482.1849950.1781559782000@kpc.webmail.kpnmail.nl \
--to=jkoolstra@xs4all.nl \
--cc=audit@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil@brown.name \
--cc=paul@paul-moore.com \
--cc=viro@zeniv.linux.org.uk \
/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 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®