Re: [PATCH 2/3] futex: reject the unused PR_FUTEX_HASH arguments
From: Thomas Gleixner
Date: Mon Nov 30 2026 - 16:59:44 EST
On Mon, Nov 09 2026 at 18:32, André Almeida wrote:
>> 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?
Well, the two prctls have different number of used arguments.
But all of this is moot because that's a user visible change, which will
result in regressions.
So far the prctl() accepts random values for arg3/arg4/arg5 with GET and
for arg5 with SET.
Which means if there is user space handing in crap it will fail
after this hits the tree as the updates to the selftests show.
The man pages even document that the extra arguments are not required to
be cleared:
int prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS);
int prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, flags);
I agree that glibc's implementation of prctl() which reads
unconditionally all five arguments is actually undefined behavior, but
that's a different tree to bark up.
This ship has sailed when the futex hash prctl() was merged and we are
not going to apply this because a revert due to regressions is pretty
much guaranteed.
That obviously means that the unchecked arguments cannot be used to
extend the existing GET/SET subfunctions, but that's fine.
Thanks,
tglx