• Bug#1063719: needrestart -b complainst of initialized variables on some

    From George Robbert@21:1/5 to All on Sun Feb 11 19:30:01 2024
    This is a multi-part MIME message sent by reportbug.


    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
  • From George Robbert@21:1/5 to All on Tue Feb 13 18:40:02 2024
    Hey,

    Just like with the previous bug (#1026927), it looks like there's more
    to this one. Trying the patch on several more systems I run into the
    same symptoms on some. Again, these have the same symptoms but
    differing causes (full patch included). What I found was:


    On an intel system, where uCode/AMD.pm was run before uCode/Intel.pm

    intel_sys1# needrestart -b
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-18-amd64
    NEEDRESTART-KEXP: 6.1.0-18-amd64
    NEEDRESTART-KSTA: 1
    NEEDRESTART-UCSTA: 1
    Use of uninitialized value $ucode_vars{"CURRENT"} in concatenation (.) or string at /usr/sbin/needrestart line 940.
    NEEDRESTART-UCCUR:
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string at /usr/sbin/needrestart line 941.
    NEEDRESTART-UCEXP:

    But we don't get the 'Use of uninitialized value' when run as
    `needrestart -b -v`. The issue here is that nr_ucode_check keeps
    going after the "eval ... ${pkg}::nr_ucode_check_real..." fails
    unless $debug is set. Thus, without $debug, thi saves off the
    unintialized values from AMD.pm as "the good ones", so we get the
    error.

    On a VM running with an AMD processor but without package
    amd64-microcode, and also directly on an AMD system with a processor new enough that it does not have a microcode version lin amd64-microcode, I get
    the following identical results.

    amd_vm1# needrestart -b
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-18-amd64
    NEEDRESTART-KEXP: 6.1.0-18-amd64
    NEEDRESTART-KSTA: 1
    NEEDRESTART-UCSTA: 1
    NEEDRESTART-UCCUR: 0xa0011d1
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string at /usr/sbin/needrestart line 941.
    NEEDRESTART-UCEXP:


    amd_sys3# needrestart -b
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-18-amd64
    NEEDRESTART-KEXP: 6.1.0-18-amd64
    NEEDRESTART-KSTA: 1
    NEEDRESTART-UCSTA: 1
    NEEDRESTART-UCCUR: 0x6006705
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string at /usr/sbin/needrestart line 941.
    NEEDRESTART-UCEXP:

    This comes from AMD.pm not setting $ucode_vars{"AVAIL"} if it doesn't
    find any matching available versions. compare_ucode_versions()
    handles, this as expected, but leaves $ucode_vars{"AVAIL"} unset to
    cause problems later when run with -b.


    The attached patch fixes includes the previous patch and also fixes
    these 2 issues.

    Hope this helps,
    George


    --- /tmp/uCode.pm.dist 2024-02-13 09:20:29.236867717 -0700
    +++ /usr/share/perl5/NeedRestart/uCode.pm 2024-02-13 09:33:23.099742955 -0700
    @@ -152,10 +152,15 @@

    # 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 ) {
    - print STDERR $@;
    + if ( $@ ) {
    + print STDERR $@ if ($debug);
    $ui->progress_step;
    next;
    }
    @@ -174,6 +179,10 @@

    $ui->progress_fin;

    + if ( $state == NRM_CURRENT && ! grep ( ( $_ eq "AVAIL"), @vars ) ) {
    + push(@vars, "AVAIL", "unavailable");
    + }
    +
    return ( $state, @vars );
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bob Proulx@21:1/5 to George Robbert on Tue Feb 20 01:30:01 2024
    George Robbert wrote:
    On an intel system, where uCode/AMD.pm was run before uCode/Intel.pm

    intel_sys1# needrestart -b
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.1.0-18-amd64
    NEEDRESTART-KEXP: 6.1.0-18-amd64
    NEEDRESTART-KSTA: 1
    NEEDRESTART-UCSTA: 1
    Use of uninitialized value $ucode_vars{"CURRENT"} in concatenation (.) or string at /usr/sbin/needrestart line 940.
    NEEDRESTART-UCCUR:
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string at /usr/sbin/needrestart line 941.
    NEEDRESTART-UCEXP:

    I have been seeing these exact uninitialized value errors on my
    machines too. Very annoying as I am often using dsh to scan a large
    collective of systems and the noise from these errors obscures the
    information want to read.

    The attached patch fixes includes the previous patch and also fixes
    these 2 issues.

    I have applied this second patch from George on my systems both Stable
    and Unstable and it has solved the uninitialized value errors for me.
    I saw no problems patching or running. It is oh so very nice not to
    be seeing those uninitialized value errors.

    Example on an Debian Unstable Sid system.

    root@clash:/# needrestart -b
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.4.0-4-amd64
    NEEDRESTART-KEXP: 6.4.0-4-amd64
    NEEDRESTART-KSTA: 1
    NEEDRESTART-UCSTA: 1
    Use of uninitialized value $ucode_vars{"CURRENT"} in concatenation (.) or string at /usr/sbin/needrestart line 940.
    NEEDRESTART-UCCUR:
    Use of uninitialized value $ucode_vars{"AVAIL"} in concatenation (.) or string at /usr/sbin/needrestart line 941.
    NEEDRESTART-UCEXP:

    root@clash:/# patch -p0 < /var/tmp/needrestart-ghr-2.patch
    patching file /usr/share/perl5/NeedRestart/uCode.pm
    Hunk #2 succeeded at 179 with fuzz 1.

    root@clash:/# needrestart -b
    NEEDRESTART-VER: 3.6
    NEEDRESTART-KCUR: 6.4.0-4-amd64
    NEEDRESTART-KEXP: 6.4.0-4-amd64
    NEEDRESTART-KSTA: 1
    NEEDRESTART-UCSTA: 0

    Looks good to me! :-)

    Bob

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)