-
papertigers
jbk: I use the in kernel smb for apple timemachine fwiw. Although I can't remember why I ended up using samba to share music to my sonos speaker. I think I couldn't get guest access without a password working
-
papertigers
could have been total user error though
-
jbk
yeah.. i have a nas zone on my smartos box that i use for that and it works pretty well..
-
sommerfeld
papertigers: well, older sonos can only do SMB1 - maybe that was it?
-
NCommander
o/
-
jclulow
Hey
-
jclulow
NCommander: So, I think you have to run this suite via "gmake test"
-
jclulow
There is at least one critical bug if you run it directly, which is that THIS_SH doesn't get set in the environment until after it's used the first time
-
jclulow
Some of these failures are just because they are using essentially unstable output of programs like od(1)
-
jclulow
e.g., for us: "printf '\n' | od -t a" prints "0000000 lf", but apparently GNU od prints "0000000 nl"
-
jbk
how od(d)
-
jbk
:P
-
jclulow
There are two pieces of delta that don't otherwise seem to be related to the fact that we don't have some of the less common locales: run-test and run-errors. The run-test thing seems to be a test that's supposed to fail, the "enable sh bash" line
-
jclulow
It seems like it happens wth an error message structure it was not necessarily expecting
-
jclulow
err rather I guess that's the run-errors thing
-
jclulow
I'm not sure about the run-test thing, but it's a bit odd. It seems like the test expects that "exec 6>&-" will create file descriptor 6, and it wll apparently be a pipe
-
jclulow
but ... I don't see that fd open on the process after using that syntax
-
jclulow
Some more digging there required probably
-
jclulow
NCommander: I don't see any evidence of bash crashing though, FWIW
-
jclulow
(this is OmniOS r151046ac)
-
NCommander
oh I was trying to figure out what tab this was coming from
-
NCommander
jclulow: that might be environment specific
-
NCommander
Give me a moment, I forgot I had this open in the background
-
jclulow
ok
-
sommerfeld
bash manpage: "the redirection operator
-
sommerfeld
[n]>&digit-
-
sommerfeld
moves the file descriptor digit to file descriptor n, or the standard
-
sommerfeld
output (file descriptor 1) if n is not specified.
-
sommerfeld
"
-
NCommander
I shut down the VM to export it, so I have to boot everything back up
-
sommerfeld
so it's some sort of fd juggle
-
NCommander
Ah, gmake check does work
-
NCommander
And you're right, no core file. I saw the error about the struct issue. Too used to linux just posting something like that and not coring
-
NCommander
I have a core dump of bash dying on login. I also have a few litering around.
-
jclulow
FWIW, it's the "enable" built-in using dlsym() to look into itself to find "bash_struct" (to do the "enable bash" thing) and not finding it. It is _expected_ that it doesn't find it, seemingly; I'm not sure what Linux systems do there. It's totally possible the Mac OS X equivalent doesn't use dlsym() but something else.
-
jclulow
Given they're Mach-O instead of ELF
-
jclulow
So that error pops out there because they print it, in the code in "builtins/enable.def"
-
jclulow
I think this test suite is actually in pretty good shape FWIW
-
NCommander
-
jclulow
If you run it with the GNU stuff in PATH first, it finds the GNU od and stops whinging about that stuff; e.g., PATH=/usr/gnu/bin:$PATH gmake test
-
NCommander
I legitimately forgot about that
-
jclulow
The locale stuff is probably because that locale is missing
-
NCommander
Well on Mastodon, the locale got brought up as a suspected cause
-
NCommander
I just noted they're not installed, since perl was complaining about it when I was trying to build arm64-gate
-
jclulow
Yeah I made that suggestion wrt. the segfault/core file stuff
-
NCommander
I am uploading the VHDs to Google right now, but they're 72 GiB
-
NCommander
So its taking awhile
-
jclulow
But because you're ostensibly using en_US.UTF-8 and a stock install, I am less sure it's locale related haha
-
NCommander
I've crawled around in bash's internals before
-
jclulow
It is not my favourite neighbourhood
-
NCommander
(I dunno if you've seen my YouTube channel, I had an adventure with it on AIX)
-
jclulow
I have not!
-
NCommander
the long story short: old AIX defines strtoimax, but doesn't include it in the headers. It's also buggy
-
NCommander
This does *really fun things*, cause a configure check in bash was broken and uh
-
NCommander
well needless to say I filed a few bugs on the matter :)
-
jclulow
neat
-
jclulow
bugs filed is always good haha
-
NCommander
Yeah, this is actually me following up on trying to build illumos for arm64, which is largely how I got here.
-
NCommander
The stack traceback to me tells me its dying somewhere in readline
-
NCommander
Bash has its own built in version that it uses if the system one isn't present, but I think its linked to readline
-
jclulow
presumably "ldd /usr/bin/bash" includes /usr/lib/64/libreadline.so.8 in there
-
NCommander
libreadline.so.8 => /usr/lib/64/libreadline.so.8
-
jclulow
yeah
-
NCommander
We have ourselves a winner
-
NCommander
Readline doesn't have a test suite :/
-
jclulow
If you "pargs -e <corefile>" can you gist the result
-
NCommander
Although there are some compiler warnings
-
NCommander
-
jclulow
ok
-
jclulow
LC_CTYPE=UTF-8 is probably the issue
-
NCommander
ncmdr@rosetta2:~/bash-5.2.21$ cat configure.log | grep -i nls
-
NCommander
checking whether NLS is requested... yes
-
NCommander
checking whether to use NLS... yes
-
NCommander
The crash is in readline though
-
NCommander
Hold on, let me make a new account which has bash as its shell
-
NCommander
so I can test different scenarios
-
jclulow
OK I can reproduce it
-
jclulow
with... LC_CTYPE=UTF-8 /usr/bin/bash
-
jclulow
It is somewhat unconscionable that it handles SIGSEGV haha
-
NCommander
ncmdr@rosetta2:~/bash-5.2.21$ LC_CTYPE=UTF-8 /usr/bin/bash -c 'echo HERE'
-
NCommander
UTF-8: unknown locale
-
NCommander
HERE
-
NCommander
ncmdr@rosetta2:~/bash-5.2.21$
-
NCommander
It's not crashing here
-
jclulow
you're not doing the same thing I was doing
-
jclulow
It also does not crash if I pass it a -c argument
-
jclulow
with no arguments, it attempts to start an interactive shell
-
jclulow
which is when readline comes in
-
NCommander
that also worked
-
NCommander
I tried that first
-
NCommander
Well I can't reproduce the SSH login crash now. I don't think I saved a snapshot before upgrading
-
jclulow
what do you get if you: pkg info readline | grep FMRI
-
NCommander
on bloody?
-
NCommander
er
-
NCommander
sorry
-
NCommander
ncmdr@rosetta2:~$ pkg info readline | grep FMRI
-
NCommander
FMRI: pkg://omnios/library/readline⊙8:20240402T110232Z
-
jclulow
ok and that's ... bloody or stable or?
-
NCommander
bloody
-
NCommander
ncmdr@rosetta2:~$ uname -a
-
NCommander
SunOS rosetta2 5.11 omnios-master-b797611cbb i86pc i386 i86pc
-
NCommander
ncmdr@rosetta2:~$
-
jclulow
ok tah
-
NCommander
The core file for me was generated by selecting /usr/bin/bash as the shell on the OmniOS installer
-
NCommander
I could log in ont he system console, but it dumped when I logged into SSH until I changed it to ksh93
-
jclulow
-
jclulow
this is the stack at the point of the actual SIGSEGV
-
jclulow
It has, I believe, passed NULL to strlen()
-
jclulow
from _rl_init_eightbit()
-
NCommander
I'm going through the code
-
NCommander
to see if I can figure out where it blows its brains out
-
jclulow
it is in _rl_init_locale()
-
jclulow
it is explicitly looking at LC_CTYPE haha
-
NCommander
well there's a big giant #if here that relates to a configure check
-
NCommander
(looking at readline-8.2 source code)
-
jclulow
I believe the #if is true
-
NCommander
it is
-
jclulow
because "_rl_init_locale::dis ! grep call" in the debugger lists some <PLT=libc.so.1`setlocale> calls
-
jclulow
I...
-
NCommander
Well, this is where it jumps into the C library
-
jclulow
am not sure you are allowed to pass NULL to setlocale() like that?!
-
jclulow
oh I guess maybe you are
-
NCommander
Well in the case on Linux where locales won't be installed, I think it would go down that codebranch.
-
NCommander
It could be a regression in libreadline ...
-
NCommander
-
NCommander
I'm looking at it in git
-
NCommander
This function hasn't changed in like 10 years.
-
jclulow
ok so we get "UTF-8" back from the environment lookup
-
jclulow
so we are in fact passing it straight to setlocale()
-
NCommander
This sounds like the C library is choking
-
NCommander
Wasn't NLS one of the bits that was closed source from Sun and had to be replaced?
-
jclulow
The i18n stuff
-
jclulow
was
-
NCommander
ls
-
NCommander
this is not my terminal
-
jclulow
accurate
-
NCommander
I'm trying to find where the other side of that function call goes
-
NCommander
-
jclulow
yes I am single stepping through
-
jclulow
ok so newlocale() in there returns NULL ultimately
-
jclulow
because we parsed it rubbish
-
jclulow
*passed
-
jclulow
we are back in _rl_init_locale()
-
jclulow
yeah it passes NULL to strlen() itself
-
jclulow
It's in savestring()
-
jclulow
in readline-8.2
-
jclulow
It seems to have been inlined (blah)
-
jclulow
but at the point where it calls strlen() it is about to pass the result to xmalloc()
-
jclulow
which is what their savestring() does
-
NCommander
So is the bug that readline passes in NULL or illumos's libc not being happy with that NULL? Cause this all looks like old code
-
jclulow
The bug is that in the event that a rubbish locale is passed to setlocale(), setlocale() returns NULL because, well, it failed to set the locale
-
jclulow
and then
-
jclulow
readline does the wrong thing
-
NCommander
wait
-
jclulow
by assuming it won't be NULL
-
NCommander
the manpage actually defines behavior for nullpointer
-
NCommander
A null pointer for locale causes setlocale() to return a pointer to the
-
NCommander
string associated with the category for the program's current locale.
-
jclulow
We're not passing in NULL, we're _returning_ NULL
-
NCommander
The program's locale is not changed.
-
NCommander
Oh
-
jclulow
we pass in what you set in your environment for LC_CTYPE
-
jclulow
i.e., "UTF-8"
-
jclulow
which is not a locale
-
NCommander
oh hold on
-
NCommander
I think I see what happens on Linux
-
jclulow
"LC_CTYPE=mr_stephens bash" also fails FWIW
-
NCommander
I think on Linux, this would return 'C'
-
jclulow
I suspect it depends on your C library, but that may well be true
-
jbk
at least some linux manpage suggests it could return NULL as well
-
NCommander
mcasadevall@lighthouse:~$ ./test_setlocale
-
NCommander
setlocale returned: C
-
NCommander
printf("setlocale returned: %s\n", setlocale(LC_CTYPE, NULL));
-
jclulow
It can definitely return NULL
-
jclulow
well to be clear
-
jclulow
setlocale(LC_CTYPE, "mrstephens")
-
jclulow
not NULLL
-
NCommander
macOS also returns 'C'
-
jclulow
linux actually returns NULL
-
NCommander
?
-
jclulow
if all you call is setlocale(LC_CTYPE, "mr_stephens");
-
jclulow
at least that's true on Ubuntu 22.04.3 LTS
-
jclulow
so glibc, really, rather than Linux
-
NCommander
yeah my test case was wrong, sorryh, its late here
-
jclulow
I believe Mac OS X also returns NULL there
-
jclulow
It does seem like /bin/bash on Ubuntu, at least, does _not_ link against libreadline
-
jclulow
at least not dynamically
-
jclulow
maybe the internal readline is less ruinous
-
NCommander
It's likely using the built in one, bash can be set to /bin/sh
-
NCommander
And there are some special considerations for /bin/sh and dpkg
-
jclulow
sure
-
jclulow
So I guess that's why it's not broken there haha
-
NCommander
It's also possible that no one has actually run glibc with an entirely invalid lang environment. That code is pretty much older than dirt.
-
jclulow
I can't really see how this would not segfault in the same way if you built it linked against the real libreadline -- unless of course they've patched _that_ in Ubuntu
-
NCommander
like if you don't have the environmental variables sent
-
jclulow
Do you know how LC_CTYPE is getting into your environment?
-
NCommander
it sends NULL into setlocale()
-
NCommander
As in my SSH shell or on illumos?
-
jclulow
on your illumos system yeah
-
NCommander
declare -x LANG="en_US.UTF-8"
-
NCommander
I am not sure if its getting that from ssh or not
-
NCommander
Hold on, let me check locale if I log on the system terminal
-
jclulow
we're specifically looking for, like, env | grep LC_CTYPE
-
NCommander
Its not set, but its also not crashing now ...
-
NCommander
wait
-
NCommander
hold on
-
NCommander
LC_CTYPE=UTF-8
-
jclulow
j'accuse!
-
NCommander
I was using cool-retro-term because I was making a video
-
jclulow
ah ha
-
NCommander
The standard macOS Terminal.app doesn't cause it
-
NCommander
but I wanted the fancy graphics
-
jclulow
fascinating
-
jclulow
I wonder why it does that!
-
NCommander
mcasadevall@infinityway ~ % ssh ncmdr⊙110
-
NCommander
(ncmdr⊙110) Password:
-
NCommander
Last login: Thu Apr 4 05:46:02 2024 from 192.168.2.215
-
NCommander
OmniOS r151049 omnios-master-b797611cbb April 2024
-
NCommander
You have new mail.
-
NCommander
Connection to 192.168.0.102 closed.
-
NCommander
mcasadevall@infinityway ~ %
-
NCommander
And that infact reproduces the crash
-
NCommander
I just checked for good measure and I can ssh into Linux VMs just fine
-
NCommander
so uh
-
jclulow
You should definitely fix the LC_CTYPE value that cool-retro-term is setting there, I don't believe that's ever valid
-
NCommander
I didn't even notice it was broken
-
NCommander
cause this was the first time I saw it go kaboom
-
jclulow
Well most software probably correctly handles a return of NULL from setlocale() haha
-
NCommander
except its a valid locale
-
NCommander
C.UTF_8
-
NCommander
I believe that would match through locale rules
-
jclulow
LC_CTYPE=UTF-8 locale on Ubuntu complains loudly
-
NCommander
hold on
-
NCommander
I need to figure out what's doing
-
NCommander
my locale when logging into Ubuntu over SSH is being set to C.UTF-8
-
NCommander
Instead of what its coming in on SSH
-
NCommander
so if I login over SSH with an invalid locale, it gets set to C.UTF-8
-
NCommander
If I log in with an invalid locale to OmniOS
-
NCommander
LC_CTYPE=abcdefg
-
jclulow
good lord, /etc/profile.d/01-locale-fix.sh
-
jclulow
Yeah ok so they've invented some training wheels in /usr/bin/locale-check haha
-
jclulow
if you.. LC_CTYPE=frank /usr/bin/locale-check C.UTF-8
-
jclulow
it emits LANG=C.UTF-8 LC_CTYPE=C.UTF-8
-
NCommander
Why do I feel like this bug was found a decade ago and this was the fix?
-
jclulow
I mean, it is on some level true that not having your locale set properly is bad
-
jclulow
but it is also true that it should probably _tell you_
-
jclulow
because how would you ever know that your terminal is setting it to something that is totally bogus
-
jclulow
cool-retro-term should be passing C.UTF-8 there if that's what wants
-
jclulow
or tbh not changing it at all?
-
NCommander
I'm pretty sure we are all intended to be coding on VT100's in a dark room ;)
-
jclulow
haha
-
jclulow
I do recall using Cathode.app a million years ago, before I gave up on the Mac
-
NCommander
So the question is what is the actual and proper fix?
-
NCommander
I guess patching readline to be less stupid and hope upstream takes it
-
jclulow
Yes I believe it is a readline bug
-
jclulow
TritonDataCenter/node-manta #61#issuecomment-19653740 is the only evidence I can recall of my Cathode.app use lol
-
jclulow
It's possible we could consider sanitising user locale stuff too, though that really feels like a perilous ptah
-
jclulow
*path
-
jclulow
I'm sure we'll break _other_ things doing stuff like that
-
NCommander
Well, hold on, would you? Applications should be expected not to crash if there's a valid locale, and making sure the environment has a safeguard incase of bad terminals is not necessarily a bad thing
-
jclulow
It's just a big hammer
-
NCommander
Essentially, this is more making getty (or whatever the equivelent is) basically sanity check what comes in, and screech loudly if it dislikes it.
-
jclulow
Well, getty/ssh don't care
-
jclulow
most programs correctly handle rubbish in the locale variables FWIW
-
jclulow
it's why you got all those messages about it haha
-
jclulow
It was in fact crying out in pain
-
NCommander
I got desensitized to it because debootstrapped Ubuntu doesn't install locales so Perl screaming is normal.
-
NCommander
>.>;
-
jclulow
I am surprised that this "locale-check" program doesn't warn people about it
-
NCommander
I didn't even know it existed
-
jclulow
Me neither!
-
jclulow
It of course has no manual page despite being in /usr/bin
-
NCommander
hold on, I can find who owns it
-
NCommander
mcasadevall@lighthouse:~$ dpkg-query -S /etc/profile.d/01-locale-fix.sh
-
NCommander
base-files: /etc/profile.d/01-locale-fix.sh
-
jclulow
lol, "locale-check --help" silently exits 0
-
jclulow
is "base-files" the package?
-
NCommander
-
jclulow
"I'm not a big fan of this approach but I certainly don't have any better idea myself."
-
NCommander
Well they were having postgres explode
-
NCommander
... which uses libreadline
-
NCommander
Well I found the common thread here :P
-
jclulow
lol
-
jclulow
indeed
-
NCommander
So I can actually provide some context
-
NCommander
because I worked on MaaS, albiet loosely
-
NCommander
They were basically deploying absolutely minimium images without locales for bare metal VM hosting
-
jclulow
-
NCommander
This is a deeply magical behavior
-
jclulow
it truly is
-
jclulow
That's what I mean by peril haha
-
jclulow
Like, people will set their locales like your terminal did
-
jclulow
and never know they were not getting what they asked for
-
jclulow
and stuff will just magically work except sometimes when it doesn't
-
jclulow
It really feels like this thing should emit a WARNING to stderr
-
NCommander
Arguably, OpenSSH should be sanitizing what its setting the environemnt to
-
NCommander
Because its entirely valid that you will have a locale on system A that doesn't exist on system B
-
jclulow
Well I believe SunSSH used to actually do thta
-
jclulow
*thta
-
jclulow
sigh *that
-
NCommander
And that formatting doesn't necessarily need to be the same across operating systems
-
jclulow
it would negotiate the locale
-
jclulow
but we dropped SunSSH (a fork of OpenSSH) long ago
-
jclulow
and the OpenSSH people are not into complex stuff like that
-
NCommander
yeah I'm not surprised
-
NCommander
The ubuntu-devel discussion seems to conclude that openssh is doing the wrong thing
-
jclulow
We have our OpenSSH built to AcceptEnv the LC_* LANG stuff by default, as is the broad custom
-
jclulow
and then it's just up to users to hold it properly basically
-
NCommander
The question becomes is it realistic that OpenSSH will get a locale that's valid on linux/mac/windows, but not valid on illumos, and what the correct behjavior is in that case
-
jclulow
It's unfortunately not really possible to say
-
jclulow
If you don't follow the spec, and you don't specify a locale that works on the remote system, the best anyone can really do is guess
-
jclulow
maybe C, maybe C.UTF-8 if we thought you wanted UTF-8
-
jclulow
also what if you specify a correct LANG but a bung LC_COLLATE
-
jclulow
It is ultimately a mess haha
-
NCommander
Is there an actual defined spec for locales?
-
jclulow
I feel like some of it is covered in the various standards yes
-
jclulow
between C and POSIX
-
jclulow
-
jclulow
which of course doesn't cover UTF-8 haha
-
jclulow
I think C.UTF-8 is actually probably a made up debian thing
-
jclulow
that we've mostly all subsequently adopted
-
NCommander
The category body shall consist of one or more lines of text. Each line shall contain an identifier, optionally followed by one or more operands. Identifiers shall be either keywords, identifying a particular locale element, or collating elements. In addition to the keywords defined in this volume of POSIX.1-2017, the source can contain
-
NCommander
implementation-defined keywords
-
jclulow
-
fenix
→
BUG 11661: provide C.UTF-8 locale (Closed)
-
NCommander
So there's no defined format
-
NCommander
for locale names
-
NCommander
Or well, there's nothing saying I can't make my own locale of LANG="pirate_ARGGGG", and be against spec
-
NCommander
and then ssh into a normal illumos system from my pirate speaking wonderland
-
jclulow
I think that's basically true haha
-
jclulow
But I'm not an expert in this area
-
NCommander
Neither am I
-
jclulow
At any rate, I will file an OmniOS bug describing the readline bug
-
jclulow
And we can figure out what to do next
-
NCommander
This is getting fairly close the eldritch tomes of lore that AT&T used to forge the One Ring deep in the heart of Murry Hill
-
NCommander
I guess fix the readline bug, and see if upstream accepts it, and then deciding if illumos needs to have a locale wrapper, since readline is probably one of the most deployed codebases on the planet
-
NCommander
make sure to shoot me the link to that bug, since I'll weigh in. If nothing else, making a video on describing how a bug in libreadline was found will be interesting
-
NCommander
I just had a stupid thought
-
NCommander
is there any way this can be exploited for code execution? This is a variable a user controls.
-
NCommander
I'm not sure it actually gets you anything, but crashing on bad environment data in a library as well used as readline makes me twitchy
-
NCommander
no wait, the bad data causes NULL to strlen, nothing a user writes to
-
NCommander
ugh, I need sleep
-
jclulow
-
jclulow
I filed the bug
-
jimklimov
cheers, got a question about NWAM which manages my OI VM's networking: sometimes the home DHCP server from the access point goes AWOL, and the OI VM loses networking (probably lease expires?) -- is it possible to tell it to use the last served address indefinitely until told otherwise? Or a specific fallback IP?
-
nikolam
if LAn have multiple gateways, how to tell illumos to always use first gateway (and DNS server) and then if it fails the other one(s).
-
nikolam
I see it alternating between gateways to access outside world, even if explicitly set what gateway and DNS to use. (SmartOS)
-
danmcd
Silly question... *our* ldd(1) doesn't execute the binary at all while trying to find paths, right?
-
danmcd
-
danmcd
I'm also pretty sure our strings(1) isn't as dangerous as the binutils one used to be...
-
danmcd
-
sommerfeld
our ldd most certainly exec's the binary after setting a bunch of environment variables that cause ld.so to dump its guts rather than run the program.
-
sommerfeld
our ldd does check that the ELF interpreter is in a plausible location (in /lib, /usr/lib, or /etc/lib) which reduces but doesn't eliminate the chance of mischief
-
rmustacc
strings should probably dumps privs.
-
rmustacc
s/dumps/drop
-
alanc
-
danmcd
Oh damn...
-
danmcd
Well, glad I asked?
-
gitomat
[illumos-gate] 16413 Post-barrier Return Stack Buffer (PBRSB) fixes can be detected in HW -- Dan McDonald <danmcd⊙mi>