From patchwork Wed Jan 20 10:31:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8070821 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 02540BEEE5 for ; Wed, 20 Jan 2016 10:35:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D43320437 for ; Wed, 20 Jan 2016 10:35:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66449203AA for ; Wed, 20 Jan 2016 10:35:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLq3v-0004bK-Bs; Wed, 20 Jan 2016 10:32:27 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLq3r-0004Z3-Iw for linux-arm-kernel@lists.infradead.org; Wed, 20 Jan 2016 10:32:24 +0000 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0MQs4Q-1aiIMR3oBK-00UIXq; Wed, 20 Jan 2016 11:31:54 +0100 From: Arnd Bergmann To: Boris Ostrovsky , David Vrabel , linux-arm-kernel@lists.infradead.org Subject: [PATCH] xen: allocate gntdev_copy_batch dynamically Date: Wed, 20 Jan 2016 11:31:49 +0100 Message-ID: <4664421.nvl14CijWp@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11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90ou 0LiGgFpgZNEl4QDo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160120_023223_986905_DE28A0C7 X-CRM114-Status: GOOD ( 17.00 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Konrad Rzeszutek Wilk Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct gntdev_copy_batch is arguably too large to fit on the kernel stack, and we get a warning about the stack usage in gntdev_ioctl_grant_copy: drivers/xen/gntdev.c:949:1: error: the frame size of 1240 bytes is larger than 1024 bytes This changes the code to us a dynamic allocation instead. Signed-off-by: Arnd Bergmann Fixes: a4cdb556cae0 ("xen/gntdev: add ioctl for grant copy") --- This is a regression against v4.4, found with ARM randconfig testing. diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index dc495383ad73..cc753b3a7154 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -915,15 +915,16 @@ static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch, static long gntdev_ioctl_grant_copy(struct gntdev_priv *priv, void __user *u) { struct ioctl_gntdev_grant_copy copy; - struct gntdev_copy_batch batch; + struct gntdev_copy_batch *batch; unsigned int i; int ret = 0; if (copy_from_user(©, u, sizeof(copy))) return -EFAULT; - batch.nr_ops = 0; - batch.nr_pages = 0; + batch = kzalloc(sizeof(*batch), GFP_KERNEL); + if (!batch) + return -ENOMEM; for (i = 0; i < copy.count; i++) { struct gntdev_grant_copy_segment seg; @@ -933,18 +934,20 @@ static long gntdev_ioctl_grant_copy(struct gntdev_priv *priv, void __user *u) goto out; } - ret = gntdev_grant_copy_seg(&batch, &seg, ©.segments[i].status); + ret = gntdev_grant_copy_seg(batch, &seg, ©.segments[i].status); if (ret < 0) goto out; cond_resched(); } - if (batch.nr_ops) - ret = gntdev_copy(&batch); + if (batch->nr_ops) + ret = gntdev_copy(batch); + kfree(batch); return ret; out: - gntdev_put_pages(&batch); + gntdev_put_pages(batch); + kfree(batch); return ret; }