From patchwork Sat Nov 12 07:06:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshit Mogalapalli X-Patchwork-Id: 19120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1158264wru; Fri, 11 Nov 2022 23:34:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6oGwbOHod9GaxLpXGT2/qMkKY6Em0hj0GThnEnXivTGrwkhkPvZ+Aj21fBJndRWG2n+qCH X-Received: by 2002:a05:6402:5383:b0:461:f919:caa4 with SMTP id ew3-20020a056402538300b00461f919caa4mr4550566edb.255.1668238458269; Fri, 11 Nov 2022 23:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668238458; cv=none; d=google.com; s=arc-20160816; b=sVxO+CUkntUSHJZZU+URtTyA3muEwjJZxmz4Zwbq3BuCEQEjDTcnmAe702XL3Tmq// 0c11EbDHBDp10ZwlpoyhhR/msIW7iSsKEs2c9sZriw5d/I4OZ0kQV6j5BcIVhBZQ4k7T FniwSeZfHq4aczAsZ7UJsluO4j+u7Bqtx05Ul0IezhdUDyb8X2ghXuw6zMZwlnSUZNRR sIfJDVrd2tjJEQ9brroEnBvC8o06EKgYziYOZiI7zyZktjmk6UDtol8Woybhbg4y864w kRuo9QZK8D74hbxVOeqEsBun27OOyhPLMkO+e4WUkwPrCH7jEBlVk9mJfm9ehOxw4ByU CyaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=O5eQWbpi3e77WheOqQeo0/5EkDQPAdr9NCVnmyUSMMw=; b=rl0CoLz4sDoFmTD36b6K5yAIjl0fOqc+3Xf4YWLXUjVqwj1ZYRJRZe5tdY66+cICWr eJ2n1BY4eZSGgIjku3yTyGaVUr/Hbllx3Xw19hZt13/f2ZxoSRz6kc8ThVqu0A/mGvS2 36LVoy+lTUtDlUVARChR4mTNC625LywDbjtTwjWrONhRyqEs+6m58r7ap10vPUBiSZBn pJbIEa86OnKj+CQSayEygZLqnV4woqGOKMxJcH/+tfWcAi4aMkhoHQWvTMVbDIJwN/+e NAAT+/qUUs+YzeYLjEpNjR9jqx7oFBERPsoC1o6e8u17J8cOh68mmf+n16Dcu2kwc7FT vhJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=u1qHbcuo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a50d0c5000000b00448d387c327si3956700edf.181.2022.11.11.23.33.48; Fri, 11 Nov 2022 23:34:18 -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=@oracle.com header.s=corp-2022-7-12 header.b=u1qHbcuo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234548AbiKLH1b (ORCPT + 99 others); Sat, 12 Nov 2022 02:27:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbiKLH13 (ORCPT ); Sat, 12 Nov 2022 02:27:29 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 067412715D; Fri, 11 Nov 2022 23:27:28 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2AC7DF4B001417; Sat, 12 Nov 2022 07:27:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=O5eQWbpi3e77WheOqQeo0/5EkDQPAdr9NCVnmyUSMMw=; b=u1qHbcuowLm51PF3kDbw96xfrsGXh1vjwytFRFjLv4OA+BnueGNCCvddlE9vFLOh36OL lSMC35WkI+EkGzBJjIKCIySe6HSZ6wq40Y/wjwL5x3kHDBEKmJFhFXDrQtYyToa/RXNR GsiMvaFaQUyWV18THhu7jGZtcYF6cTk7CPB3D1q8ApUs96VdvyxAo7grPHc3bfeBkJ9N V+tKN71JvSmflrUGfQRfQ0pqPS2OzPeAc/4XlN6QE9kFFgbA3fjL2SNwX1PWRcZVZLTV Kh1Ui2cDJVKkx9IY5D5OfvuoSAjP+TDzs0X975aUoF5pkLQuw9eh/9X9F9ixe0iV+OFb 6w== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kt6w7g0cm-28 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Nov 2022 07:27:25 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AC4Rx2g020662; Sat, 12 Nov 2022 07:06:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1x8e00c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Nov 2022 07:06:20 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AC74eXT002475; Sat, 12 Nov 2022 07:06:20 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3kt1x8dyyq-1; Sat, 12 Nov 2022 07:06:20 +0000 From: Harshit Mogalapalli To: dgilbert@interlog.com Cc: harshit.m.mogalapalli@oracle.com, error27@gmail.com, harshit.m.mogalapalli@gmail.com, "James E.J. Bottomley" , "Martin K. Petersen" , Damien Le Moal , "Shin'ichiro Kawasaki" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: scsi_debug: Fix a warning in resp_report_zones() Date: Fri, 11 Nov 2022 23:06:12 -0800 Message-Id: <20221112070612.2121535-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-12_04,2022-11-11_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211120052 X-Proofpoint-GUID: _-QZLeS_QsXhNYb9UiRvH303FBZ5kin_ X-Proofpoint-ORIG-GUID: _-QZLeS_QsXhNYb9UiRvH303FBZ5kin_ X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749274809338029955?= X-GMAIL-MSGID: =?utf-8?q?1749274809338029955?= As 'alloc_len' is user controlled data, if user tries to allocate memory larger than(>=) MAX_ORDER, then kcalloc() will fail, it creates a stack trace and messes up dmesg with a warning. Add __GFP_NOWARN in order to avoid too large allocation warning. This is detected by static analysis using smatch. Fixes: 7db0e0c8190a ("scsi: scsi_debug: Fix buffer size of REPORT ZONES command") Signed-off-by: Harshit Mogalapalli --- drivers/scsi/scsi_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 697fc57bc711..eaa726654be2 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4497,7 +4497,7 @@ static int resp_report_zones(struct scsi_cmnd *scp, rep_max_zones = (alloc_len - 64) >> ilog2(RZONES_DESC_HD); - arr = kzalloc(alloc_len, GFP_ATOMIC); + arr = kzalloc(alloc_len, GFP_ATOMIC | __GFP_NOWARN); if (!arr) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ);