From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Alejandro Colomar <alx@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-man@vger.kernel.org,
"André Almeida" <andrealmeid@igalia.com>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"Ingo Molnar" <mingo@redhat.com>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"Waiman Long" <longman@redhat.com>
Subject: Re: [PATCH v5 2/3] man/man2/prctl.2, PR_FUTEX_HASH_SET_SLOTS.2const: Document PR_FUTEX_HASH_SET_SLOTS
Date: Thu, 21 Aug 2025 16:08:51 +0200 [thread overview]
Message-ID: <20250821140851.z1FYafVm@linutronix.de> (raw)
In-Reply-To: <v5luee7avc6ayyox7hn4lwb6wfvezv52by7noffwejvksypord@kx26fel62kan>
On 2025-08-19 13:19:15 [+0200], Alejandro Colomar wrote:
> Hi Sebastian,
Hi Alejandro,
> > > +.B int prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS,
> > > +.BI " unsigned long " hash_size ", unsigned long " hash_flags ");
>
> I see that it is implemented in the kernel as
>
> static int
> futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
> {
> ...
> }
>
> But PR_FUTEX_HASH is implemented as
>
> int
> futex_hash_prctl(unsigned long arg2, unsigned long arg3,
> unsigned long arg4)
> {
> ...
> }
>
> Should we document is as a u_int, or a u_long? Is that mismatch a bug,
> or is it on purpose?
The prctl() interface is long so I started with that. Internally we keep
it as an int since we don't need it that big and it avoids a hole
otherwise (but then there is a hole towards the end of the structure).
Realistically speaking 1 << 31 is the largest value that can be
specified (atm) and it will very likely lead to ENOMEM. If the user
tries the next higher value, 1 << 32, then the upper bits will be
truncated and the global hash will be requested and this will succeed.
The bug could be based on the argument type 1 << 32 will succeed but
it should not. Using 1 << 25 will request ~2GiB of memory and is a bit
far from sane.
I am bit forth and back between forcing an error for anything > 1 << 30,
or updating the docs to int. But this will be the easiest ;)
Any recommendations based on similar cases?
> Cheers,
> Alex
Sebastian
next prev parent reply other threads:[~2025-08-21 14:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 7:17 [PATCH v5 0/3] Add documentation for PR_FUTEX_HASH Sebastian Andrzej Siewior
2025-08-19 7:17 ` [PATCH v5 1/3] man/man2const/PR_FUTEX_HASH.2const: Update as of Linux v6.17-rc2 Sebastian Andrzej Siewior
2025-08-19 11:03 ` Alejandro Colomar
2025-08-19 7:17 ` [PATCH v5 2/3] man/man2/prctl.2, PR_FUTEX_HASH_SET_SLOTS.2const: Document PR_FUTEX_HASH_SET_SLOTS Sebastian Andrzej Siewior
2025-08-19 11:02 ` Alejandro Colomar
2025-08-19 11:19 ` Alejandro Colomar
2025-08-21 14:08 ` Sebastian Andrzej Siewior [this message]
2025-08-21 19:14 ` Alejandro Colomar
2025-08-22 14:32 ` [PATCH v6] " Sebastian Andrzej Siewior
2025-08-19 7:17 ` [PATCH v5 3/3] man/man2/prctl.2, PR_FUTEX_HASH_GET_SLOTS.2const: Document PR_FUTEX_HASH_GET_SLOTS Sebastian Andrzej Siewior
2025-08-19 11:07 ` Alejandro Colomar
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=20250821140851.z1FYafVm@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=alx@kernel.org \
--cc=andrealmeid@igalia.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vschneid@redhat.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®