Subject: sudo: [i386] invalid opcode

From: Martin-Éric Racine <[email-masked]>
Date: Thu, 03 Feb 2022 09:11:10 +0200

Package: sudo
Version: 1.9.9-1
Severity: important

On a Geode LX (i686 without PAE), the most recent sudo dumps core. dmesg shows the following:

# dmesg | grep traps
[  150.890563] traps: sudo[729] trap invalid opcode ip:44ffa0 sp:bfd59cfc error:0 in sudo[44f000+27000]
[  154.997101] traps: sudo[745] trap invalid opcode ip:461fa0 sp:bfd5a77c error:0 in sudo[461000+27000]
[  195.085329] traps: sudo[813] trap invalid opcode ip:4b6fa0 sp:bfa918ec error:0 in sudo[4b6000+27000]
[  227.145870] traps: sudo[842] trap invalid opcode ip:48ffa0 sp:bfd9978c error:0 in sudo[48f000+27000]
[  419.727558] traps: sudo[1640] trap invalid opcode ip:412fa0 sp:bff2567c error:0 in sudo[412000+27000]
[  421.724746] traps: sudo[1644] trap invalid opcode ip:49cfa0 sp:bfa5adac error:0 in sudo[49c000+27000]

# coredumpctl debug 1644
           PID: 1644 (sudo)
           UID: 1000 (perkelix)
           GID: 1000 (perkelix)
        Signal: 4 (ILL)
     Timestamp: Thu 2022-02-03 09:01:49 EET (4min 26s ago)
  Command Line: sudo journalctl --vacuum-time=1d
    Executable: /usr/bin/sudo
 Control Group: /user.slice/user-1000.slice/session-1.scope
          Unit: session-1.scope
         Slice: user-1000.slice
       Session: 1
     Owner UID: 1000 (perkelix)
       Boot ID: a9bc307137484b5ea8737cdcfb628610
    Machine ID: 1063a9d1fb9df6e371ea9f94491345ed
      Hostname: geode
       Storage: /var/lib/systemd/coredump/core.sudo.1000.a9bc307137484b5ea8737cdcfb628610.1644.1643871709000000.zst (present)
     Disk Size: 33.6K
       Message: Process 1644 (sudo) of user 1000 dumped core.
                
                Module linux-gate.so.1 with build-id 598c8083710539a0d5fb3baab6246b053a769e43
                Module libpthread.so.0 with build-id e86be904a5d7f0b52cb0a3a729049909a548e3e9
                Module ld-linux.so.2 with build-id bba92aa07f95103e1f37c78065e5a29bf3772ad4
                Module libdl.so.2 with build-id 3d4e397859cdd91bfbaa59627813192469087b5e
                Module libpcre2-8.so.0 with build-id a4df58fa222acba18708316d4a6b451ad7b173db
                Module libcap-ng.so.0 with build-id aa6038a53112df6f372332a19d44df3f0226cf3e
                Module libc.so.6 with build-id 0664ee9761108af17a12afc957834a09b9efa606
                Module libsudo_util.so.0 with build-id 9365ea68f3d56343b5f0ec16a88c8f3bae8ae8a5
                Module libutil.so.1 with build-id a4b03373737eb0b3b68d111d33b652def5d48304
                Module libselinux.so.1 with build-id a3e4158f4327b4f6836562f4f9808260e2b626f8
                Module libaudit.so.1 with build-id 5a935b323c041a7ebbb4f03d7a3ef06be7888913
                Module sudo with build-id a564233ee048049a8da1f14f4bf78238e1cdaadd
                Stack trace of thread 1644:
                #0  0x000000000049cfa0 n/a (sudo + 0x4fa0)
                #1  0x00000000b7d2f905 __libc_start_main (libc.so.6 + 0x1e905)
                #2  0x000000000049f791 n/a (sudo + 0x7791)
                ELF object binary architecture: Intel 80386

