linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Siddh Raman Pant <code@siddh.me>
Cc: syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.com,
	linux-kernel-mentees
	<linux-kernel-mentees@lists.linuxfoundation.org>,
	linux-security-modules <linux-security-module@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	David Howells <dhowells@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Subject: Re: [PATCH] kernel/watch_queue: Make pipe NULL while clearing watch_queue
Date: Sat, 23 Jul 2022 16:04:17 +0200	[thread overview]
Message-ID: <Ytv/4Tljvlt0PJ2r@kroah.com> (raw)
In-Reply-To: <20220723135447.199557-1-code@siddh.me>

On Sat, Jul 23, 2022 at 07:24:47PM +0530, Siddh Raman Pant via Linux-kernel-mentees wrote:
> If not done, a reference to a freed pipe remains in the watch_queue,
> as this function is called before freeing a pipe in free_pipe_info()
> (see line 834 of fs/pipe.c).
> 
> This causes a UAF when post_one_notification tries to access the pipe on
> a key update, which is reported by syzbot.
> 
> Bug report: https://syzkaller.appspot.com/bug?id=1870dd7791ba05f2ea7f47f7cbdde701173973fc
> Reported-and-tested-by: syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.com
> 
> Signed-off-by: Siddh Raman Pant <code@siddh.me>
> ---
>  kernel/watch_queue.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
> index bb9962b33f95..bab9e09c74cf 100644
> --- a/kernel/watch_queue.c
> +++ b/kernel/watch_queue.c
> @@ -637,8 +637,17 @@ void watch_queue_clear(struct watch_queue *wqueue)
>  		spin_lock_bh(&wqueue->lock);
>  	}
>  
> -	spin_unlock_bh(&wqueue->lock);
>  	rcu_read_unlock();

Also you now have a spinlock held when calling rcu_read_unlock(), are
you sure that's ok?

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  parent reply	other threads:[~2022-07-23 14:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23 13:54 [PATCH] kernel/watch_queue: Make pipe NULL while clearing watch_queue Siddh Raman Pant via Linux-kernel-mentees
2022-07-23 14:03 ` Greg KH
2022-07-23 14:29   ` Siddh Raman Pant via Linux-kernel-mentees
2022-07-24  3:45     ` Khalid Masum
2022-07-24  4:02       ` Siddh Raman Pant via Linux-kernel-mentees
2022-07-23 14:04 ` Greg KH [this message]
2022-07-23 14:29   ` Siddh Raman Pant via Linux-kernel-mentees
2022-07-27 14:46   ` David Howells
2022-07-27 16:20     ` Siddh Raman Pant via Linux-kernel-mentees
2022-07-31 18:11       ` Dipanjan Das
2022-07-31 18:46         ` Siddh Raman Pant via Linux-kernel-mentees
2022-08-01  8:47           ` Greg KH
2022-08-01  8:53             ` Siddh Raman Pant via Linux-kernel-mentees
2022-07-27 14:15 ` David Howells
2022-07-27 14:23   ` Siddh Raman Pant via Linux-kernel-mentees
     [not found] <20220801121513.28E4B5204D1@webmail.sinamail.sina.com.cn>
2022-08-01 12:52 ` Siddh Raman Pant via Linux-kernel-mentees

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=Ytv/4Tljvlt0PJ2r@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=code@siddh.me \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.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;
as well as URLs for NNTP newsgroup(s).