Package: needrestart
Version: 3.6-4+deb12u1
Severity: normal
Tags: patch

Dear Maintainer,

When running 'needrestart -b' on some AMD systems I get the following
uninitialized variable warning.  It also does not report the expected
microcode version (NEEDRESTART-UCEXP).

Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string 
at /usr/sbin/needrestart line 941.

On ARM systems, it gives the following 2 uninitialized variable warnings.

Use of uninitialized value $ucode_vars{"CURRENT"} in concatenation (.) or 
string at /usr/sbin/needrestart line 940.
Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string 
at /usr/sbin/needrestart line 941.

I first thought this was a regression of bug #1026927, but find this
is actually a different bug with similar behavior.

The problem stems from NeedRestart::uCode::Intel:::nr_ucode_check_real
running "successfully" on non-intel platforms.  The reason only some
AMD systems are affected is that nr_ucode_check_real() for AMD and
Intel may be run in either order, depending on the order they are
returned by findsubmod().  If AMD::nr_ucode_check_real() is run first,
the bug does not appear.

Here is sample output from 3 systems: a "failing" AMD, a "passing"
AMD, and an arm7l (banana pi).  I've trimmed (w/ grep) the stderr from
these to only the pertinent lines, please let me know if you want the
entire output.

    amd_sys1# needrestart -b -v 2>/tmp/a
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-17-amd64
    NEEDRESTART-KEXP: 6.1.0-18-amd64
    NEEDRESTART-KSTA: 3
    NEEDRESTART-UCSTA: 1
    NEEDRESTART-UCCUR: 0x600063e
    NEEDRESTART-UCEXP: 
    amd_sys1# grep -e NeedRestart::uCode -e uninitialized /tmp/a 
    [ucode] using NeedRestart::uCode::Intel
    [ucode] using NeedRestart::uCode::AMD
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or 
string at /usr/sbin/needrestart line 941.

    amd_sys2# needrestart -b -v 2>/tmp/a
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-17-amd64
    NEEDRESTART-KEXP: 6.1.0-18-amd64
    NEEDRESTART-KSTA: 3
    NEEDRESTART-UCSTA: 1
    NEEDRESTART-UCCUR: 0x06000852
    NEEDRESTART-UCEXP: 0x06000852
    amd_sys2# grep -e NeedRestart::uCode -e uninitialized /tmp/a       
    [ucode] using NeedRestart::uCode::AMD
    [ucode] using NeedRestart::uCode::Intel

    arm7l_sys# needrestart -b -v 2>/tmp/a
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-17-armmp-lpae
    NEEDRESTART-KEXP: 6.1.0-18-armmp-lpae
    NEEDRESTART-KSTA: 3
    NEEDRESTART-UCSTA: 0
    NEEDRESTART-SVC: irqbalance
    NEEDRESTART-SVC: lircd
    NEEDRESTART-SVC: lircmd
    NEEDRESTART-SVC: openbsd-inetd
    NEEDRESTART-SVC: ssh
    arm7l_sys# grep -e uninitial -e ucode /tmp/a       
    [ucode] using NeedRestart::uCode::Intel
    [ucode] using NeedRestart::uCode::AMD
    [ucode] #0 did not get available microcode version
    Use of uninitialized value $ucode_vars{"CURRENT"} in concatenation (.) or 
string at /usr/sbin/needrestart line 940.
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or 
string at /usr/sbin/needrestart line 941.


The problem comes from uCode::Intel::nr_ucode_check_real() still not
dying on non-Intel processors, and actually returning a "CURRENT"
microcode version on AMD processors.  This looks to be checked for in
uCode::Intel::nr_ucode_init(), but this function is never called.

The following patch adds a call to this so that nr_ucode_check_real()
is only called for architectures that successfully pass
nr_ucode_init().  An alternative would be to modify
uCode::Intel::nr_ucode_check_real() to do the equivalent checks like
uCode::AMD does.



--- /tmp/uCode.pm.dist  2024-02-11 09:28:27.051119002 -0700
+++ uCode.pm    2024-02-11 10:14:26.905533440 -0700
@@ -152,6 +152,11 @@
 
         # call ucode modules
         foreach my $pkg (@PKGS) {
+           eval "${pkg}::nr_ucode_init();";
+           if ( $@ ) {
+               print STDERR $@ if ($debug);
+               next;
+           }
             my @nvars;
             eval "\@nvars = ${pkg}::nr_ucode_check_real(\$debug, \$ui, 
\$processors{\$pid});";
             if ( $@ && $debug ) {






-- Package-specific info:
needrestart output:
Your outdated processes:
emacs[9574, 6843, 10275, 3922, 6197]



-- System Information:
Debian Release: 12.0
Architecture: i386 (i686)

Kernel: Linux 6.1.0-17-686-pae (SMP w/6 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=ANSI_X3.4-1968) 
(ignored: LC_ALL set to C), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages needrestart depends on:
ii  binutils                   2.40-2
ii  dpkg                       1.21.22
ii  gettext-base               0.21-12
ii  libintl-perl               1.33-1
ii  libmodule-find-perl        0.16-2
ii  libmodule-scandeps-perl    1.31-2
ii  libproc-processtable-perl  0.634-1+b2
ii  libsort-naturally-perl     1.03-4
ii  libterm-readkey-perl       2.38-2+b1
ii  perl                       5.36.0-7+deb12u1
ii  xz-utils                   5.4.1-0.2

Versions of packages needrestart recommends:
pn  systemd | libimvirt-perl  <none>
ii  sysvinit-core             3.06-4devuan3

Versions of packages needrestart suggests:
pn  iucode-tool                          <none>
pn  needrestart-session | libnotify-bin  <none>

-- Configuration Files:
/etc/apt/apt.conf.d/99needrestart changed:
DPkg::Post-Invoke {"test -x /usr/lib/needrestart/apt-pinvoke && 
/usr/lib/needrestart/apt-pinvoke -b || true"; };

/etc/needrestart/hook.d/20-rpm [Errno 2] No such file or directory: 
'/etc/needrestart/hook.d/20-rpm'

-- no debconf information
--- /tmp/uCode.pm.dist  2024-02-11 09:28:27.051119002 -0700
+++ uCode.pm    2024-02-11 10:14:26.905533440 -0700
@@ -152,6 +152,11 @@
 
         # call ucode modules
         foreach my $pkg (@PKGS) {
+           eval "${pkg}::nr_ucode_init();";
+           if ( $@ ) {
+               print STDERR $@ if ($debug);
+               next;
+           }
             my @nvars;
             eval "\@nvars = ${pkg}::nr_ucode_check_real(\$debug, \$ui, 
\$processors{\$pid});";
             if ( $@ && $debug ) {

Reply via email to