From patchwork Thu Feb 25 21:25:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8426801 Return-Path: X-Original-To: patchwork-xen-devel@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 3ECF7C0553 for ; Thu, 25 Feb 2016 21:28:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7260B2038F for ; Thu, 25 Feb 2016 21:28:50 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F86B2037C for ; Thu, 25 Feb 2016 21:28:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aZ3Pj-00074c-At; Thu, 25 Feb 2016 21:25:35 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1aZ3Ph-00074W-Ol for xen-devel@lists.xenproject.org; Thu, 25 Feb 2016 21:25:33 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 22/F0-03306-D417FC65; Thu, 25 Feb 2016 21:25:33 +0000 X-Env-Sender: arnd@arndb.de X-Msg-Ref: server-6.tower-31.messagelabs.com!1456435532!25121085!1 X-Originating-IP: [212.227.17.24] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44868 invoked from network); 25 Feb 2016 21:25:32 -0000 Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.24) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Feb 2016 21:25:32 -0000 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0LdEht-1a8U2J3x3J-00iSt8; Thu, 25 Feb 2016 22:25:27 +0100 From: Arnd Bergmann To: Konrad Rzeszutek Wilk , Boris Ostrovsky , David Vrabel Date: Thu, 25 Feb 2016 22:25:18 +0100 Message-Id: <1456435523-287763-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:oRU4Oi02JfJYNQaOMi9j2FertMRcJWjNK48w5b5p9Dqsud0Bv1O KZG6rBPjYrMFZs68AYDp9WqqjaUg5UxkbApZRmNzIqB62HtKoQFjPuAT3Wgw3pbMFCiFii7 cAvetVNUR3sE1+43IqTgMi4tLHPFQeDDiWTAiuxShRd/MJotZadh/xmdGTKlnjz2xQr8ngb 3IeQE3PvixhjsbMkxojLg== X-UI-Out-Filterresults: notjunk:1; V01:K0:1SYk5n5IYUc=:ONctkCxCsJpYmdLhK2fPgI 4Y+EqQ36JBDIsbxkSyF6/wQ2f8hEnl8uoYcD0hcPOv6tS3kqWmnhY8CIAuppOGqJnzIkpvRP1 7ySuxFJM0TZLRzwBAoO61+PYedt/4Wsk/sAebyMUX9MC/R1xLOJWKmy6U7QXCzwYhBehThpCQ /ay1qNWhPqTsB87t9MBO7XlBH8SywBgQu/nL4JUwwVvGZjdwoV+wf0UerX1gyTLjnTBTneEsZ yQ7Q6nRzMODVUosnDQiP9bIRy0otkzHvT+2Q9gF4YBE0NtYy5CxWOoiHlhLi74dOzR+atxVcm mb83xNTUy3hCF3ArEI6myLeAizkqMnTBhusMOO5Gr7EiCilSqAKEdg9SuiySnZMmvG6pqhTFw z9piqoGIehR5vXjzJsU7vrOgi9VHz7rssRIZHhT0WdoRR+6pp97Ylw53ajbZdXZzvEiKSJqVz 1Rdfonednv8Ng4GnuI4F9IkxkR8sij+CGeWhPOGLe8lmUK4RCXvIdJNVNmiHi01vMxYLK0/rH 3oX7H3pOxnHQ28ruh+RvW36C2KP5+ZsCMnUc43DS1mT2+FvIeOvC+g0OCRQnJLw6VveoyHYDl eKHkFzccknIwPKZtU0t1xgQKx2JZd+0bEQWukeFsTRNgYL0cqv0iym+WGt77EkeQOPAKmIkiW R88Mgm97CRo9rmYxbhkGHarEFaJDwHk34c9EziWcf/9OcyiuZocw2m+spbb8lAb4m304= Cc: xen-devel@lists.xenproject.org, Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH, RESEND] xen: allocate gntdev_copy_batch dynamically X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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") --- drivers/xen/gntdev.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) I sent this in January, Boris sent an almost identical patch as http://www.gossamer-threads.com/lists/xen/devel/414056 but the bug remains present in mainline and linux-next as of Feb 25. Could you apply one of the patches before the bug makes it into v4.5? 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; }