Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1351514rwb; Wed, 16 Nov 2022 16:24:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf5BcJJWeXJsW/+xENKeg+PjLIXPiqmMTxEe07Vf2cwrV0zToGbFV9OUyLmH1g8ETJeBkb1R X-Received: by 2002:aa7:d915:0:b0:463:69bc:c574 with SMTP id a21-20020aa7d915000000b0046369bcc574mr142009edr.120.1668644639892; Wed, 16 Nov 2022 16:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668644639; cv=none; d=google.com; s=arc-20160816; b=Mrk5/+BbknUulNrctuEL/lgHYF1caenZwe1Z5uZ/25ss7CRbPqPkURYgwHVTqdw5+w iGVbPzbV9sNY+1qSLmMJU/Sc9XkqDiPT5JtH6hEkynqEULeA2pcDCjD70f4VD/ulXq+W IN2UdM8klj2I+tYrKvWYSrebimF+M1yOn2S0cGr6WWYqsevUIu/HeAsRwv/9cScKmvjT +oS8qZu6hnVDvmzR7ogfHF1uKBu8mmElUSzu/DRw5NCaJYTtEds2lDyyOmAwEsIhaSXZ CRB7oH3g2CCThq+0rrDbcEqW0WS5sIRkCPTgxo1oWm4jpZMHzveZhGsaF37uOq6JHihf vLyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=fA1G1agOd4tHqccYBlA7Bq+qNCuLfCAeIRRO5CED94M=; b=iX7HT3XwrapJVWGYVvbdAU+eGLZhSPu9hHtwFkwo7bYs+BjSG3E0wO/6DBicEyNLqc t434lAFjuCXa9Wh2F437FHpiERUiWQjLkTGklFe+MCWS4XmTNLGe5m5OkY1Yz54mU9iC WLtB+hk53pijvhCdnuPDw8coWZk4oOOKeemu/4fKXgV8MTrgvY2+mwr+r11rOwbm31LR 4lA13qlTOQ4nbCWcBmiYkUTHIcNyZI3IGXHscDV4No3NuOFAhrR8qlhQvVL/yivuNJma Nr1PgcoVKzEOrKPc3Bf8bj8DZeMgE1l1iMcaMBeII+DNgU5djG6UMucUdO3L9N8NcLm5 jmBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=IHE7vFF6; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=apCfJsKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a056402274200b0045cd68a2bc5si10019260edd.17.2022.11.16.16.23.38; Wed, 16 Nov 2022 16:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=IHE7vFF6; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=apCfJsKW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234037AbiKQADv (ORCPT + 90 others); Wed, 16 Nov 2022 19:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233394AbiKQADn (ORCPT ); Wed, 16 Nov 2022 19:03:43 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE206459 for ; Wed, 16 Nov 2022 16:03:34 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 65B5632009ED; Wed, 16 Nov 2022 19:03:33 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 16 Nov 2022 19:03:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1668643413; x=1668729813; bh=fA 1G1agOd4tHqccYBlA7Bq+qNCuLfCAeIRRO5CED94M=; b=IHE7vFF6zvU/JEka24 FhOIlZlJ+5dsXnFUePG0scfb59SUKZvHrXHQLoMJrew8Bv9yPQkpheeWuKAdqjtz w3owWzQIKLTIzz8VWoZvVqb/YvRC5+mfeXNJEqs9w/H3RMA3fst1EKtUwiUCwI0+ KGt2iZOlI21YG40AIIlVoY+n3LeJLyjq3SNE6CZe52J9eDHwEKerVbfFI6sO8s+i mESJLzTrUkfpBLutF7UAezepdmNfvTPJ1cxkYKeWFFmzzgZbdWq8/odYH4GyhhFp e5+Dp0uRBlEy1kmTSLN3HhrSfG2MHVP9fMUG2SoOoQigqf2lp6eFFK3bPI8S8a1E OITA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1668643413; x=1668729813; bh=fA1G1agOd4tHqccYBlA7Bq+qNCuL fCAeIRRO5CED94M=; b=apCfJsKWe7QbiFHkpkjdleY5YhwuSTIvDQYK6GcQBRsS fpCaDDfi/eEVBAzAk7OQKJzGNM3MZ1lDVbUCK1AyCrmMyiIg0dLMPZhNDRFa7khi OJdGQlfFRzf0s/cov01mzV6TttUkV/26QFXCyMnjZwA5ExoUu5ITfM8vVUY6dvfg R3hSlveaEeLL3I3P6xeb1MTMqxadTygho9YhcnSLo7hZ1zuPhIRnPxgCmrMNFYtj VbSyfiEm4rTalRs5JfS34/FUrxGkszsmdgRx1w5T68PmJZgFCYjKyOTWjgkz7k5W B+6OeQzAFslNbco7LWxAsO+UlWU9WSr2RJre/zRSzQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgeejgddukecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfkhhirhhi lhhlsehshhhuthgvmhhovhdrnhgrmhgvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrd hnrghmvgeqnecuggftrfgrthhtvghrnhepvdejhfegffetveevieevhfeuuefhleelteei ueffledtteeuveetfeeuheethffhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 16 Nov 2022 19:03:31 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 15A93109702; Thu, 17 Nov 2022 03:03:30 +0300 (+03) Date: Thu, 17 Nov 2022 03:03:30 +0300 From: "kirill@shutemov.name" To: David Laight Cc: "'Kirill A. Shutemov'" , "dave.hansen@intel.com" , "dave.hansen@linux.intel.com" , "jejb@linux.ibm.com" , "linux-kernel@vger.kernel.org" , "lkp@intel.com" , "martin.petersen@oracle.com" , "oe-kbuild-all@lists.linux.dev" , "x86@kernel.org" Subject: Re: [PATCH 1/2] scsi: Fix get_user() in call sg_scsi_ioctl() Message-ID: <20221117000330.up7qwxjnrtb3u2ll@box.shutemov.name> References: <20221115155802.p3vjnk7eqqcyskt3@box.shutemov.name> <20221116004353.15052-1-kirill.shutemov@linux.intel.com> <20221116004353.15052-2-kirill.shutemov@linux.intel.com> <9d59ec367e0445028775d304bcf64704@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9d59ec367e0445028775d304bcf64704@AcuMS.aculab.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 16, 2022 at 10:40:09PM +0000, David Laight wrote: > From: Kirill A. Shutemov > > Sent: 16 November 2022 00:44 > > > > get_user() expects the pointer to be pointer-to-simple-variable type, > > but sic->data is array of 'unsigned char'. It violates get_user() > > contracts. > > > > Cast it explicitly to 'unsigned char __user *'. It matches current > > behaviour. > > > > This is preparation for fixing sparse warnings caused by Linear Address > > Masking patchset. > > > > Signed-off-by: Kirill A. Shutemov > > Cc: "James E.J. Bottomley" > > Cc: "Martin K. Petersen" > > --- > > drivers/scsi/scsi_ioctl.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c > > index 2d20da55fb64..72b3ab5137b8 100644 > > --- a/drivers/scsi/scsi_ioctl.c > > +++ b/drivers/scsi/scsi_ioctl.c > > @@ -519,7 +519,7 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode, > > return -EFAULT; > > if (in_len > PAGE_SIZE || out_len > PAGE_SIZE) > > return -EINVAL; > > - if (get_user(opcode, sic->data)) > > + if (get_user(opcode, (unsigned char __user *)sic->data)) > > Using &sic->data[0] should work and is much nicer than the cast. Okay. Fair enough. Adjusted patch is below. From 86baed963c9295c067940479ab0f844c3644e1c9 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Wed, 16 Nov 2022 03:22:28 +0300 Subject: [PATCHv2 1/2] scsi: Fix get_user() in call sg_scsi_ioctl() get_user() expects the pointer to be pointer-to-simple-variable type, but sic->data is array of 'unsigned char'. It violates get_user() contracts. Explicitly take pointer to the first element of the array. It matches current behaviour. This is preparation for fixing sparse warnings caused by Linear Address Masking patchset. Signed-off-by: Kirill A. Shutemov Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" --- drivers/scsi/scsi_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 2d20da55fb64..fdd47565a311 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -519,7 +519,7 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode, return -EFAULT; if (in_len > PAGE_SIZE || out_len > PAGE_SIZE) return -EINVAL; - if (get_user(opcode, sic->data)) + if (get_user(opcode, &sic->data[0])) return -EFAULT; bytes = max(in_len, out_len); -- Kiryl Shutsemau / Kirill A. Shutemov