GNU gdb (Debian 10.1-2) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/sudo...
(No debugging symbols found in /usr/bin/sudo)
[New LWP 1644]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
Core was generated by `sudo journalctl --vacuum-time=1d'.
Program terminated with signal SIGILL, Illegal instruction.
#0  0x0049cfa0 in ?? ()
(gdb) bt full
#0  0x0049cfa0 in ?? ()
No symbol table info available.
#1  0xb7d2f905 in __libc_start_main (main=0x49cfa0, argc=3, argv=0xbfa5ae54, init=0x4c2e50, fini=0x4c2eb0, rtld_fini=0xb7fb9480 <_dl_fini>, stack_end=0xbfa5ae4c)
    at ../csu/libc-start.c:332
        self = <optimized out>
        result = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, 3, 4847456, 0, -1612358959, 1901020865}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0xb7fda000}, data = {prev = 0x0, 
              cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#2  0x0049f791 in ?? ()
No symbol table info available.
(gdb) quit

- -- System Information:
Debian Release: bookworm/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'stable-security'), (500, 'testing')
Architecture: i386 (i586)

Kernel: Linux 5.15.0-3-686 (SMP w/1 CPU thread)
Kernel taint flags: TAINT_CPU_OUT_OF_SPEC
Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8), LANGUAGE=fi:en
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages sudo depends on:
ii  init-system-helpers  1.61
ii  libaudit1            1:3.0.6-1+b1
ii  libc6                2.33-5
ii  libpam-modules       1.4.0-11
ii  libpam0g             1.4.0-11
ii  libselinux1          3.3-1+b1
ii  lsb-base             11.1.0
ii  zlib1g               1:1.2.11.dfsg-2

sudo recommends no packages.

sudo suggests no packages.

- -- Configuration Files:
/etc/sudoers [Errno 13] Lupa evätty: '/etc/sudoers'
/etc/sudoers.d/README [Errno 13] Lupa evätty: '/etc/sudoers.d/README'

- -- no debconf information

---

From: Marc Haber <[email-masked]>
Date: Thu, 3 Feb 2022 08:41:35 +0100

> On a Geode LX (i686 without PAE), the most recent sudo dumps core. dmesg shows the following:

Just for the record, the current i386 sudo was built on x86-ubc-02, Logs
https://buildd.debian.org/status/logs.php?pkg=sudo&ver=1.9.9-1&arch=i386

I guess this might be a toolchain or autobuilder issue.

Greetings
Marc

-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany    |  lose things."    Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421

---

From: Martin-Éric Racine <[email-masked]>
Date: Thu, 3 Feb 2022 09:55:53 +0200

> I guess this might be a toolchain or autobuilder issue.

The log suggests that this was built on an amd64 host configured with
a 386 chroot. This might explain it. Putting the port maintainers in
CC.

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Thu, 3 Feb 2022 09:10:06 +0100

Hi,

> a 386 chroot. This might explain it. Putting the port maintainers in

I also see 

Is Geode LX a supported machine in Bullseye in the first place? I
understand that the ALIX boards use that CPU and that they are rather
widely deployed, but...

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Thu, 3 Feb 2022 10:11:30 +0200

> a 386 chroot. This might explain it. Putting the port maintainers in

FYI I tried building this in a chroot. The following doesn't bode too well:

Now running lintian sudo_1.9.9-1_i386.changes ...
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/52/9f0be3cc3ee3895db3782367a6d5027b490c16.debug]
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/60/b26a463d4e15e03b1cad5bbd3a1c7727374e33.debug]
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/62/e514099b09b5784710801d4ee31c939fa78be2.debug]
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/75/92f631f7e3d7b3d445949b531311bd3c9dfd8d.debug]
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/bf/93824f1972a7ac3e65aa9cc4a2e688719c4218.debug]
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/d0/3d4a21049378634ee409aedd9e737342f022f7.debug]
W: sudo-dbgsym: elf-error In program headers: Unable to find program
interpreter name
[usr/lib/debug/.build-id/dc/68f81b10cfdf0528275050a5c9f58212c747b7.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/09/fd070313d4b734265d870c2a6c3c6ed5aa19af.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/64/c8cb86718642d65fc1d409ba1d673c4a8a667d.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/7e/ae661fff053994f13f649a30bde394ed533704.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/87/15a519ebb851bbeae9dc69da45fce90621f43f.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/dc/bc41efaa2f4467cabe9b472ae91056951a0bfe.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/e8/be7f62e31944813b3c52f051f8507869aa6550.debug]
W: sudo-ldap-dbgsym: elf-error In program headers: Unable to find
program interpreter name
[usr/lib/debug/.build-id/e9/e23698273c50a1e632d319e1586a8de59dd38b.debug]
N: 38 hints overridden (28 errors, 6 warnings, 4 info); 0 unused overrides
Finished running lintian.

Martin-Éric

---

From: Martin-Éric Racine <[email-masked]>
Date: Thu, 3 Feb 2022 10:14:21 +0200

> understand that the ALIX boards use that CPU and that they are rather

The base level kernel for i386 (linux-image-686) currently is a kernel
configured for Geode.

CONFIG_MGEODE_LX=y

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Thu, 3 Feb 2022 09:32:30 +0100

> [usr/lib/debug/.build-id/52/9f0be3cc3ee3895db3782367a6d5027b490c16.debug]

See #1000977 and #1000449

tl;dr, that's a binutils bug, which in turn causes those are non-overridable
lintian warnings.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 12:56:54 +0200

> The base level kernel for i386 (linux-image-686) currently is a kernel

Hello again,

Is there any progress on this? Have you checked wiht upstream for
possible changes in the code that would explain this? Or have there
been recent changes in the i386 port's toolchain defaults?

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Tue, 15 Feb 2022 12:23:35 +0100

On Tue, Feb 15, 2022 at 12:56:54PM +0200, Martin-Éric Racine wrote:
> possible changes in the code that would explain this?

Not yet. Can you confirm that old sudo upstream works with the current
toolchain? Sadly, I don't have any 32 bit systems left other than some
ARMs.

> Or have there

I was hoping that the i386 porters would comment on that.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 13:36:17 +0200

> toolchain? Sadly, I don't have any 32 bit systems left other than some

Logged onto my unstable-i386 chroot.
$ dget http://deb.debian.org/debian/pool/main/s/sudo/sudo_1.9.5p2-3.dsc
Fetched build-deps.
$ debuild -uc -us
Copied sudo and sudo-dbgsym over to the Geode host.
Logged onto the Geode host.
$ su
dpkg -i sudo*.deb
Logged onto Geode host as a normal user.
Tried a sudo command. No core dump. Command works as expected.

This would suggest upstream changes as the source of the problem.

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Tue, 15 Feb 2022 12:47:47 +0100

> Tried a sudo command. No core dump. Command works as expected.

Thank you. Two more questions:

Can you do actual builds on the Geode box?
If so, does the 1.9.9 package also dump core when it was actually built
on Geode?

Greetings
Marc

---

From: Marc Haber <[email-masked]>
Date: Tue, 15 Feb 2022 12:52:43 +0100

> If so, does the 1.9.9 package also dump core when it was actually built

And, can you try 1.9.8p2-1 from Snapshot?
https://snapshot.debian.org/package/sudo/1.9.8p2-1/

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 14:11:57 +0200

> If so, does the 1.9.9 package also dump core when it was actually built

Logged onto Geode host.
$ dget http://deb.debian.org/debian/pool/main/s/sudo/sudo_1.9.9-1.dsc
Fetched build-deps.
$ debuild -uc -us
[have plenty of coffee and snacks while things build]
Build crashes. See attachment.

Martin-Éric

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 15:04:47 +0200

> https://snapshot.debian.org/package/sudo/1.9.8p2-1/

This build also crashes.  Log attached.

Martin-Éric

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 16:12:03 +0200

> This build also crashes.  Log attached.

I also tried building that 1.9.8p2-1 on my amd64 host's i386 chroot.
It builds, and the binaries don't produce a core dump on the Geode
host. Presumably the breakage happened after that release.

Hopefully this can help you narrow it down.

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Tue, 15 Feb 2022 19:35:43 +0100

> Hopefully this can help you narrow it down.

Can you build a small table like

sudo version     built on      works/works not

When I do they there is possibility that I get it wrong and we have
wrong history in the bug report.

Thanks for your help, I appreciate that.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 21:03:01 +0200

> sudo version     built on      works/works not

1.9.5p2-3 built in unstable i386 chroot (amd64 host) works on Geode host
1.9.8p2-1 built in unstable i386 chroot (amd64 host) works on Geode host
1.9.9-1 built in unstable i386 chroot (amd64 host) COREDUMPS on Geode host

1.9.8p2-1 FTBFS on Geode testing host (log attached earlier)
1.9.9-1 FTBFS on Geode testing host (log attached earlier)

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Tue, 15 Feb 2022 20:10:39 +0100

> 1.9.9-1 FTBFS on Geode testing host (log attached earlier)

I apologize, I didnt see earlier that your builds were already failing
at build time. The error is

config.status:1474: error: cannot find input file: `plugins/sudoers/sudoers'

Was that file actually missing in your build chroot? If not, I don't
know what went wrong there.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Tue, 15 Feb 2022 21:58:49 +0200

> know what went wrong there.

No idea. I unpacked the source and types debuild. That's all.

However, here's an interesting thing. I tried building 1.9.9-1 again
on the Geode using a good sudo instead of fakeroot. It fails as
follows:

during GIMPLE pass: cunroll
../../../lib/util/event.c: In function ‘sudo_ev_add_v2’:
../../../lib/util/event.c:465:1: internal compiler error: in
graphds_scc, at graphds.c:316
  465 | sudo_ev_add_v2(struct sudo_event_base *base, struct sudo_event *ev,
      | ^~~~~~~~~~~~~~
0xb7555904 __libc_start_main
    ../csu/libc-start.c:332
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
make[3]: *** [Makefile:653: event.lo] Virhe 1
make[3]: Poistutaan hakemistosta
”/home/perkelix/sudo-1.9.9/build-simple/lib/util”
make[2]: *** [Makefile:108: all] Virhe 2
make[2]: Poistutaan hakemistosta ”/home/perkelix/sudo-1.9.9/build-simple”
dh_auto_build: error: cd build-simple && make -j1 returned exit code 2
make[1]: *** [debian/rules:45: override_dh_auto_build] Virhe 2
make[1]: Poistutaan hakemistosta ”/home/perkelix/sudo-1.9.9”
make: *** [debian/rules:37: build] Virhe 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Wed, 16 Feb 2022 08:11:11 +0100

>   465 | sudo_ev_add_v2(struct sudo_event_base *base, struct sudo_event *ev,

I think that this refers to gcc, not to sudo.

> make[3]: Poistutaan hakemistosta

It would probably help to run those with an English locale.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Wed, 16 Feb 2022 10:08:01 +0200

> I think that this refers to gcc, not to sudo.

Yes, it's a GCC failure while building sudo 1.9.9-1 on the Geode host itself.

> It would probably help to run those with an English locale.

/bin/bash ../../libtool --tag=disable-static --mode=compile gcc -c -o
json.lo -I../../../include -I../.. -I. -I../../../lib/util
-D_PATH_SUDO_CONF=\"/etc/sudo.conf\" -Wdate-time -D_FORTIFY_SOURCE=2
-DZLIB_CONST -DDEFAULT_TEXT_DOMAIN=\"sudo\" -g -O2
-ffile-prefix-map=/home/perkelix/sudo-1.9.9=. -fstack-protector-strong
-Wformat -Werror=format-security -Wall -pedantic -fvisibility=hidden
-fPIE -fstack-protector-strong -fstack-clash-protection
-fcf-protection ../../../lib/util/json.c
libtool: compile:  gcc -c -I../../../include -I../.. -I.
-I../../../lib/util -D_PATH_SUDO_CONF=\"/etc/sudo.conf\" -Wdate-time
-D_FORTIFY_SOURCE=2 -DZLIB_CONST -DDEFAULT_TEXT_DOMAIN=\"sudo\" -g -O2
-ffile-prefix-map=/home/perkelix/sudo-1.9.9=. -fstack-protector-strong
-Wformat -Werror=format-security -Wall -pedantic -fvisibility=hidden
-fstack-protector-strong -fstack-clash-protection -fcf-protection
../../../lib/util/json.c  -fPIC -DPIC -o .libs/json.o
during GIMPLE pass: dom
../../../lib/util/json.c: In function 'json_append_string':
../../../lib/util/json.c:122:1: internal compiler error: in
graphds_scc, at graphds.c:316
  122 | json_append_string(struct json_container *json, const char *str)
      | ^~~~~~~~~~~~~~~~~~
0xb7574904 __libc_start_main
    ../csu/libc-start.c:332
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
make[3]: *** [Makefile:968: json.lo] Error 1
make[3]: Leaving directory '/home/perkelix/sudo-1.9.9/build-simple/lib/util'
make[2]: *** [Makefile:108: all] Error 2
make[2]: Leaving directory '/home/perkelix/sudo-1.9.9/build-simple'
dh_auto_build: error: cd build-simple && make -j1 returned exit code 2
make[1]: *** [debian/rules:45: override_dh_auto_build] Error 2
make[1]: Leaving directory '/home/perkelix/sudo-1.9.9'
make: *** [debian/rules:37: build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Wed, 16 Feb 2022 09:11:57 +0100

> graphds_scc, at graphds.c:316

That makes it a toolchain issue.

This bug has grown huge. Can you please file a new bug against gcc and
mark this bug as affected? I am not sure whether it woud make sense to
clone this monster to gcc.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Wed, 16 Feb 2022 11:20:09 +0200

> clone this monster to gcc.

Bug#1005863: gcc-11: invalid opcode for Geode LX on i386

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Wed, 16 Feb 2022 17:45:03 +0100

Hi,

> No idea. I unpacked the source and types debuild. That's all.

Can you retry building with the lines 4863-4866:

    AX_CHECK_LINK_FLAG([-fcf-protection], [
	AX_APPEND_FLAG([-fcf-protection], [SSP_CFLAGS])
	AX_APPEND_FLAG([-Wc,-fcf-protection], [SSP_LDFLAGS])
    ])

of configure.ac removed? There is suspicion that the hardening options don't
play too well with Geode LX.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Wed, 16 Feb 2022 19:15:37 +0200

> > No idea. I unpacked the source and types debuild. That's all.

Btw, the build log has tons of the following:

./configure: cannot duplicate fd -19201 to fd 0: Bad file descriptor

> play too well with Geode LX.

I cannot help but wonder why the build doesn't simply parse
$(HARDENING_CFLAGS) and $(HARDENING_LDFLAGS). Hard-coded hardening
options tend to be a bad idea. GCC supports them all, but the target
host's CPU won't always support them.

0xb754d904 __libc_start_main

***

diff -Nru sudo-1.9.9/debian/changelog sudo-1.9.9/debian/changelog
--- sudo-1.9.9/debian/changelog    2022-01-31 21:19:55.000000000 +0200
+++ sudo-1.9.9/debian/changelog    2022-02-16 18:56:31.000000000 +0200
@@ -1,3 +1,9 @@
+sudo (1.9.9-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+
+ -- Martin-Éric Racine <[email-masked]>  Wed, 16 Feb 2022
18:56:31 +0200
+
 sudo (1.9.9-1) unstable; urgency=medium

   * new upstream version
diff -Nru sudo-1.9.9/debian/patches/remove-fcf-protection.patch
sudo-1.9.9/debian/patches/remove-fcf-protection.patch
--- sudo-1.9.9/debian/patches/remove-fcf-protection.patch
1970-01-01 02:00:00.000000000 +0200
+++ sudo-1.9.9/debian/patches/remove-fcf-protection.patch
2022-02-16 18:56:31.000000000 +0200
@@ -0,0 +1,42 @@
+Description: <short summary of the patch>
+ TODO: Put a short summary on the line above and replace this paragraph
+ with a longer explanation of this change. Complete the meta-information
+ with other relevant fields (see below for details). To make it easier, the
+ information below has been extracted from the changelog. Adjust it or drop
+ it.
+ .
+ sudo (1.9.9-1.1) UNRELEASED; urgency=medium
+ .
+   * Non-maintainer upload.
+Author: Martin-Éric Racine <[email-masked]>
+
+---
+The information above should follow the Patch Tagging Guidelines, please
+checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
+are templates for supplementary fields that you might want to add:
+
+Origin: <vendor|upstream|other>, <url of original patch>
+Bug: <url in upstream bugtracker>
+Bug-Debian: https://bugs.debian.org/<bugnumber>
+Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
+Forwarded: <no|not-needed|url proving that it has been forwarded>
+Reviewed-By: <name and email of someone who approved the patch>
+Last-Update: 2022-02-16
+
+--- sudo-1.9.9.orig/configure.ac
++++ sudo-1.9.9/configure.ac
+@@ -4860,10 +4860,10 @@ if test "$enable_hardening" != "no"; the
+     AX_APPEND_FLAG([-fstack-clash-protection], [SSP_CFLAGS])
+     AX_APPEND_FLAG([-Wc,-fstack-clash-protection], [SSP_LDFLAGS])
+     ])
+-    AX_CHECK_LINK_FLAG([-fcf-protection], [
+-    AX_APPEND_FLAG([-fcf-protection], [SSP_CFLAGS])
+-    AX_APPEND_FLAG([-Wc,-fcf-protection], [SSP_LDFLAGS])
+-    ])
++dnl     AX_CHECK_LINK_FLAG([-fcf-protection], [
++dnl    AX_APPEND_FLAG([-fcf-protection], [SSP_CFLAGS])
++dnl    AX_APPEND_FLAG([-Wc,-fcf-protection], [SSP_LDFLAGS])
++dnl    ])
+     AX_CHECK_LINK_FLAG([-Wl,-z,relro],
[AX_APPEND_FLAG([-Wl,-z,relro], [LDFLAGS])])
+     AX_CHECK_LINK_FLAG([-Wl,-z,now], [AX_APPEND_FLAG([-Wl,-z,now],
[LDFLAGS])])
+     AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack],
[AX_APPEND_FLAG([-Wl,-z,noexecstack], [LDFLAGS])])
diff -Nru sudo-1.9.9/debian/patches/series sudo-1.9.9/debian/patches/series
--- sudo-1.9.9/debian/patches/series    2022-01-31 21:19:55.000000000 +0200
+++ sudo-1.9.9/debian/patches/series    2022-02-16 18:56:31.000000000 +0200
@@ -1,3 +1,4 @@
 paths-in-samples.diff
 Whitelist-DPKG_COLORS-environment-variable.diff
 sudo-ldap-docs
+remove-fcf-protection.patch

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Wed, 16 Feb 2022 21:31:43 +0100

> host's CPU won't always support them.

That would be an upstream issue, I think. Upstream uses bugzilla, so you
need an account to submit a bug. Would you want to do that, or can you
help me with the wording of a bug report?

>   465 | sudo_ev_add_v2(struct sudo_event_base *base, struct sudo_event *ev,

So it still doesn't build on Geode LX.

How about your i386 build chroot?

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Wed, 16 Feb 2022 22:45:28 +0200

> How about your i386 build chroot?

Builds fine on my i386 chroot (amd64 host) and the resulting binary
doesn't dump core when installed on the Geode. Assuming there's no
uncovered corner case due to other optimizations, I think we've got a
winner.

Martin-Éric

---

From: Henning Paul <[email-masked]>
Date: Fri, 18 Feb 2022 15:21:23 +0100

> uncovered corner case due to other optimizations, I think we've got a

Triggered build on a fresh sid install on my Alix board and obtained the
attached log file. AFAICT, the compile itself did not produce any
errors, but fuzz_sudo_conf causes the known illegal opcode exception.

best regards
Henning

---

From: Henning Paul <[email-masked]>
Date: Fri, 18 Feb 2022 21:51:57 +0100

> errors, but fuzz_sudo_conf causes the known illegal opcode exception.

lscpu:

root@alix:~# lscpu
Architecture:           i586
   CPU op-mode(s):       32-bit
   Address sizes:        32 bits physical, 32 bits virtual
   Byte Order:           Little Endian
CPU(s):                 1
   On-line CPU(s) list:  0
Vendor ID:              AuthenticAMD
   Model name:           Geode(TM) Integrated Processor by AMD PCS
     CPU family:         5
     Model:              10
     Thread(s) per core: 1
     Core(s) per socket: 1
     Socket(s):          1
     Stepping:           2
     BogoMIPS:           996.02
     Flags:              fpu de pse tsc msr cx8 sep pge cmov clflush mmx
mmxext 3
                         dnowext 3dnow cpuid 3dnowprefetch vmmcall
Caches (sum of all):
   L1d:                  57 KiB (1 instance)
   L1i:                  57 KiB (1 instance)
   L2:                   128 KiB (1 instance)
Vulnerabilities:
   Itlb multihit:        Not affected
   L1tf:                 Not affected
   Mds:                  Not affected
   Meltdown:             Not affected
   Spec store bypass:    Vulnerable
   Spectre v1:           Mitigation; usercopy/swapgs barriers and __user
pointer
                         sanitization
   Spectre v2:           Mitigation; Full generic retpoline, STIBP
disabled, RSB
                         filling
   Srbds:                Not affected
   Tsx async abort:      Not affected

best regards
Henning

---

From: Marc Haber <[email-masked]>
Date: Sat, 19 Feb 2022 06:30:17 +0100

>   Model name:           Geode(TM) Integrated Processor by AMD PCS

Should that not explicitly say "Geode LX"? And, afaik, the Geode LX is a
i686 not an i586 machine?

Martin-Éric, what does your lscpu say?

Greetings
Marc

---

From: Henning Paul <[email-masked]>
Date: Sat, 19 Feb 2022 09:02:02 +0100

Hello,

Am 19.02.22 um 06:30 schrieb Marc Haber:
> Should that not explicitly say "Geode LX"?

I can send you photos of the processor as proof, it says LX on it.

> And, afaik, the Geode LX is a i686 not an i586 machine?

IIRC, it doesn't implement all of the i686 instruction set (hence the
illegal opcode).

