From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEF63C3A5A1 for ; Thu, 29 Aug 2019 02:27:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1BB322CF5 for ; Thu, 29 Aug 2019 02:27:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727383AbfH2C1i (ORCPT ); Wed, 28 Aug 2019 22:27:38 -0400 Received: from smtp.infotech.no ([82.134.31.41]:40169 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727376AbfH2C1i (ORCPT ); Wed, 28 Aug 2019 22:27:38 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 3BF55204238; Thu, 29 Aug 2019 04:27:37 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hsrtMPC9MNm9; Thu, 29 Aug 2019 04:27:35 +0200 (CEST) Received: from xtwo70.bingwo.ca (host-23-251-188-50.dyn.295.ca [23.251.188.50]) by smtp.infotech.no (Postfix) with ESMTPA id 7857620423A; Thu, 29 Aug 2019 04:27:34 +0200 (CEST) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, bvanassche@acm.org, hch@infradead.org Subject: [PATCH v4 21/22] sg: warn v3 write system call users Date: Wed, 28 Aug 2019 22:26:58 -0400 Message-Id: <20190829022659.23130-22-dgilbert@interlog.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829022659.23130-1-dgilbert@interlog.com> References: <20190829022659.23130-1-dgilbert@interlog.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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) instead. 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 simple. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 2620f4079474..9b320a46f024 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -619,6 +619,9 @@ sg_write(struct file *filp, const char __user *p, size_t count, loff_t *ppos) __func__); return -EPERM; } + WARN_ONCE(true, "Please use %s instead of write(),\n%s\n", + "ioctl(SG_SUBMIT_V3)", + " See: http://sg.danny.cz/sg/sg_v40.html"); memcpy(h3p, ohp, SZ_SG_HEADER); if (__copy_from_user(h3u8p + SZ_SG_HEADER, p + SZ_SG_HEADER, SZ_SG_IO_HDR - SZ_SG_HEADER)) -- 2.23.0