diff mbox series

[v17,38/45] sg: warn v3 write system call users

Message ID 20210408014531.248890-39-dgilbert@interlog.com (mailing list archive)
State Deferred
Headers show
Series sg: add v4 interface | expand

Commit Message

Douglas Gilbert April 8, 2021, 1:45 a.m. UTC
Should generate one log message per kernel run when the write()
system call is used with the sg interface version 3. Due to
security concerns suggest that they use ioctl(SG_SUBMIT_v3)

Sg interface version 1 or 2 based code may also be calling
write() in this context. There is no easy solution for them
(short of upgrading their interface to version 3 or 4), so
don't produce a warning suggesting the conversion will be

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
 drivers/scsi/sg.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series


diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index dbb74e409a9c..fad396a3c4e7 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -644,6 +644,9 @@  sg_write(struct file *filp, const char __user *p, size_t count, loff_t *ppos)
 			return -EPERM;
+		pr_warn_once("Please use %s instead of write(),\n%s\n",
+			     "ioctl(SG_SUBMIT_V3)",
+			     "  See: http://sg.danny.cz/sg/sg_v40.html");
 		res = sg_v3_submit(filp, sfp, h3p, false, NULL);
 		return res < 0 ? res : (int)count;