regards
Henning

---

From: Marc Haber <[email-masked]>
Date: Mon, 14 Mar 2022 15:19:05 +0100

Control: tags -1 wontfix
Control: severity -1 minor
thanks

> IIRC, it doesn't implement all of the i686 instruction set (hence the

I apologize, but it looks like the Geode LX is no longer among the CPUs
supported in Debian. FWIW, the stretch release notes still mentioned the
Geode LX explicitly in chapters 2.1 and 5.1.7:

2.1:
Support for 32-bit PCs no longer covers vanilla i586

    The 32-bit PC support (known as the Debian architecture i386) now no
    longer covers a plain i586 processor. The new baseline is the i686,
    although some i586 processors (e.g. the “AMD Geode”) will remain
    supported.

    Please refer to Section 5.1.7, “Minimum requirement for 32-bit Intel
    is now i686 (with a minor exception)” for more information.

5.1.7. Minimum requirement for 32-bit Intel is now i686 (with a minor exception)

The 32-bit PC support (known as the Debian architecture i386) now no
longer covers a plain i586 processor. The new baseline is the i686,
although some i586 processors (e.g. the “AMD Geode”) will remain
supported.

Both mentions have vanished from the Release Notes for buster and
bullseye. It looks like this non-support has now manifested itself in
our toolchains using the full i686 instruction set including the opcodes
that the Geode LX does not have.

