* Re: [PATCH v2] exec: make printable macro more concise
2024-11-16 16:49 ` Linus Torvalds
@ 2024-11-16 17:23 ` Nir Lichtman
2024-11-16 22:06 ` Al Viro
2024-11-16 21:48 ` Al Viro
2024-11-18 11:46 ` Rasmus Villemoes
2 siblings, 1 reply; 9+ messages in thread
From: Nir Lichtman @ 2024-11-16 17:23 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Al Viro, ebiederm, kees, brauner, jack, linux-kernel
On Sat, Nov 16, 2024 at 08:49:39AM -0800, Linus Torvalds wrote:
> On Fri, 15 Nov 2024 at 23:28, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > Now, whether that logics makes sense is a separate story;
> > that's before my time (1.3.60), so...
>
[...]
>
> Anyway, the fs/exec.c "printable()" code most definitely shouldn't use
> the ctype stuff. I'm not sure it should exist at all, and if it should
> exist it probably should be renamed. Because it has *nothing* to do
> with "isprint()".
>
[...]
>
> Anyway, a.out support is dead, so I think this code is pure historical
> leftovers and should be removed.
>
> Linus
Thanks for answering Al and Linus.
Al, continuing forward, to work on a new version of the patch removing the
support for dynamically loading binfmt kernel modules or you'll take it
from here?
Thanks,
Nir
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] exec: make printable macro more concise
2024-11-16 17:23 ` Nir Lichtman
@ 2024-11-16 22:06 ` Al Viro
2024-11-16 22:38 ` Nir Lichtman
0 siblings, 1 reply; 9+ messages in thread
From: Al Viro @ 2024-11-16 22:06 UTC (permalink / raw)
To: Nir Lichtman; +Cc: Linus Torvalds, ebiederm, kees, brauner, jack, linux-kernel
On Sat, Nov 16, 2024 at 05:23:01PM +0000, Nir Lichtman wrote:
> On Sat, Nov 16, 2024 at 08:49:39AM -0800, Linus Torvalds wrote:
> > On Fri, 15 Nov 2024 at 23:28, Al Viro <viro@zeniv.linux.org.uk> wrote:
> > >
> > > Now, whether that logics makes sense is a separate story;
> > > that's before my time (1.3.60), so...
> >
> [...]
> >
> > Anyway, the fs/exec.c "printable()" code most definitely shouldn't use
> > the ctype stuff. I'm not sure it should exist at all, and if it should
> > exist it probably should be renamed. Because it has *nothing* to do
> > with "isprint()".
> >
> [...]
> >
> > Anyway, a.out support is dead, so I think this code is pure historical
> > leftovers and should be removed.
> >
> > Linus
>
> Thanks for answering Al and Linus.
> Al, continuing forward, to work on a new version of the patch removing the
> support for dynamically loading binfmt kernel modules or you'll take it
> from here?
Just kill it off, since you are poking in the area anyway... No point
coordinating patches, etc. - removal is completely straightforward,
with something along the lines of "that was an ancient leftover from
a.out-to-ELF transition, left without a single valid use after removal
of a.out support; anyone who might find future uses for it (currently
there's none) would be better off using binfmt_misc to trigger whatever
module loading they might need - would be more flexible that way"
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] exec: make printable macro more concise
2024-11-16 22:06 ` Al Viro
@ 2024-11-16 22:38 ` Nir Lichtman
0 siblings, 0 replies; 9+ messages in thread
From: Nir Lichtman @ 2024-11-16 22:38 UTC (permalink / raw)
To: Al Viro; +Cc: Linus Torvalds, ebiederm, kees, brauner, jack, linux-kernel
On Sat, Nov 16, 2024 at 10:06:02PM +0000, Al Viro wrote:
> On Sat, Nov 16, 2024 at 05:23:01PM +0000, Nir Lichtman wrote:
> > On Sat, Nov 16, 2024 at 08:49:39AM -0800, Linus Torvalds wrote:
> > > On Fri, 15 Nov 2024 at 23:28, Al Viro <viro@zeniv.linux.org.uk> wrote:
> > > >
> > > Anyway, a.out support is dead, so I think this code is pure historical
> > > leftovers and should be removed.
> > >
> > > Linus
> >
> > Thanks for answering Al and Linus.
> > Al, continuing forward, to work on a new version of the patch removing the
> > support for dynamically loading binfmt kernel modules or you'll take it
> > from here?
>
> Just kill it off, since you are poking in the area anyway... No point
Roger, will send out a new patch shortly.
> coordinating patches, etc. - removal is completely straightforward,
> with something along the lines of "that was an ancient leftover from
> a.out-to-ELF transition, left without a single valid use after removal
> of a.out support; anyone who might find future uses for it (currently
> there's none) would be better off using binfmt_misc to trigger whatever
> module loading they might need - would be more flexible that way"
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] exec: make printable macro more concise
2024-11-16 16:49 ` Linus Torvalds
2024-11-16 17:23 ` Nir Lichtman
@ 2024-11-16 21:48 ` Al Viro
2024-11-18 11:46 ` Rasmus Villemoes
2 siblings, 0 replies; 9+ messages in thread
From: Al Viro @ 2024-11-16 21:48 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Nir Lichtman, ebiederm, kees, brauner, jack, linux-kernel
On Sat, Nov 16, 2024 at 08:49:39AM -0800, Linus Torvalds wrote:
> The original ctype array was US-ASCII only, and at some point in the
> random past it got changed to be based on Latin1. Maybe indeed 1.3.60
> as you say, I didn't go digging around.
Almost certainly unrelated.
0.10:
initial support of #! in do_execve()
0.99.12:
binfmt added; array, with aout as the hardwired first entry.
#! handling happens prior to looking through that array.
0.99.13:
binfmt_elf added; goes into the second slot of array if
enabled.
0.99.14g:
binfmt_coff added.
1.1.14:
formats is a linked list instead of an array now, aout is
still the hardwired first entry. Anything else
should call register_binfmt(). Nobody does, though, so
elf and coff support got broken? Lovely...
At the same point binfmt_elf.c got copied from fs/ to ibcs/,
along with fs/binfmt_coff.c (originals gone in 1.1.23)
1.1.54:
fs/binfmt_elf.c returns (ibcs copy sticks around)
elf_format is added back to the list - explicitly kludged
into initializer of aout_format if non-modular and
handled by register_binfmt() if modular.
1.1.77:
ibcs moved to arch/i386/ibcs, stuff in there still not
reachable?
1.3.5:
arch/i386/ibcs finally gone; exists out of tree, with
varying degrees of rot.
1.3.60:
binfmt autoload if no match found, setting aliases up is
up to userland (decimal aliases, at that). Check for "printable"
first 4 bytes added, apparently to filter out text files (recall
that msdosfs marked everything executable).
Aliases potentially useful for iBCS2 binaries (with out of tree
module).
1.3.61:
aout made modular, both elf and aout use register_binfmt()
both in modular and built-in cases (earlier kludge would
be hopeless, so it's gone and good riddance).
These two (aout and elf) are the only binfmt in the tree.
Aliases are theoretically useful for both, probably set up only
for aout - insmod(8) itself is ELF by that point. Again,
that's up to distros - we are decades before MODULE_ALIAS
machinery, so the kernel build is not setting those up.
1.3.60/1.3.61 look like a transition to modular a.out, on systems with
already mostly ELF userland - arranging for autoload of modular aout
and allowing it to become modular. Filter hadn't been there before
that - it appeared along with autoload, so ctype changes are irrelevant;
there hadn't been an earlier stage of that thing anyway.
1.3.71:
binfmt_script added (unconditional, nominally may be modular,
in reality always built-in). Special-casing of #! is gone.
Never going to be autoloaded (and filter would reject it
anyway).
1.3.100:
binfmt_java added. Two formats (java binary and crapplet);
the former might be subject to autoload (and I've seen
such aliases in examples of /etc/module* on the net),
the latter couldn't - text files.
2.1.23:
aliases went from binfmt-%hd to binfmt-%04x; userland either
adapts, or it hadn't needed those in the first place...
2.1.32:
binfmt_em86 added (alpha emulation of i386 ELF); aliases
are not going to be useful for that - the first 4 bytes are
identical to those for native ELF.
2.1.34:
binfmt_elf32 added (sparc64 compat ELF); same story wrt
aliases usefulness.
2.1.43pre1:
binfmt_misc added; at that point aliases have become useless -
in effect, that's a better replacement for those.
another binfmt_elf32 (itanic compat)
2.1.44pre3:
binfmt_irixelf added (irix compat); ELF binaries, so aliases
are useless.
2.1.44:
binfmt_aout32 added (sparc64 compat aout)
2.3.5:
binfmt_java gone
Past that point there's really not much happening - and by now all
traces of aout are gone, which leaves this autoload logics pretty
much useless.
I mean, all ELF binaries are indistinguishable to it, scripts are
out of consideration anyway, aliases for binfmt_misc are pretty
much insane... What does it leave? binfmt_flat? Sorry, the first
4 bytes are "bFLT", so it won't pass the filter...
All alias examples I had been able to find were for
* a.out variants
* iBCS2
* java
Oh, and binfmt-0000 aliased to /bin/true, so that trying to exec a
zero-filled file wouldn't trigger whining from the modprobe when
we hit that autoload.
IMO we should simply take it out.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] exec: make printable macro more concise
2024-11-16 16:49 ` Linus Torvalds
2024-11-16 17:23 ` Nir Lichtman
2024-11-16 21:48 ` Al Viro
@ 2024-11-18 11:46 ` Rasmus Villemoes
2024-11-18 17:07 ` Linus Torvalds
2 siblings, 1 reply; 9+ messages in thread
From: Rasmus Villemoes @ 2024-11-18 11:46 UTC (permalink / raw)
To: Linus Torvalds
Cc: Al Viro, Nir Lichtman, ebiederm, kees, brauner, jack, linux-kernel
On Sat, Nov 16 2024, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Fri, 15 Nov 2024 at 23:28, Al Viro <viro@zeniv.linux.org.uk> wrote:
>>
>> Now, whether that logics makes sense is a separate story;
>> that's before my time (1.3.60), so...
>
> Bah. The whole ctype stuff is a mess, partly because it's
> fundamentally a broken concept and depends on locale.
>
> The original ctype array was US-ASCII only, and at some point in the
> random past it got changed to be based on Latin1. Maybe indeed 1.3.60
> as you say, I didn't go digging around.
>
> And Latin1 is not only what I used to use, it's the "low range of
> unicode". So it makes *some* sense, but not a whole lot.
Yes, but the kernel's ctype is almost-but-not-quite latin1...
> It might be good to go back to US-ASCII just as a true lowest common
> denominator, because people who use the ctype macros almost certainly
> don't actually do it on unicode characters, they do it on bytes, and
> then UTF-8 will not actually DTRT with anything but US-ASCII anyway.
Exactly. But you said otherwise two years ago:
https://lore.kernel.org/lkml/3a2fa7c1-2e31-0479-761f-9c189f8ed8c3@rasmusvillemoes.dk/
Rasmus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] exec: make printable macro more concise
2024-11-18 11:46 ` Rasmus Villemoes
@ 2024-11-18 17:07 ` Linus Torvalds
0 siblings, 0 replies; 9+ messages in thread
From: Linus Torvalds @ 2024-11-18 17:07 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Al Viro, Nir Lichtman, ebiederm, kees, brauner, jack, linux-kernel
On Mon, 18 Nov 2024 at 03:45, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
>
> Exactly. But you said otherwise two years ago:
> https://lore.kernel.org/lkml/3a2fa7c1-2e31-0479-761f-9c189f8ed8c3@rasmusvillemoes.dk/
I do tend to stand by the "anybody who uses ctype deserves to get what
they asked for" thing.
But yeah, I think the time has come to admit that Latin1 isn't what we
want. And I'm looking at some of the users we _do_ have, and (ignoring
tools/ and script/) the most common ones seem to be
14 isascii
32 isalpha
46 isxdigit
56 isprint
59 isalnum
158 isspace
187 isdigit
and none of them would really care if we just limited it to ASCII
again. In fact, the isprint() ones would seem to generally be much
improved (looking at the ACPI uses).
I suspect we could make them be range-based instead of based on that
table lookup while at it.
So if somebody sends me a tested patch...
Linus
^ permalink raw reply [flat|nested] 9+ messages in thread