mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: Bradley Morgan <brads@mainlining.org>
Cc: Darren Hart <dvhart@infradead.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH 2/3] futex: reject the unused PR_FUTEX_HASH arguments
Date: Mon, 9 Nov 2026 18:32:43 -0300	[thread overview]
Message-ID: <c9077b39-b7d9-45c7-968a-6bd1b3ab5572@igalia.com> (raw)
In-Reply-To: <20261105003129.3130709-3-brads@mainlining.org>

Thanks for your patch!

Em 04/11/2026 21:31, Bradley Morgan escreveu:
> PR_SET_MM, PR_SET_MDWE and the shadow stack cases all check that the
> args they do not use are zero before doing anything.  PR_FUTEX_HASH is
> the one that does not.  arg5 never even reaches futex_hash_prctl(), and
> the GET_SLOTS branch never looks at arg3 or arg4, so
> prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS, 1, 2, 3) hands back the
> slot count.
> 
> Once an arg is ignored it is burned, whatever userspace sends there
> today becomes part of the ABI and we can never use it for anything
> without breaking whoever already passes garbage.  Take arg5 too and
> reject the unused args per sub command, same as the neighbours do.
> 
> prctl() is variadic, so the two callers under tools/ leave those args as
> whatever the register holds, they only work today because nothing was
> checked.  The preceding patch in this series writes the zeros out first,
> so this does not break them.
> 
> Fixes: 80367ad01d93 ("futex: Add basic infrastructure for local task local hash")
> Signed-off-by: Bradley Morgan <brads@mainlining.org>

[...]

>   {
>   	unsigned int flags = FH_CUSTOM;
>   	int ret;
>   
>   	switch (arg2) {
>   	case PR_FUTEX_HASH_SET_SLOTS:
> -		if (arg4)
> +		if (arg4 || arg5)
>   			return -EINVAL;
>   		ret = futex_hash_allocate(arg3, flags);
>   		break;
>   
>   	case PR_FUTEX_HASH_GET_SLOTS:
> +		if (arg3 || arg4 || arg5)
> +			return -EINVAL;
>   		ret = futex_hash_get_slots();
>   		break;
>   
> diff --git a/kernel/sys.c b/kernel/sys.c
> index 755bfa5ccd92c..c4839c986f5e0 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -2885,7 +2885,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
>   		error = posixtimer_create_prctl(arg2);
>   		break;
>   	case PR_FUTEX_HASH:
> -		error = futex_hash_prctl(arg2, arg3, arg4);
> +		error = futex_hash_prctl(arg2, arg3, arg4, arg5);
>   		break;

By reading kernel/sys.c, it seems like most of PR_ options check for 
(arg4 || arg5) here, not inside of the function. Any reason why you 
didn't follow the current pattern?

>   	case PR_RSEQ_SLICE_EXTENSION:
>   		if (arg4 || arg5)


  reply	other threads:[~2026-11-09 21:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  0:31 [PATCH 0/3] two small fixes out of kernel/sys.c Bradley Morgan
2026-11-05  0:31 ` [PATCH 1/3] tools: pass the unused prctl() args explicitly for PR_FUTEX_HASH Bradley Morgan
2026-11-05  0:31 ` [PATCH 2/3] futex: reject the unused PR_FUTEX_HASH arguments Bradley Morgan
2026-11-09 21:32   ` André Almeida [this message]
2026-11-30 21:59     ` Thomas Gleixner
2026-11-05  0:31 ` [PATCH 3/3] compat: make compat_sysinfo() scale far enough to actually fit Bradley Morgan
2026-11-05  7:25   ` Arnd Bergmann
2026-11-05 16:47     ` Bradley Morgan
2026-11-05 16:52       ` Arnd Bergmann

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=c9077b39-b7d9-45c7-968a-6bd1b3ab5572@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=brads@mainlining.org \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    /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®