I therefore apologize for marking this bug wontfix.

If you find any evidence in our docs that the Geode LX should still be
supported in Debian 12, please let me know and I'll happily resume
pursuing this issue.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Mon, 14 Mar 2022 16:23:40 +0200

> Support for 32-bit PCs no longer covers vanilla i586

The Geode LX is not a vanilla 586. It is a vanilla 686. The reported
CPU variant has simply remained at 586 for reasons only known to AMD.

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Mon, 14 Mar 2022 15:30:02 +0100

> CPU variant has simply remained at 586 for reasons only known to AMD.

According to all docs available to me, it is a vanilla 686 sans
multi-byte NOP ("NOPL").

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Mon, 14 Mar 2022 16:32:58 +0200

> According to all docs available to me, it is a vanilla 686 sans

That's correct. No PAE and no NOPL.

Martin-Éric

---

From: Marc Haber <[email-masked]>
Date: Mon, 14 Mar 2022 15:38:55 +0100

> That's correct. No PAE and no NOPL.

The only piece of evidence I have is that:

- Debian explicitly mentioned NOPL-less i686 processors as being
  supported in stretch AND
- this mention vanishing in buster and bullseye

Not being a native speaker of English, is there any other possible
interpretation of this removal than the retraction of support for
NOPL-less i686 processors?

