Package: sg3-utils
Version: 1.46-3
Severity: important
Tags: patch upstream
X-Debbugs-Cc: gregory.da...@indexengines.com

Hello,

This bug is in the upstream sg3-utils project, version 1.46.  The upstream
project has applied a fix for later versions which Debian is not using in
testing/unstable.  The upstream fix has been applied as a backport patch
on other Linux distros which also have chosen to remain on version 1.46.

The upstream issue and fix can be tracked here:
https://github.com/doug-gilbert/sg3_utils/pull/10

The attached patch is a debdiff to implement the change in the above
pull-request as a patch in the Debian package.

To reproduce the issue, install Debian stable or newer, where the root
partition is stored on a SCSI device (virtual or physical).  Do not use
LVM to partition the disk.  Run 'rescan-scsi-bus.sh -a -r' as the root
user.  Suppose the '/' root partition is on /dev/sda, which is
underpinned by the /dev/sg0 device.  When the script queries other tools
in the sg3-utils package, it fails to parse their output properly and
mistakenly marks the /dev/sg0 device for removal.  Once removed, no
other commands are possible.  If an SSH server was running on the
machine, it will not accept any more connections.  The machine needs to
be rebooted once in this state, in order for the SCSI device to be
attached again.

After applying the patch, the root partition's SCSI device description is
correctly parsed in the rescan-scsi-bus.sh script.  Devices are no
longer incorrectly detached or removed.

Greg


-- System Information:
Debian Release: 12.8
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-26-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages sg3-utils depends on:
ii  libc6               2.36-9+deb12u9
ii  libsgutils2-1.46-2  1.46-3.1

sg3-utils recommends no packages.

sg3-utils suggests no packages.

-- no debconf information
diff -Nru sg3-utils-1.46/debian/changelog sg3-utils-1.46/debian/changelog
--- sg3-utils-1.46/debian/changelog     2023-03-02 13:58:32.000000000 -0500
+++ sg3-utils-1.46/debian/changelog     2024-11-12 11:16:50.000000000 -0500
@@ -1,3 +1,11 @@
+sg3-utils (1.46-3.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Backport upstream bugfix for rescan-scsi-bus.sh
+    + https://github.com/doug-gilbert/sg3_utils/pull/10
+
+ -- Gregory Davis <gregory.da...@indexengines.com>  Tue, 12 Nov 2024 11:16:50 
-0500
+
 sg3-utils (1.46-3) unstable; urgency=medium
 
   * Upload to unstable
diff -Nru sg3-utils-1.46/debian/patches/0002-backport-rescan-scsi-bus.patch 
sg3-utils-1.46/debian/patches/0002-backport-rescan-scsi-bus.patch
--- sg3-utils-1.46/debian/patches/0002-backport-rescan-scsi-bus.patch   
1969-12-31 19:00:00.000000000 -0500
+++ sg3-utils-1.46/debian/patches/0002-backport-rescan-scsi-bus.patch   
2024-11-12 11:16:50.000000000 -0500
@@ -0,0 +1,18 @@
+Index: sg3-utils-1.46/scripts/rescan-scsi-bus.sh
+===================================================================
+--- sg3-utils-1.46.orig/scripts/rescan-scsi-bus.sh
++++ sg3-utils-1.46/scripts/rescan-scsi-bus.sh
+@@ -307,7 +307,13 @@ testonline ()
+   IPREV=$(echo "$INQ" | grep 'Product revision level:' | sed 's/^[^:]*: 
\(.*\)$/\1/')
+   STR=$(printf "  Vendor: %-08s Model: %-16s Rev: %-4s" "$IVEND" "$IPROD" 
"$IPREV")
+   IPTYPE=$(echo "$INQ" | sed -n 's/.* Device_type=\([0-9]*\) .*/\1/p')
++  if [ -z "$IPTYPE" ]; then
++    IPTYPE=$(echo "$INQ" | sed -n 's/.* PDT=\([0-9]*\) .*/\1/p')
++  fi
+   IPQUAL=$(echo "$INQ" | sed -n 's/ *PQual=\([0-9]*\)  Device.*/\1/p')
++  if [ -z "$IPQUAL" ] ; then
++    IPQUAL=$(echo "$INQ" | sed -n 's/ *PQual=\([0-9]*\)  PDT.*/\1/p')
++  fi
+   if [ "$IPQUAL" != 0 ] ; then
+     [ -z "$IPQUAL" ] && IPQUAL=3
+     [ -z "$IPTYPE" ] && IPTYPE=31
diff -Nru sg3-utils-1.46/debian/patches/series 
sg3-utils-1.46/debian/patches/series
--- sg3-utils-1.46/debian/patches/series        2023-03-01 02:54:37.000000000 
-0500
+++ sg3-utils-1.46/debian/patches/series        2024-11-12 11:16:50.000000000 
-0500
@@ -1 +1,2 @@
 0001-Fix-path-for-udevadm.patch
+0002-backport-rescan-scsi-bus.patch

Reply via email to