The SG_IO ioctl is a SCSI generic ioctl used for sending raw SCSI commands to devices under Linux. Valgrind incorrectly shows the memory areas that were written to by the kernel when performing the ioctl as untouched, such as when some data is returned from the device to the userspace for reading. Reproducible: Always Steps to Reproduce: 1. Write a program that sends some data to a device via the SG_IO ioctl, or use the attached example. 2. Run the program under valgrind. Actual Results: Valgrind reports the memory areas written to by the kernel as uninitialized. Running the attached example results in the following messages to appear : - Conditional jump or move depends on uninitialised value(s) - Syscall param write(buf) points to uninitialised byte(s) Expected Results: Valgrind should treat the memory areas as initialized by the ioctl() call, and the aforementioned messages should not appear. The attached example program obtains some basic information about a CD-ROM device located at /dev/sr0 via the INQUIRY SCSI command, sent to it via the SG_IO ioctl. Please use it while reviewing the bug.
Created attachment 86244 [details] Example program for illustrating the bug Gets information about /dev/sr0 via the INQUIRY command.
Created attachment 86245 [details] Proposed patch for the issue
Committed, with minor changes, as r14107.