Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11732986rwb; Fri, 25 Nov 2022 21:21:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf5A/Ek80B+Vr0j7UzSTLQ4aaJYgd0ukY/9uwZ94W8Kf5pb87KH0htWqszjDRSaxluTlWwgL X-Received: by 2002:a05:6a00:15d1:b0:572:4ea6:ddc7 with SMTP id o17-20020a056a0015d100b005724ea6ddc7mr22043062pfu.26.1669440095968; Fri, 25 Nov 2022 21:21:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669440095; cv=none; d=google.com; s=arc-20160816; b=OdDFY1JNOIlpviLO3waXPec37nxntE8+jw5v3T4hUDTHfodY5VZ9NgOcBIkz8jDw0b T4yGwXDz0sLTkSihBF5C4a6pJVEiM5XT+xBN1EwpUYB3aQXbToNIhfd7+vpx+qNuiFPm ZkK/o3getfKYOrEOR5WjXsetH9PjTa/o/EwAzVNg31iFOdIJo9NE8bI9MmZKslTHoZFa WI+68g7teE56x0TBOTiadlZDDhb7NaWC56xovflCsVD3mVZxGQdqioLOoNoODJIG72/S aTXdTMC8E26LDU5ul+F/z+Bi8SNcB0MwxLlhPqutP5fZp/DCQbTriSqPg6mYWwtAKyCi /vfQ== 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=hEdmssi73mdZJZby6VH83OA2wc6mC+NgmIbVOzmV8+8=; b=dqc0Ta9nwnE4JU+VFcEVN8PE6ASAgBTbdiRu5snEKeTX4a+mksvU9t6zTIaL/G+OxC 5x+knH/TNQM+WwHJLU6DdaR/6fipOKlCZBK5DPkDITNJr6WUITFjWHSorO9E8zvfOjCg LjceGGA5Xe8RSL/IBmITht5qC5IQuwtpWlwodrJnvIHyqN6K7a6oyZII7jVgQn0b8aDy TUqFUx7fbp7zVW2Ahy3bOlMIbd27ws6T1VNmL1U5TA9WUsHsjN0I4DEjlPEWbkojGZhn PEhxO+vX06ViWyZhXpHDyB/8PMVfEkSZXHsxorPGoK17KDtkOVkkIo96NFvYYNDwjulk ZEIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2022-7-12 header.b="YRv/Mbqs"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a63d104000000b004606d9040b9si6125806pgg.649.2022.11.25.21.21.23; Fri, 25 Nov 2022 21:21:35 -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="YRv/Mbqs"; 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 S230060AbiKZFIS (ORCPT + 84 others); Sat, 26 Nov 2022 00:08:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbiKZFIN (ORCPT ); Sat, 26 Nov 2022 00:08:13 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F491A806 for ; Fri, 25 Nov 2022 21:08:12 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AQ4uq8i011137; Sat, 26 Nov 2022 05:07:56 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=hEdmssi73mdZJZby6VH83OA2wc6mC+NgmIbVOzmV8+8=; b=YRv/MbqsKUL00lc46HNMmHbRZN5nRNTAQSZErCmQ2JKouYF8lTgHw57IJg+gbcbUbFqd j/TK0X5TvVm+D17WWxIbHD5sXRrb0EQDkYT7HLk+f4wMyOHpW0UMMKIdc+AGmnF94kXY pCo1Pr5LKwMXHqCEwUM9EthDW3yd7Sh7MsHRsSjOzX0BKlDzISo74jDFDZc4mTCMHiVu znFxsXqHM9Q5kTfP4XJqoiVdVTZuyKDNB8v2tUI5u2agBmzDcSSQLsld1MHGaIemOh1K g3xsbZodojcNStcjzFzSsRZLSw67l4LmbjP2+Cwy4O0qqFAahDmoBZ7vboDmM0cvvmc9 nw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m3c7dg07b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 26 Nov 2022 05:07:56 +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 2AQ4jExv023572; Sat, 26 Nov 2022 05:07:54 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3m3c1q8p74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 26 Nov 2022 05:07:54 +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 2AQ52vF1011626; Sat, 26 Nov 2022 05:07:54 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 3m3c1q8p61-1; Sat, 26 Nov 2022 05:07:54 +0000 From: Harshit Mogalapalli Cc: harshit.m.mogalapalli@oracle.com, error27@gmail.com, harshit.m.mogalapalli@gmail.com, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Paul Durrant , Boris Ostrovsky , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [PATCH] xen/privcmd: Fix a possible warning in privcmd_ioctl_mmap_resource() Date: Fri, 25 Nov 2022 21:07:45 -0800 Message-Id: <20221126050745.778967-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-26_04,2022-11-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211260040 X-Proofpoint-GUID: kO7OwKz7A5zcOQYmakxJLrTnzyx51z-5 X-Proofpoint-ORIG-GUID: kO7OwKz7A5zcOQYmakxJLrTnzyx51z-5 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 As 'kdata.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: -> privcmd_ioctl --> privcmd_ioctl_mmap_resource Add __GFP_NOWARN in order to avoid too large allocation warning. This is detected by static analysis using smatch. Fixes: 3ad0876554ca ("xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE") Signed-off-by: Harshit Mogalapalli --- drivers/xen/privcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index fae50a24630b..1edf45ee9890 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -760,7 +760,7 @@ static long privcmd_ioctl_mmap_resource(struct file *file, goto out; } - pfns = kcalloc(kdata.num, sizeof(*pfns), GFP_KERNEL); + pfns = kcalloc(kdata.num, sizeof(*pfns), GFP_KERNEL | __GFP_NOWARN); if (!pfns) { rc = -ENOMEM; goto out; -- 2.38.1