** Description changed:

+ [ Impact ]
+ 
+   * sg_wr_mode rejects all arguments (even if valid) to --contents= or
+     --cfile=.
+ 
+   * This impacts every usage of sg_wr_mode with --contents= or --cfile.
+ 
+   * This used to work in Noble, and is a regression in Resolute.
+ 
+   * The upload fixes the bug by including a patch from upstream that corrects
+     the argument handling logic.
+ 
+ [ Test Plan ]
+ 
+  * Running the following script should output nothing.
+ 
+ sg_wr_mode --page=8 --contents=0,1 /dev/null 2>&1 | grep 'bad argument'
+ sg_wr_mode --page=8 --contents='08 12 01' /dev/null 2>&1 | grep 'bad argument'
+ sg_wr_mode -p 8 -c 08,12,01 /dev/null 2>&1 | grep 'bad argument'
+ 
+ printf '\x08\x12\x01' > /tmp/page.bin
+ sg_wr_mode --page=8 --cfile=/tmp/page.bin /dev/null 2>&1 | grep 'bad argument'
+ 
+   * Current output in Resolute:
+ 
+ bad argument to '--contents='
+ bad argument to '--contents='
+ bad argument to '--contents='
+ bad argument to '--cfile='
+ 
+ [ Where problems could occur ]
+ 
+  * Changes are isolated to argument parsing in sg_wr_mode.
+ 
+  * Any regression would show up as other valid arguments for sg_wr_mode being
+    misparsed or rejected.
+ 
+ [ Other Info ]
+ 
+  * This issue was fixed upstream in svn r1048, but there's no upstream release
+    yet.
+ 
+ [ Original Bug Description ]
+ 
  Package: sg3-utils 1.48-3ubuntu3
  Ubuntu: 26.04 (Resolute Raccoon)
  Binary: sg_wr_mode version "1.30 20230623"
  
  sg_wr_mode rejects every --contents= and --cfile= argument before
  opening the target device, regardless of value. The rejection fires from
  argv parsing — it's not device-specific.
  
  Repro (any of these):
  
  $ sg_wr_mode --page=8 --contents=0,1 /dev/null
  bad argument to '--contents='
  
  $ sg_wr_mode --page=8 --contents="08 12 01" /dev/null
  bad argument to '--contents='
  
  $ sg_wr_mode -p 8 -c 08,12,01 /dev/null
  bad argument to '--contents='
  
  $ printf '\x08\x12\x01' > /tmp/page.bin
  $ sg_wr_mode --page=8 --cfile=/tmp/page.bin /dev/null
  bad argument to '--cfile='
  
  Exit code: 32 in every case.
  
  strace confirms the failure is pre-I/O: libsgutils2-1.48.so.2 loads,
  then the error is written to stderr and the process exits — the device
  is never opened. So the bug is in sg_wr_mode's argv handler, not the
  underlying SCSI layer.
  
  Confirmed not device-related: same failure against /dev/sg1 (a QEMU CD-
  ROM SCSI generic device). sg_inq and sg_modes against the same device
  work normally — only sg_wr_mode's argument parser rejects --contents=.
  The sg3-utils library and the device are both healthy; the bug is
  isolated to sg_wr_mode.
  
  Workaround: issue MODE SELECT(10) directly via sg_raw, e.g.: sg_raw -v
  -s 28 -i payload.bin /dev/sgN 55 10 00 00 00 00 00 00 1C 00
  
  Expected: --contents= should accept the documented "comma-separated
  string of hex numbers (00..ff)" syntax (per the man page and --help
  text).
  
  Actual: every value is rejected.
  
  ProblemType: Bug
  DistroRelease: Ubuntu 26.04
  Package: sg3-utils 1.48-3ubuntu3
  ProcVersionSignature: Ubuntu 7.0.0-15.15-generic 7.0.0
  Uname: Linux 7.0.0-15-generic x86_64
  ApportVersion: 2.34.0-0ubuntu2
  Architecture: amd64
  CasperMD5CheckResult: pass
- Date: Sat May  9 13:59:51 2026
+ Date: Sat May 9 13:59:51 2026
  InstallationDate: Installed on 2026-05-02 (7 days ago)
  InstallationMedia: Ubuntu-Server 26.04 "Resolute Raccoon" - Release amd64 
(20260420.1)
  ProcEnviron:
   LANG=en_US.UTF-8
   PATH=(custom, no user)
   SHELL=/bin/bash
   TERM=xterm-256color
   XDG_RUNTIME_DIR=<set>
  SourcePackage: sg3-utils
  UpgradeStatus: No upgrade log present (probably fresh install)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2152092

Title:
  sg_wr_mode rejects every --contents= and --cfile= argument with "bad
  argument"

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/sg3-utils/+bug/2152092/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to