Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3160043rwb; Fri, 11 Nov 2022 23:47:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7T2No2f8jrOEdVgCK/aoptwI+jYggm81lFow5mVnqzw3a+6FrBo1xDXzE0BuiaHRJaDMJw X-Received: by 2002:a63:f158:0:b0:43c:2e57:9636 with SMTP id o24-20020a63f158000000b0043c2e579636mr4616540pgk.81.1668239228742; Fri, 11 Nov 2022 23:47:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668239228; cv=none; d=google.com; s=arc-20160816; b=wqYaINVGJ15ljVNAWR3pjWp1NSxxvWPJFjhn0OJI0xayGFLWD7gkHe31z9EE2rqst+ 5PgqeST21Di81uFWm59bpC9SarAu2m/KAKeQYpQmUV1kUCZoMQfdEPTGI6rNltzkr6QZ 7DiPTgV0hU2TImUhtRRYTsYVTqjf3bSKHXdemmO/9mpn1dnsoF9qxBeUbGbMOJ0StRZi MXx0rakNcvqG7/HGO8RAyET5bRpknQ5yWqs643J+yeFkplI8nPrmEqEDyq/vmFkls3xL 8K1IlzfQcKZLUj0OqM4R9UMZaSHegiMDNNjkdelKLLRJcX1Wu6jESDVKKL/V8ApDYYfO YEKA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a170903230700b00186b59eba21si5565788plh.574.2022.11.11.23.46.54; Fri, 11 Nov 2022 23:47:08 -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 + 91 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 Content-Transfer-Encoding: 8bit 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 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); -- 2.38.1