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: 8070811 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 626E1BEEE5 for ; Wed, 20 Jan 2016 10:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 835CA203AA for ; Wed, 20 Jan 2016 10:34:51 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75D412022A for ; Wed, 20 Jan 2016 10:34:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLq3W-0005RA-0V; Wed, 20 Jan 2016 10:32:02 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLq3T-0005QW-P5 for xen-devel@lists.xenproject.org; Wed, 20 Jan 2016 10:31:59 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id CE/94-12889-E126F965; Wed, 20 Jan 2016 10:31:58 +0000 X-Env-Sender: arnd@arndb.de X-Msg-Ref: server-11.tower-27.messagelabs.com!1453285917!18075862!1 X-Originating-IP: [212.227.126.130] 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 62230 invoked from network); 20 Jan 2016 10:31:58 -0000 Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.126.130) by server-11.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Jan 2016 10:31:58 -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 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.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:cbzDB0+l5kYpbogX0J3Gpgnp89vBG5z9lKMXvGlEBZIfF87z/W5 rHUYXh41t0FUujm4WTsv6IZuKSjoXSo86YgSKXGSzOMsJkGpSI+cUcH8xu5pLMK21Wv6Ei3 iqRYGbOIkdc0jBhfjStP2dnZakz5cVbaO4aXar0OxdUL1j+plfMd4BYYflXgyL2ZjzP6Z2T dQMFCyiwyY5sKn9yaVaEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:+Y8AiD5ldC8=:cKkXaZjsKd0gIF0HkNDKwR 7BUcVuwr8BThxn8f8xrRUYMQiJYfg0NJWcbLfbnK/PAGsYVwCDSLo/XH7+WIXqp9IE8Xfzo53 nmw5yDHe0F3L49P1Dn3tUyL0atD8YvSZFY7MTFOEndzLwRQYD6GA7tRGZVUGGAdl5Loz0r/1L NRWcaa6JUvoVVM7RilLD2cG/KMZ18flomgvuhv8/KmQvj0sZeT2O5RAiqcKkdNQxSKZxLOLUj X7KF1Z3xzDdPPA/myR5Kyu8nV2xAQP21qIGGBi/dvC8EA7LL1bC+wuIcjdEO5WFZMMhI7qjwT aAX7bFbdKKpV+Uy4eyLMrDmhawoQ7BNWEco+7/j/0sxQhspJtc4+96JzR+io+vPdvC01I6IPD VxBZx+hmX1ViyAcReKTPIBnE/S/Z5lVZcf6bpNOyCwJljr6Z4Puog0Cv5P2Pnb7ahHvFMCOaG caq0ZZH5SSrcVRa0jKxGX/5prccLJouUt99RrzW0s6Uru6BXfU3O5YTdjU+8eTreMf7KU1b5/ NEnGCHTDiGgBdZXGlUSVQlANNzbnzl/qHiwwLhbQx6kJiXfoUAE1/FATG4hfRQ4LMNc0Sf3mY 7IsnJEeJNYvt85nbQyoufGXo3s/mdXBu3BIbKk+ZvwP7ziQ8r95Y8yKdAWd1mrNPKaRYpkXko uwgq6v5J1MEvF8Oatp8C5jgckN1s1YFTuKHM8iFIxikYkAhWixkKbQ0B+wXCmdueM8SSg90ou 0LiGgFpgZNEl4QDo Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH] xen: allocate gntdev_copy_batch dynamically X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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; }