From: Ian Kent <raven@themaw.net>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>
Cc: autofs@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+c6d286fd51860df64d9a@syzkaller.appspotmail.com
Subject: Re: [PATCH] autofs: serialize allocation of global wait queue tokens
Date: Wed, 11 Nov 2026 12:33:05 +0800 [thread overview]
Message-ID: <5a3c91335fad00a6fa9d0667d6377a4da482533f.camel@themaw.net> (raw)
In-Reply-To: <20261111034050.12573-1-zhujun2@cmss.chinamobile.com>
On Wed, 2026-11-11 at 11:40 +0800, Zhu Jun wrote:
> autofs_next_wait_queue is shared by all autofs superblocks, while
> sbi->wq_mutex only serializes requests on one superblock. Concurrent
> requests on different mounts can therefore lose updates to the global
> counter. A delayed update can also move it backwards, allowing an
> outstanding token to be reused on a mount.
>
> Protect token allocation with a global spinlock. Keep the existing
> token
> type and the wraparound rule that reserves zero.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Yeah, good catch ...
Acked-by: Ian Kent <raven@themaw.net>
> ---
> fs/autofs/waitq.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/autofs/waitq.c b/fs/autofs/waitq.c
> index 92c0bbbf452b..22bc59c2f63e 100644
> --- a/fs/autofs/waitq.c
> +++ b/fs/autofs/waitq.c
> @@ -5,12 +5,14 @@
> */
>
> #include <linux/sched/signal.h>
> +#include <linux/spinlock.h>
> #include "autofs_i.h"
>
> /* We make this a static variable rather than a part of the
> superblock; it
> * is better if we don't reassign numbers easily even across
> filesystems
> */
> static autofs_wqt_t autofs_next_wait_queue = 1;
> +static DEFINE_SPINLOCK(autofs_wait_queue_lock);
>
> static void autofs_catatonic_mode_locked(struct autofs_sb_info *sbi)
> {
> @@ -396,9 +398,11 @@ int autofs_wait(struct autofs_sb_info *sbi,
> return -ENOMEM;
> }
>
> + spin_lock(&autofs_wait_queue_lock);
> wq->wait_queue_token = autofs_next_wait_queue;
> if (++autofs_next_wait_queue == 0)
> autofs_next_wait_queue = 1;
> + spin_unlock(&autofs_wait_queue_lock);
> wq->next = sbi->queues;
> sbi->queues = wq;
> init_waitqueue_head(&wq->queue);
next prev parent reply other threads:[~2026-11-11 4:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 3:40 Zhu Jun
2026-11-11 4:33 ` Ian Kent [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-11-11 2:49 Zhu Jun
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=5a3c91335fad00a6fa9d0667d6377a4da482533f.camel@themaw.net \
--to=raven@themaw.net \
--cc=autofs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+c6d286fd51860df64d9a@syzkaller.appspotmail.com \
--cc=zhujun2@cmss.chinamobile.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®