From patchwork Sat Nov 12 07:00:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshit Mogalapalli X-Patchwork-Id: 19119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1152700wru; Fri, 11 Nov 2022 23:14:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5e1Avo3Sz4eoeaIx9UReSwnMNfnvbQaDAyby1qPRVI3iN3EZ5KWJooodeOjT1GluJsrweB X-Received: by 2002:a17:906:ad98:b0:7a1:e4c2:fb0a with SMTP id la24-20020a170906ad9800b007a1e4c2fb0amr4579526ejb.101.1668237277452; Fri, 11 Nov 2022 23:14:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668237277; cv=none; d=google.com; s=arc-20160816; b=iEntWatH+FSq2rb0JcKs0opP4ZN8NJSEIKOIFZNUaO95RK0Yu1fLaXELmxkqxqtmF5 rk6sg5RuJltS7qoHJYEQnihMG9jY7uhMw1uLYaJ34i+RSz2DwNdt6bNIFzFkO3EM3ezF NhVsnFxQ8pOuRlut0MinQ9BqHjs3US3RYpXCxE2gPfljXTMRfsnksvOCeuWoIavuYZeB uRVsWyCDtzbnrwsUrq1bJ6iq6dU1gbFd0fldaq6u9TvfeoirntckjCKESlH6Nhq064g4 PFpgluEItL6cw1WwzF/l8pI4q5/Av6R3vIkQPYhUT0EI0ORYVKeiPy+lFzDpW95ZuZ6/ 0Hpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=gDZ6MG+tnirLjij+RM1xUgF3hdmZdeFJrSWDvS2APYA=; b=aT3BIjpRoBPiLP1liFevzH1e1T+HSbohvl/1/bgnUW8ZvTV2HrqnlHsXVznqHnChfh /mwArCw4/SSS+KKh9pHySDZ/ZiXmkn73rsWCHEcmmt1PU5amS3hUEV5c/1Nb3avJO01m aiJDnYt/trq6qYDey7PWHFFppb36BvmhCI5sqbCHUL+xhvk6wDEt46V82jxGaaJMQhXb b25OuYL53zSAfd5Wy4jaNqHcJl6+hVsmwIZGdEuEbwWIfgGMJzuH3V6qSZUfKCq/yVsL A+FtWwDeVUp+O5nA7Zr+9LnReObJ/xFXPq9R3UjAso/EXQ0CZGW+fPOF+NGwqYcbqUOo +ngg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=LOInsb7q; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m27-20020a50d7db000000b00458ab55ccc9si4321670edj.168.2022.11.11.23.14.10; Fri, 11 Nov 2022 23:14:37 -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=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=LOInsb7q; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234624AbiKLHN4 (ORCPT + 99 others); Sat, 12 Nov 2022 02:13:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbiKLHNy (ORCPT ); Sat, 12 Nov 2022 02:13:54 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B14511583B; Fri, 11 Nov 2022 23:13:51 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2AC7BZft030768; Sat, 12 Nov 2022 07:13:46 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=gDZ6MG+tnirLjij+RM1xUgF3hdmZdeFJrSWDvS2APYA=; b=LOInsb7qXb1FpC2Phhs6Cp1jyZxX4lh98vHNv7oSfIgKMYDsKOesYjpB9/7vURyTTDns Ft6ABtaDFSVKxEZu+Gktigxn5hJq4upDT531RckV2fG1OcI21clx+HG16rGJ66Cwqy8C VW6dX2aueTLKiluxHVqWEGzDDGm+LQObD4H/Ta99WZwZONHKwdU3uCeSbU8fTLW1SC+S 2LjbAIhGj9q5BwvSkxc0Q+/LDCv1zMxaMYmx0br7yFtESoZc7EGmAgJ8wYKWwmUj7B7q hQbdBQWyvvhrQgf4GtLoPl4Rfp4kWxT42DhzfU9ancP/GF+nSEqOtkabN7dW1gWReoQ2 NQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kt6vjr03f-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Nov 2022 07:13:46 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AC4S1qM038037; Sat, 12 Nov 2022 07:00:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1x25jx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 12 Nov 2022 07:00:44 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AC70hSS012960; Sat, 12 Nov 2022 07:00:43 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3kt1x25jwk-1; Sat, 12 Nov 2022 07:00:43 +0000 From: Harshit Mogalapalli Cc: harshit.m.mogalapalli@oracle.com, error27@gmail.com, harshit.m.mogalapalli@gmail.com, "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Douglas Gilbert , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: scsi_debug: Fix a warning in resp_verify() Date: Fri, 11 Nov 2022 23:00:31 -0800 Message-Id: <20221112070031.2121068-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 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211120051 X-Proofpoint-GUID: er5ZAZG1nXXdrbj9x89ZZyO--BBTB1dU X-Proofpoint-ORIG-GUID: er5ZAZG1nXXdrbj9x89ZZyO--BBTB1dU 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 To: unlisted-recipients:; (no To-header on input) 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?1749273571468813820?= X-GMAIL-MSGID: =?utf-8?q?1749273571468813820?= As 'vnum' is controlled by user, so 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: c3e2fe9222d4 ("scsi: scsi_debug: Implement VERIFY(10), add VERIFY(16)") 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..cbb9395c90c1 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4429,7 +4429,7 @@ static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) if (ret) return ret; - arr = kcalloc(lb_size, vnum, GFP_ATOMIC); + arr = kcalloc(lb_size, vnum, GFP_ATOMIC | __GFP_NOWARN); if (!arr) { mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, INSUFF_RES_ASCQ);