From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751978AbcBYV0I (ORCPT ); Thu, 25 Feb 2016 16:26:08 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:59497 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751927AbcBYV0H (ORCPT ); Thu, 25 Feb 2016 16:26:07 -0500 From: Arnd Bergmann To: Konrad Rzeszutek Wilk , Boris Ostrovsky , David Vrabel Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [PATCH, RESEND] xen: allocate gntdev_copy_batch dynamically 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= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.7.0