Don't export scsi kernel variables in userspace headers.
PATCH 1/1 Don't export scsi kernel variables in userspace headers.
Found with make headers_check
/usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel /usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel
include/scsi/scsi.h +4 -0
@@ -156,7 +156,9 @@ scsi_varlen_cdb_length(const void *hdr)return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length +8 ; } +#ifdef __KERNEL__extern const unsigned char scsi_command_size_tbl[8 ]; +#endif #define COMMAND_SIZE (opcode) scsi_command_size_tbl[((opcode) >> 5) & 7] static inline unsigned
@@ -281,8 +283,10 @@ enum scsi_protocol { SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */ }; +#ifdef __KERNEL__/* Returns a human-readable name for the device */ extern const char *scsi_device_type (unsigned type); +#endif /* * standard mode-select header prepended to all mode-select commands
include/scsi/scsi.h scsi_varlen_cdb_length(const void *hdr) · line 164
Quoted 11 lines · Dave Jones
+++
b/include/scsi/scsi.hinclude/scsi/scsi.h +2
-0@@ -156,7 +156,9 @@ scsi_varlen_cdb_length(const void *hdr)return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length +8 ; } +#ifdef __KERNEL__extern const unsigned char scsi_command_size_tbl[8 ]; +#endif #define COMMAND_SIZE (opcode) scsi_command_size_tbl[((opcode) >> 5) & 7] static inline unsigned
Probably should move that #endif down -- it's not like userspace can use the COMMAND_SIZE macro (should headers_check also check for this?)
Also scsi_command_size() isn't usable by userspace either, since it uses COMMAND_SIZE.
Signature · 4 lines
Matthew Wilcox Intel Open Source Technology Centre "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."
Quoted 4 lines · Dave Jones
Found with make
headers_check
/usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel/usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel
The headers shouldn't be exported at all because scsi/ headers are exported from glibc.
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Dave Jones
Found with make
headers_check
/usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel/usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernelThe headers shouldn't be exported at all because scsi/ headers are exported from glibc.
Where does glibc get these headers from?
If glibc have their own private copy then the headers should indeed be exported so we avoid such mess.
Sam
Quoted 6 lines · Sam Ravnborg
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Dave Jones
Found with make
headers_check
/usr/include/scsi/scsi.h:159: userspace cannot call function or variable defined in the kernel/usr/include/scsi/scsi.h:285: userspace cannot call function or variable defined in the kernel
Quoted 8 lines
Quoted 2 lines
The headers shouldn't be exported at all because scsi/ headers are exported from glibc.
Where does glibc get these headers from?
If glibc have their own private copy then the headers should indeed be exported so we avoid such mess.
Sam
We never had a Kbuild file in include/scsi. It was only added recently by the fcoe patchset. scsi.h is not the only problem. All of /usr/include/scsi/* come from glibc private snapshot.
I agree with Sam that this is a complete mess, and that Kernel should take control back. But someone should do it in an orderly manner. Clean up all the headers to be safe for user mode and send notifications/patches to glibc, and the distributions must know that they might be geting same files from two packages for a while.
Would we want a Kconfig option for a while, like SCSI_EXPORT_HEADERS so it can be turned off?
Boaz