From: Linus Torvalds <torvalds@linux-foundation.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
Linux-MM <linux-mm@kvack.org>,
linux-xfs <linux-xfs@vger.kernel.org>,
linux-hardening@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Kees Cook <keescook@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Joe Perches <joe@perches.com>
Subject: Re: [PATCH] usercopy: use unsigned long instead of uintptr_t
Date: Thu, 16 Jun 2022 09:56:21 -0700 [thread overview]
Message-ID: <CAHk-=wj_K2MnhC6N_LyY6ezmQyWzqBnfobXC354HJuKdqMePzA@mail.gmail.com> (raw)
In-Reply-To: <Yqtd6hTS52mbb9+q@casper.infradead.org>
On Thu, Jun 16, 2022 at 9:44 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> I don't want to support an address space larger than word size. I can't
> imagine any CPU vendor saying "So we have these larger registers that
> you can only use for pointers and then these smaller registers that you
> can use for data". We haven't had A/D register splits since the m68k.
> Perhaps I haven't talked to enough crazy CPU people. But if anyone does
> propose something that bad, we should laugh at them.
Yeah, the thing is, right now we have 'unsigned long' as the "wordsize".
And I want to point out that that is not about "pointers" at all, it's
about pretty much everything.
It shows up in some very core places like system call interface etc,
where "long" is in very real ways the expected register size.
So the 128-bit problem is actually much larger than just "uintptr_t",
and we have that "sizeof(long)" thing absolutely everywhere.
In fact, you can see it very much in things like this:
#if BITS_PER_LONG == 64
which you'll find all over as the "is this a 64-bit architecture".
Out bitmaps and bit fields are also all about "long" - again, entirely
unrelated to pointers.
So I agree 100% that "we will have a problem with 128-bit words".
> So how do you think we should solve the 128-bit-word-size problem?
> Leave int at 32-bit, promote long to 128-bit and get the compiler to
> add __int64 to give us a 64-bit type?
That would likely be the least painful approach, but I'm not sure it's
necessarily the right one.
Maybe we might have to introduce a "word size" type.
> The only reason I like size_t is that it's good _documentation_.
> It says "This integer is a byte count of something that's in memory".
> As opposed to being a count of sectors, blocks, pages, pointers or
> turtles.
Yes.
And yes:
> extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
> unsigned int, unsigned int);
We should use a lot more explicit types for flags in particular.
Partly for documentation, partly for "we could type-check these".
And in declarations it might be good to encourage use of (helpful)
argument names, in case it really is just an offset or other integer
where a type makes no sense.
Linus
next prev parent reply other threads:[~2022-06-16 16:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 14:36 Jason A. Donenfeld
2022-06-16 14:38 ` Matthew Wilcox
2022-06-16 14:51 ` Jason A. Donenfeld
2022-06-16 15:11 ` Jason A. Donenfeld
2022-06-16 15:21 ` Matthew Wilcox
2022-06-16 15:59 ` Linus Torvalds
2022-06-16 16:12 ` Linus Torvalds
2022-06-16 16:44 ` Matthew Wilcox
2022-06-16 16:56 ` Linus Torvalds [this message]
2022-06-16 19:14 ` Linus Torvalds
2022-06-16 19:18 ` Linus Torvalds
2022-06-17 9:19 ` David Laight
2022-06-17 7:58 ` Geert Uytterhoeven
2022-06-17 11:05 ` Christophe Leroy
2022-06-17 12:51 ` David Laight
2022-06-16 16:29 ` Kees Cook
2022-06-16 16:36 ` Mark Brown
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='CAHk-=wj_K2MnhC6N_LyY6ezmQyWzqBnfobXC354HJuKdqMePzA@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=Jason@zx2c4.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=urezki@gmail.com \
--cc=willy@infradead.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