Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1282895rwb; Wed, 16 Nov 2022 15:09:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hzUCXMRVYsO6h9HObZJ7yKU7hit0bMXLWbOFtHkykRSIfHSMjKsuYmxgW7z09ZzO7OQNo X-Received: by 2002:a17:902:ba91:b0:186:c958:6cd8 with SMTP id k17-20020a170902ba9100b00186c9586cd8mr10893623pls.145.1668640191373; Wed, 16 Nov 2022 15:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668640191; cv=none; d=google.com; s=arc-20160816; b=cwA2lmUyaPVXOoxrAeLQPbOmxyaAiJUlkzaYC1o0KUDGH3GEajAAJwqu0ZAd97Ir3d WCH+IjGvRUsxl85lIXyxpdrVomvHRJJ9pukZLcMAi2quWSxqqyEbhK6oqfy8u0QVMRur We6yBpuAS55BNbCw7yyjoESk873jRE29Z6ZRXSwBAomKdoDfg51KnUtb49XaDddAzglr mMf9Ncbxqk74Z+PkEqwnxLrs5PIyS05n8AndCuNREaeecoEWOll72+rdaZYftY3Uc25j yeM1vEcVxit1F6aoWpmsvHePWCrv8FaljytqJacocwF0SfuefLAdjgnlDzhYKbGSEcI9 q6tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=zrQp7+2pkRHlH6THsLP5UDb+ps1i6IqB33fhLPEz4Eg=; b=YHarfZLDGv/BoFE53BPYc6qNeAK+GJS9PwHDeEaMcjHG2T0SgWsvVioPhXsDJKjdSg KO1ufiBy6Oh6TWQn0B8C9/xXSWd3Osd9Hpi6kJZThlesamzY3z7UlDb9GmLQBLbWUorm C+wM+c7HVWWtAaSzm68OQ6jv41tze+SngpzQILzvkXCLMvMoBQ9GkJug1Sfo0jAKHl8g mNo4J0bQUOkwve3+JmteZHy4O4NZklRnCAsQmv68bXGvwM/RLraMuA/PUckBslx+pm5t sW2v5URk1bLqJ8TkBw8WKN+VNznZFJOsrs2DvhHcBU228szOPbwa4FVGdM/gaxIhSvmu b5Ag== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a634705000000b00476e3bb2334si3368393pga.452.2022.11.16.15.09.40; Wed, 16 Nov 2022 15:09:51 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbiKPWkT convert rfc822-to-8bit (ORCPT + 90 others); Wed, 16 Nov 2022 17:40:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbiKPWkQ (ORCPT ); Wed, 16 Nov 2022 17:40:16 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C439FB7E3 for ; Wed, 16 Nov 2022 14:40:13 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-43-QmRQHnZtPD-f-gfapKz2sw-1; Wed, 16 Nov 2022 22:40:10 +0000 X-MC-Unique: QmRQHnZtPD-f-gfapKz2sw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 16 Nov 2022 22:40:09 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.044; Wed, 16 Nov 2022 22:40:09 +0000 From: David Laight To: "'Kirill A. Shutemov'" , "kirill@shutemov.name" CC: "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() Thread-Topic: [PATCH 1/2] scsi: Fix get_user() in call sg_scsi_ioctl() Thread-Index: AQHY+VSNJhar89N50E24WEBG2HeXiK5CJcRg Date: Wed, 16 Nov 2022 22:40:09 +0000 Message-ID: <9d59ec367e0445028775d304bcf64704@AcuMS.aculab.com> References: <20221115155802.p3vjnk7eqqcyskt3@box.shutemov.name> <20221116004353.15052-1-kirill.shutemov@linux.intel.com> <20221116004353.15052-2-kirill.shutemov@linux.intel.com> In-Reply-To: <20221116004353.15052-2-kirill.shutemov@linux.intel.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 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. David > return -EFAULT; > > bytes = max(in_len, out_len); > -- > 2.38.0 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)