Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2065518yba; Mon, 15 Apr 2019 04:20:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7eKR74U4x3e6O4fEhTki7pZr/SczPgwznUcFJGtryIOpt/zXYIJFTXkAN5MBoY0U6vvyS X-Received: by 2002:a17:902:8f92:: with SMTP id z18mr76418733plo.123.1555327227434; Mon, 15 Apr 2019 04:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555327227; cv=none; d=google.com; s=arc-20160816; b=gafAx5iIOZ871RzZgnfhrzc6iiRDI3O6vnj0QR8GmghwznJ78Duzfq1z0g3Vp8CCLn gt7a89YjlSAPDfbdgfiA/8++Ij2vGQvIUi0K/6aBVy7fTc3ban4O6gtyK+gU5DcplulW 4TBgRfk5NBLlUu6L5HTnO3D4MD7vEjomfQfCuMr+IH0eeMcroc0J7ibThHnqBOefe7bi Ikwbzeo9uH1l+yujpmsQzf2UEKYTo4xXAJMe51Wc1asj79PHP8WAv5phvNlxHT9+OvPs ULKuScJbNXu5AZikoFwXC7GrwEgq5/a8N0Vr15wEEhTkr3qqwomrCmAKMCUgKGL86Bow nQYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=+FmQRXXIAJm1EH20d+zOmKjiGKMxEp89UVWAJkKB994=; b=nNx+LIfgd5fGu5NAsuKlm/ahBc+oZorryrBNqwfnkFwTF5NvbenHUKYZF83syRNTEo OHflcpnOeRELi+6zXP9TL7XxjbrSsmdFdR9t83asZf4KDuQWT6PTRGneqRZQ1Qw9Clcz 84LZMkDKf0J7dWj5c1errsuAavtk/i+4vOlrNvFsAc5Rfv5gd8hfONj60zejt8NsIjx4 Ok7S7iX+F2rVwvbN/BBj/PUPU+Z175eSkgOGsqo95osKvIYQ0Eu513LBjO8CyXbO11E+ xIifcm+cjHYoZ3iA0q9q9ZWTG/8oj11SeTsMarXFVx5HVD3tCOAKxNahLWRnbYG7yJKU oAoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si36162068plt.119.2019.04.15.04.20.09; Mon, 15 Apr 2019 04:20:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727264AbfDOLSF (ORCPT + 99 others); Mon, 15 Apr 2019 07:18:05 -0400 Received: from relay.sw.ru ([185.231.240.75]:55742 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbfDOLSF (ORCPT ); Mon, 15 Apr 2019 07:18:05 -0400 Received: from [10.94.4.83] (helo=finist-ce7.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hFzcb-00083d-45; Mon, 15 Apr 2019 14:17:57 +0300 From: Konstantin Khorenko To: Adam Borowski , Greg Kroah-Hartman Cc: Konstantin Khorenko , linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH] tty/vt: avoid high order pages allocation on GIO_UNIMAP ioctl Date: Mon, 15 Apr 2019 14:17:55 +0300 Message-Id: <20190415111755.9471-1-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GIO_UNIMAP can easily result in a high order allocation, seen 6th order allocation on radeondrmfb: fbcon: radeondrmfb (fb0) is primary device Console: switching to colour frame buffer device 160x64 radeon 0000:01:05.0: fb0: radeondrmfb frame buffer device WARNING: CPU: 0 PID: 78661 at mm/page_alloc.c:3532 __alloc_pages_nodemask+0x1b1/0x600 order 6 >= 3, gfp 0x40d0 The warning is generated by a debug patch. At the same time it's safe to use kvmalloc() for allocation in con_get_unimap(), so let's do the substitution. And do the same for con_set_unimap(). Signed-off-by: Konstantin Khorenko --- drivers/tty/vt/consolemap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 7c7ada0b3ea0..b28aa0d289f8 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -542,7 +542,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) if (!ct) return 0; - unilist = memdup_user(list, ct * sizeof(struct unipair)); + unilist = vmemdup_user(list, ct * sizeof(struct unipair)); if (IS_ERR(unilist)) return PTR_ERR(unilist); @@ -641,7 +641,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) out_unlock: console_unlock(); - kfree(unilist); + kvfree(unilist); return err; } @@ -743,7 +743,7 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni struct uni_pagedir *p; struct unipair *unilist; - unilist = kmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL); + unilist = kvmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL); if (!unilist) return -ENOMEM; @@ -775,7 +775,7 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni if (copy_to_user(list, unilist, min(ect, ct) * sizeof(struct unipair))) ret = -EFAULT; put_user(ect, uct); - kfree(unilist); + kvfree(unilist); return ret ? ret : (ect <= ct) ? 0 : -ENOMEM; } -- 2.15.1