Linux Power Management development
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Zicheng Qu <quzicheng@huawei.com>,
	 Linus Torvalds <torvalds@linux-foundation.org>,
	jlayton@kernel.org, axboe@kernel.dk, joel.granados@kernel.org,
	 tglx@linutronix.de, linux-kernel@vger.kernel.org, hch@lst.de,
	len.brown@intel.com,  pavel@ucw.cz, pengfei.xu@intel.com,
	rafael@kernel.org,  syzkaller-bugs@googlegroups.com,
	linux-pm@vger.kernel.org, tanghui20@huawei.com,
	 zhangqiao22@huawei.com, judy.chenhui@huawei.com
Subject: Re: [PATCH] acct: Prevent NULL pointer dereference when writing to sysfs
Date: Tue, 11 Feb 2025 11:17:07 +0100	[thread overview]
Message-ID: <20250211-anschaffen-leiht-9e803cc9b087@brauner> (raw)
In-Reply-To: <20250211002308.GG1977892@ZenIV>

On Tue, Feb 11, 2025 at 12:23:08AM +0000, Al Viro wrote:
> On Mon, Feb 10, 2025 at 06:19:02PM +0000, Al Viro wrote:
> > On Mon, Feb 10, 2025 at 05:02:35PM +0100, Christian Brauner wrote:
> > > On Mon, Feb 10, 2025 at 03:21:46PM +0000, Al Viro wrote:
> > > > On Mon, Feb 10, 2025 at 04:12:54PM +0100, Christian Brauner wrote:
> > > > 
> > > > > One fix would be to move exit_fs() past exit_task_work(). It looks like
> > > > > that this should be doable without much of a problem and it would fix
> > > > > the path_init() problem.
> > > > > 
> > > > > There should hopefully be nothing relying on task->fs == NULL in
> > > > > exit_task_work().
> > > > 
> > > > There's a question of the task_work_add() issued by exit_task_fs(),
> > > > though.
> > > 
> > > Can't we simply remove the pins on the mounts of fs->root and fs->pwd in
> > > exit_fs() explicitly? If that works I think that's a fair enough
> > > compromise for this shite.
> > 
> > I'd rather go for a simpler approach...  Why do we need those writes
> > to be done in context of exiting process in the first place?  It's
> > not as if they needed to go out before it terminates, so what's to
> > stop us from having a kernel thread in background and queue the data
> > to be written for it to pick up?
> > 
> > Does anybody see problems with that approach?
> 
> Note, BTW, that games with rlimit and creds switching disappear if done
> that way.  
> 
> FWIW, I wonder if we should simply allocate a page worth of buffer,
> occupied by acct_t array, with count + pointer to buffer kept in acct,
> with acct->mutex used to protect the entire thing, so that do_acct_process()
> would add a record to that sucker and wake the kthread up, with kthread
> handling actual writes and emptying the buffer.  No need for exit(2)
> to wait unless the buffer is full...

I had thought about it but both LTP and the selftests want the buffer to
be filled after the process exits.

So let's not overly complicate this. I want this to be as simple as
possible and then start deprecating this api asap.

I have a patch that just moves the final write into the workqueue. But
let's keep the cred override because who knows what security hole we
open up if we skip the override cred.

  reply	other threads:[~2025-02-11 10:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-10 14:04 [Syzkaller & bisect] There is general protection fault in path_init in v6.11-rc2 Pengfei Xu
2025-01-27  9:18 ` Zicheng Qu
2025-02-10 13:17   ` [PATCH] acct: Prevent NULL pointer dereference when writing to sysfs Zicheng Qu
2025-02-10 15:12     ` Christian Brauner
2025-02-10 15:21       ` Al Viro
2025-02-10 16:02         ` Christian Brauner
2025-02-10 18:19           ` Al Viro
2025-02-11  0:23             ` Al Viro
2025-02-11 10:17               ` Christian Brauner [this message]
2025-02-11 17:15       ` [PATCH 0/2] acct: don't allow access to internal filesystems Christian Brauner
2025-02-11 17:15         ` [PATCH 1/2] acct: perform last write from workqueue Christian Brauner
2025-02-11 17:16         ` [PATCH 2/2] acct: block access to kernel internal filesystems Christian Brauner
2025-02-11 20:30           ` Amir Goldstein
2025-02-11 20:54           ` Al Viro
2025-02-12 10:32             ` Christian Brauner
2025-02-11 18:56         ` [PATCH 0/2] acct: don't allow access to " Jeff Layton
2025-02-12 11:16           ` Christian Brauner
2025-02-13 14:56             ` Christian Brauner

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=20250211-anschaffen-leiht-9e803cc9b087@brauner \
    --to=brauner@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=jlayton@kernel.org \
    --cc=joel.granados@kernel.org \
    --cc=judy.chenhui@huawei.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=pengfei.xu@intel.com \
    --cc=quzicheng@huawei.com \
    --cc=rafael@kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tanghui20@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zhangqiao22@huawei.com \
    /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