[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260203232634.GJ3183987@ZenIV>
Date: Tue, 3 Feb 2026 23:26:34 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Waiman Long <llong@...hat.com>
Cc: Paul Moore <paul@...l-moore.com>, Eric Paris <eparis@...hat.com>,
Christian Brauner <brauner@...nel.org>,
linux-kernel@...r.kernel.org, audit@...r.kernel.org,
Richard Guy Briggs <rgb@...hat.com>,
Ricardo Robaina <rrobaina@...hat.com>
Subject: Re: [PATCH v2] audit: Avoid excessive dput/dget in audit_context
setup and reset paths
On Tue, Feb 03, 2026 at 09:50:02PM +0000, Al Viro wrote:
> On Tue, Feb 03, 2026 at 03:32:04PM -0500, Waiman Long wrote:
>
> > That is actually a concern that I have at the back of my mind. I can modify
> > the patch to cache only the dentry and do get/put the mount every time which
> > is much cheaper as it is a percpu counter. In that way, a chdir(2) followed
> > by a umount(2) shouldn't cause a -EBUSY. Right?
>
> Quite - it will just retain a reference to dentry, with filesystem shutdown
> being very unhappy about somebody retaining references to objects on the
> filesystem about to be taken out...
Sarcasm aside, I wonder if we could do the following trick:
* a new primitive for "grab or borrow pwd", similar to what fdget()
does for struct file. If current->fs is shared, do what we do now and return
true; otherwise just copy the contents of current->fs->pwd return false.
* paired primitive that would take a boolean + struct path * and
do path_put() if boolean is true.
* syscalls that might alter ->fs, ->fs->pwd or add extra references to
->fs would start with grabbing an extra ref on entry and drop it in the end;
that would make that primitive safe to use there.
* audit using that thing and storing the result along with the copy
of pwd; on the way out it would use the "put unless borrowed" primitive.
Might or might not be useful - hard to tell without knowing the job mix of those
audit-afflicted production systems.
I'll try to put something along those lines together...
Powered by blists - more mailing lists