I have never seen Debian issue release notes like "the frobnication
processor is no longer supported", and i386 being the former mainstream
architecture, there is no explicit porter group to talk to.

I am afraid that my time resources are limited. If you want continued
action on this but report, please talk to the gcc and/or linux
maintainers in Debian and have them tell me that the Geode LX is still
supported.

I apologize, but I do not intend at the moment to reduce sudo's
hardening level just to have it run on Geode LX.

Greetings
Marc

---

From: Martin-Éric Racine <[email-masked]>
Date: Mon, 14 Mar 2022 16:45:10 +0200

> NOPL-less i686 processors?

Possibly. Dropping support for non-PAE i686 has been randomly
discussed on mailing lists. However, the base kernel on i386 still is
configured for a Geode LX.

> architecture, there is no explicit porter group to talk to.

That's incorrect. Every now and then, architectures drop support for
earlier CPU variants and that tends to be mentioned in the release
notes.

> maintainers in Debian and have them tell me that the Geode LX is still

In CC.

Martin-Éric

---

From: Martin-Éric Racine <[email-masked]>
Date: Fri, 25 Mar 2022 15:51:42 +0200

> > maintainers in Debian and have them tell me that the Geode LX is still

FYI, I reported this upstream at:

https://github.com/sudo-project/sudo/issues/140

Upstream commented that this seems to really be a GCC issue:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104713

The GCC bug report refers to this Debian bug as an example of what
this GCC bug causes.

Martin-Éric