Repository navigation
Description
systemd version the issue has been seen with
Known good versions:
- sys-apps/systemd-249.4-r4 (but not recompiled it yet)
Known bad versions:
- sys-apps/systemd-249.6-r1
- sys-apps/systemd-249.7
- sys-apps/systemd-250-r1
Used distribution
Gentoo Linux.
Linux kernel version used (uname -a)
5.15.5-gentoo
CPU architecture issue was seen on
sparc64
Expected behaviour you didn't see
Commands which end up involving NSS lookups like
ls -alsucceeding.
Unexpected behaviour you saw
SIGBUS on
ls -al,sudo su.
Steps to reproduce the problem
- Install >sys-apps/systemd-249.4 on a
sparc64machine- Have systemd configured for NSS lookups in
/etc/nsswitch.conf- Try to run
ls -alor some other command which will need to lookup entries via NSS
Additional program output to the terminal or log subsystem illustrating the issue
Originally reported downstream in Gentoo here.
$ sudo su
Bus error (core dumped)
$ ls -al
Bus error (core dumped)
Backtrace:
(gdb) bt
#0 copy_synthesized_group (dest=0xfff800010049bf90 <resbuf>, src=0xfff8000100706b08 <root_group>, buffer=0x100001382a0 "root", buflen=1024, errnop=0xfff800010002fbd8)
at ../systemd-250/src/nss-systemd/nss-systemd.c:254
#1 0xfff80001005b6730 in _nss_systemd_getgrgid_r (gid=<optimized out>, gr=0xfff800010049bf90 <resbuf>, buffer=0x100001382a0 "root", buflen=1024, errnop=0xfff800010002fbd8)
at ../systemd-250/src/nss-systemd/nss-systemd.c:498
#2 0xfff80001002f1f54 in __getgrgid_r (gid=<optimized out>, resbuf=0xfff800010049bf90 <resbuf>, buffer=0x100001382a0 "root", buflen=1024, result=0x7fefff207e0) at ../nss/getXXbyYY_r.c:274
#3 0xfff80001002f150c in getgrgid (gid=<optimized out>) at ../nss/getXXbyYY.c:135
#4 0x0000010000012d3c in getgroup (gid=<optimized out>) at lib/idcache.c:167
#5 0x000001000000dc84 in format_group_width (g=0) at src/ls.c:4183
#6 gobble_file (name=0x1000012f623 "glibc-2.30-r9.ebuild", type=<optimized out>, command_line_arg=<optimized out>, dirname=<optimized out>, inode=0) at src/ls.c:3534
#7 0x000001000000e484 in print_dir (name=0x100001276e0 ".", realname=<optimized out>, command_line_arg=<optimized out>) at src/ls.c:2989
#8 0x00000100000046e4 in main (argc=<optimized out>, argv=<optimized out>) at src/ls.c:1778
(gdb)
Note that the machine is running glibc-2.33 and the 2.30 reference in the backtrace is just because there's a bunch of glibc ebuilds (=filenames) in the directory I was in.
I don't think there was anything else related/useful in the journal.
Activity
thesamesam commentedon Dec 30, 2021
Backtrace points to us dying at
systemd/src/nss-systemd/nss-systemd.c
Line 254 in 47fd7fa
Reverting 47fd7fa from #20679 with 250 works.
/etc/nsswitch.confI'm using to trigger this:And
sed -i -e 's/systemd//' /etc/nsswitch.confis enough to make things work again with a broken version.nss-systemd: fix required buffer size calculation
yuwata commentedon Dec 30, 2021
Thank you for the report. Could you test PR #21938?
nss-systemd: fix required buffer size calculation
thesamesam commentedon Dec 30, 2021
Thanks @yuwata. Sadly,
ls -alstill ends up SIGBUSing for me. The backtrace seems the same too:Did double check that the patch is applied. Let me know if I can try anything else / give any other information too.
nss-systemd: fix pointer calculation
yuwata commentedon Dec 30, 2021
Ouch. Could you test #21944?
thesamesam commentedon Dec 30, 2021
Thanks! But not yet:
If necessary, you're free to have access to this porting machine FWIW.
yuwata commentedon Dec 30, 2021
Could you apply the following, and then run
build/test-nss-util systemd root?On my machine (x86_64), I get the following:
thesamesam commentedon Dec 30, 2021
Hm, I don't see
test-nss-utilanywhere. But I do havetest-nss-usersandtest-nss-hostsso I'll run users:I think it's good news that this breaks too:
Maybe helpful:
15 remaining items
evverx commentedon Dec 31, 2021
Looks like UBsan is happy. Thanks!
Apparently those tests aren't ready to be run yet but at least eventually they hopefully can be used to catch and prevent issues like that.
evverx commentedon Jan 2, 2022
The tests are hopefully on the way: #21778 but #21975 prevents them from being rolled out
thesamesam commentedon Jan 2, 2022
Thank you all and I appreciate the efforts to get the tests running to avoid regressions/catch future cases!
nss-myhostname: do not apply non-zero offset to null pointer
[elfutils] turn on the alignment check
[elfutils] turn on the alignment check (#7092)
nss-systemd: fix required buffer size calculation
nss-systemd: fix alignment of gr_mem
nss-myhostname: do not apply non-zero offset to null pointer
nss-myhostname: do not apply non-zero offset to null pointer
nss-systemd: fix required buffer size calculation
nss-systemd: fix alignment of gr_mem
[elfutils] turn on the alignment check (google#7092)
tests: run nss-{users|hosts} by default