From: Manfred Spraul <manfred@colorfullife.com>
To: Varad Gautam <varad.gautam@suse.com>, linux-kernel@vger.kernel.org
Cc: Matthias von Faber <matthias.vonfaber@aox-tech.de>,
Christian Brauner <christian.brauner@ubuntu.com>,
Oleg Nesterov <oleg@redhat.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Andrew Morton <akpm@linux-foundation.org>,
Davidlohr Bueso <dbueso@suse.de>,
James Morris <jamorris@linux.microsoft.com>,
Serge Hallyn <serge@hallyn.com>,
Jules Irenge <jbi.octave@gmail.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [PATCH v4] ipc/mqueue, msg, sem: Avoid relying on a stack reference past its expiry
Date: Wed, 12 May 2021 20:55:14 +0200 [thread overview]
Message-ID: <d1360f03-40ef-7930-e8af-9a3c77fdb5de@colorfullife.com> (raw)
In-Reply-To: <20210510102950.12551-1-varad.gautam@suse.com>
Hi Varad,
On 5/10/21 12:29 PM, Varad Gautam wrote:
> do_mq_timedreceive calls wq_sleep with a stack local address. The
> sender (do_mq_timedsend) uses this address to later call
> pipelined_send.
>
> This leads to a very hard to trigger race where a do_mq_timedreceive call
> might return and leave do_mq_timedsend to rely on an invalid address,
> causing the following crash:
[...]
> Fixes: c5b2cbdbdac563 ("ipc/mqueue.c: update/document memory barriers")
> Fixes: 8116b54e7e23ef ("ipc/sem.c: document and update memory barriers")
> Fixes: 0d97a82ba830d8 ("ipc/msg.c: update and document memory barriers")
> Signed-off-by: Varad Gautam <varad.gautam@suse.com>
> Reported-by: Matthias von Faber <matthias.vonfaber@aox-tech.de>
> Cc: Christian Brauner <christian.brauner@ubuntu.com>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: Manfred Spraul <manfred@colorfullife.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Davidlohr Bueso <dbueso@suse.de>
> Cc: Manfred Spraul <manfred@colorfullife.com>
> ---
> v2: Call wake_q_add before smp_store_release, instead of using a
> get_task_struct/wake_q_add_safe combination across
> smp_store_release. (Davidlohr Bueso)
> v3: Comment/commit message fixup.
> v4: - v2 / v3 have potential for introducing lost wakeups. Return to v1
> as the path-of-least-surprises to fix the race at hand.
> - Also fix ipc/msg.c and ipc/sem.c which have the same usage
> pattern.(Manfred Spraul)
>
Acked-by: Manfred Spraul <manfred@colorfullife.com>
I would recommend that you add cc:stable. The patch is obvious, and it
is a bugfix.
>
> diff --git a/ipc/sem.c b/ipc/sem.c
> index f6c30a85dadf..7d9c06b0ad6e 100644
> --- a/ipc/sem.c
> +++ b/ipc/sem.c
> @@ -784,12 +784,14 @@ static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q)
> static inline void wake_up_sem_queue_prepare(struct sem_queue *q, int error,
> struct wake_q_head *wake_q)
> {
> - get_task_struct(q->sleeper);
> + struct task_struct *sleeper;
> +
> + sleeper = get_task_struct(q->sleeper);
>
> /* see SEM_BARRIER_2 for purpuse/pairing */
This collides with a spelling correction.
s/purpuse/purpose/ required.
--
Manfred
prev parent reply other threads:[~2021-05-12 20:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 10:29 Varad Gautam
2021-05-12 18:55 ` Manfred Spraul [this message]
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=d1360f03-40ef-7930-e8af-9a3c77fdb5de@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=christian.brauner@ubuntu.com \
--cc=dbueso@suse.de \
--cc=ebiederm@xmission.com \
--cc=gustavoars@kernel.org \
--cc=jamorris@linux.microsoft.com \
--cc=jbi.octave@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthias.vonfaber@aox-tech.de \
--cc=oleg@redhat.com \
--cc=serge@hallyn.com \
--cc=varad.gautam@suse.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
all inboxes | Powered by JetHome®