Message ID | 20221126050745.778967-1-harshit.m.mogalapalli@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4464080wrr; Fri, 25 Nov 2022 21:11:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf7EWBWLjeDbbcrEUwPKURoFRx0fs9j4Rrq5pq+gT51rrnpMm9ajEGwXD+Elid98Nu48AQre X-Received: by 2002:a05:6402:5483:b0:468:d5a9:cb4b with SMTP id fg3-20020a056402548300b00468d5a9cb4bmr24768119edb.409.1669439471181; Fri, 25 Nov 2022 21:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669439471; cv=none; d=google.com; s=arc-20160816; b=SqZIlcYvzfw/+iNLpUKVlIRmXps807Ej7j6kwAc2hNFATGZjuIGmCB9eP/EfALZ6gv EcIWqKkCYJcaEypLMyAaYReZOXsxh6lKWJnn7EwxLImfejcsLTQpDVIy4B/awCCm4tLp 6uyOU6MP/AXieb015PbIwIC/OalVxle+CPSoP1Vhk7TZ73ri0WQseyxUVPbXjiopmBjZ GtNJK/JRneTNrBuee6zsrgQxOs1R6wHLdihOaPSjdoqrySZ0NuulZaR6zEPTNexxDFlQ bgOAvs2TRiwfUcYkXfTOHcgqcJjEVhSzax5FyN+o15HnspBX9MNiTaYOCJ95MgXBqkIh 65rQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vq2-20020a170907a4c200b007ae165c79c8si4398716ejc.940.2022.11.25.21.10.48; Fri, 25 Nov 2022 21:11:11 -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 <rfc822;zxc52fgh@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <harshit.m.mogalapalli@oracle.com> Cc: harshit.m.mogalapalli@oracle.com, error27@gmail.com, harshit.m.mogalapalli@gmail.com, Juergen Gross <jgross@suse.com>, Stefano Stabellini <sstabellini@kernel.org>, Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>, Paul Durrant <paul.durrant@citrix.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750534163385659590?= X-GMAIL-MSGID: =?utf-8?q?1750534163385659590?= |
Series |
xen/privcmd: Fix a possible warning in privcmd_ioctl_mmap_resource()
|
|
Commit Message
Harshit Mogalapalli
Nov. 26, 2022, 5:07 a.m. UTC
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 <harshit.m.mogalapalli@oracle.com>
---
drivers/xen/privcmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 26.11.22 06:07, Harshit Mogalapalli wrote: > 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 <harshit.m.mogalapalli@oracle.com> Reviewed-by: Juergen Gross <jgross@suse.com> Juergen
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;