Bug 333817 - Valgrind reports the memory areas written to by the SG_IO ioctl as untouched
Summary: Valgrind reports the memory areas written to by the SG_IO ioctl as untouched
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-24 11:35 UTC by Daniel Kamil Kozar
Modified: 2014-06-26 11:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Example program for illustrating the bug (1.34 KB, text/x-csrc)
2014-04-24 11:36 UTC, Daniel Kamil Kozar
Details
Proposed patch for the issue (2.54 KB, patch)
2014-04-24 11:37 UTC, Daniel Kamil Kozar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Kamil Kozar 2014-04-24 11:35:53 UTC
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.
Comment 1 Daniel Kamil Kozar 2014-04-24 11:36:45 UTC
Created attachment 86244 [details]
Example program for illustrating the bug

Gets information about /dev/sr0 via the INQUIRY command.
Comment 2 Daniel Kamil Kozar 2014-04-24 11:37:29 UTC
Created attachment 86245 [details]
Proposed patch for the issue
Comment 3 Tom Hughes 2014-06-26 11:30:46 UTC
Committed, with minor changes, as r14107.