From patchwork Sat Nov 26 03:59:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshit Mogalapalli X-Patchwork-Id: 26183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4446162wrr; Fri, 25 Nov 2022 20:03:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Kv3WCUzW0e62GgVE9U3Gg3l7TBT4PCmGQg/twSYLdaDIhzf9S3vttHAP/gE8CPMxVk5Fa X-Received: by 2002:a17:90b:46ca:b0:212:ce2d:9fd7 with SMTP id jx10-20020a17090b46ca00b00212ce2d9fd7mr44418205pjb.157.1669435407321; Fri, 25 Nov 2022 20:03:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669435407; cv=none; d=google.com; s=arc-20160816; b=p+V1U+7RNMQpyoKslGmEZgqcEnQe3E9AfFyxS49o90WIO5NjdWsCGxxWmKk1iaMn3J nL9e/w6kitU20HDq4sEphCONFjlbSVdzuuWi0vYUkhkyEgxMEFeGZMCfVKwCL4+NdtfZ 3TKEKb8NVHuKq3lUu/iVKf4JBj7kXIrFHFySzefdhyeOD3uFuR7Y48g8q1DFoDucXjAg 5qhmeEmdT0SzMlKTCRVba38Dnngu50hg4GiBsiBda2iWz7YOaw0ezDhaUU4rmHdYIBlY Ou/HbYH19IYueAmZjrvJPxreXQbKVTrx/kqzyHKsXYXu29DfBWR3nkDykNZ7FDH6VXfJ FeqA== 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=86FpH3oiEaRToGTOfAbl1a68NK0H++B6xU/ccV5PssI=; b=mwSToTzoZwdIg2mzIPllwMETko0va/BxYeZJ5pHLXp5w81jgRgZv1qvPLUKZr4Zxhq h1LPet8VrL4Duk6Sx7XA6hHmP01B4nrr+dnjkXR9b7bbe3Kmj6OSQClY+XYljJ00+7GV dha0QKbPPRjB1NCc6ulR+Oxhxu1vVa28mIYzsHUN9J1V0moDhCnjB1AOEm5eR6+oeR3v M52eDL8fNMX6r6OFuGRvhyhB1yW066UHKJ1yfSTkK25eEkkL/QN+SM6ZQsOf8wckV8Mc 1vHTmRjWUB5FYkQZN5fAxizmWr5L07lsUjjwDOh59OcyHH+ZQPcue+ZSnEXb1U0/bMuR E4/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b=SxijZMQU; 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 g24-20020a63fa58000000b0044b5e15db73si4739884pgk.249.2022.11.25.20.03.11; Fri, 25 Nov 2022 20:03:27 -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=SxijZMQU; 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 S229810AbiKZEAh (ORCPT + 99 others); Fri, 25 Nov 2022 23:00:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiKZEAf (ORCPT ); Fri, 25 Nov 2022 23:00:35 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8863C2CCB7 for ; Fri, 25 Nov 2022 20:00:33 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AQ390WW005777; Sat, 26 Nov 2022 04:00:23 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=86FpH3oiEaRToGTOfAbl1a68NK0H++B6xU/ccV5PssI=; b=SxijZMQUN0pbxslbw01JRRVyFEhksxWOUlSz8H62yoDjPN8gGBidEwFqNSNssg98+muA ESVjwVx5mzPo3gXvG9eBAlNP1EXJs7TKqz8T8s6Ie+LkHT0PVTQpDB9vWSS7uLYVyQ27 Y3bGx87XgUIR124JSiX1shSmPqkErCNiETThLaRwm7aO+E9qFI7A/JxIWdXmWPczTHjh n78ewfLrptFViNxAH/NkC0roECjR3rz8x8jnahkhMLOfVgS6EOvNmsyD+VpQEXvK7b8o NSFO6GwBNc4cflBSi4sv/tQaOj48PxrmF6jPYxcBhp1l8dHVFmWG78JWBHpQn7gS5/UC qQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m39dfr2d6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 26 Nov 2022 04:00:22 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AQ1XkV4007555; Sat, 26 Nov 2022 04:00:21 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m3988c6pa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 26 Nov 2022 04:00:21 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AQ40KIw039282; Sat, 26 Nov 2022 04:00:20 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3m3988c6jw-1; Sat, 26 Nov 2022 04:00:20 +0000 From: Harshit Mogalapalli Cc: harshit.m.mogalapalli@oracle.com, error27@gmail.com, harshit.m.mogalapalli@gmail.com, "Michael S. Tsirkin" , Jason Wang , Xie Yongji , Gautam Dawar , Maxime Coquelin , Guanjun , Parav Pandit , Eli Cohen , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] vduse: Fix a possible warning in vduse_create_dev() Date: Fri, 25 Nov 2022 19:59:58 -0800 Message-Id: <20221126040000.775914-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-26_02,2022-11-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211260029 X-Proofpoint-ORIG-GUID: _Sfm4z2GCsIcp460MDMbNp7fhdcBRdKI X-Proofpoint-GUID: _Sfm4z2GCsIcp460MDMbNp7fhdcBRdKI 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?1750529901577399249?= X-GMAIL-MSGID: =?utf-8?q?1750529901577399249?= As 'dev->vq_num' 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. Call trace: -> vduse_ioctl --> vduse_create_dev 'config->vq_num' is user data as it comes from ioctl, which is assigned to 'dev->vq_num'. Add __GFP_NOWARN in order to avoid too large allocation warning. This is detected by static analysis using smatch. Fixes: c8a6153b6c59 ("vduse: Introduce VDUSE - vDPA Device in Userspace") Signed-off-by: Harshit Mogalapalli --- drivers/vdpa/vdpa_user/vduse_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index 35dceee3ed56..5e9546b16165 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1512,7 +1512,8 @@ static int vduse_create_dev(struct vduse_dev_config *config, dev->config_size = config->config_size; dev->vq_align = config->vq_align; dev->vq_num = config->vq_num; - dev->vqs = kcalloc(dev->vq_num, sizeof(*dev->vqs), GFP_KERNEL); + dev->vqs = kcalloc(dev->vq_num, sizeof(*dev->vqs), + GFP_KERNEL | __GFP_NOWARN); if (!dev->vqs) goto err_vqs;