[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHk-=wh++R5W1ifuS6YoSb-9ExKGr7cVavo8SHiWtzyR4-hVgg@mail.gmail.com>
Date: Sun, 24 Sep 2023 10:24:40 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Alexey Dobriyan <adobriyan@...il.com>
Cc: Kees Cook <keescook@...omium.org>, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [GIT PULL] hardening fixes for v6.6-rc3
On Sun, 24 Sept 2023 at 09:58, Alexey Dobriyan <adobriyan@...il.com> wrote:
>
> Most of those in uapi/ are likely unnecessary: extern "C" means
> "don't mangle", but kernel doesn't export functions to userspace
> except vDSO so there is nothing to mangle in the first place.
I suspect a lot of it is "this got copied-and-pasted from a source
that used it".
And even if you don't export, you have to *match* the linkage in case
you have the same name.
So I suspect that if you have any kind of prototype sharing between
user space (that might use C++) and kernel space, and end up with the
same helper functions in both cases, and having some header sharing,
you end up with that pattern. And you do it just once, and then it
spreads by copy-and-paste.
And then about a third of the hits seem to be in tools, which is
literally user space and probably actually has C and C++ mixing.
Another third is the drm uapi files. I didn't even try to look at what
the cause there is. But presumably there are common names used in user
space vs kernel.
And then the last third is random.
We do have a few other uses of __cplusplus. Sometimes just "we have a
structure member name that the C++ people decided was a magic
keyword".
So it's not like this new pattern is *completely* new - we've had
random "people want to use this header with C++ compilers and that
causes random issues" before. The details are different, the cause is
similar.
Linus
Powered by blists - more mailing lists