Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3272361ybb; Tue, 31 Mar 2020 01:46:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt4PDjYZ3M2UGw3oDzcH3VAPJyLWfwGNbDMK1rQ3mZcnKTqq+abb5BEKMeZ7ybgBHpxpfA4 X-Received: by 2002:a9d:6c89:: with SMTP id c9mr11918198otr.337.1585644363441; Tue, 31 Mar 2020 01:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585644363; cv=none; d=google.com; s=arc-20160816; b=wkqSmut1i9CTFivZVUM4t8TB9pCQJL42+lPWCe8sboQuLjRhCTR+NqldOhwOWoNqqV 2ffyCEYTGloLjX/K/Yr59kfUp4GHYdnko5KM4SN2i2I163mfv0Q/aTD/X64/HcrScIx6 IzKc0wCYHxPV8a+smyDs/mSrsr8g3XyyTEzYtdQYgygHFllHX3BNgkpJ0gFcmL+PnQNE kDnlXhdsi7DzUn5NnU0CoGRShEGlZ1pWMgrB9fPoPfuuQ6DqEAmtJ0dcDRerr2wwMIqh 3uZ4OKC2eiSD3sqcgh1gya01yXt3zpAV4peS/kWNSKlwLQ1nxc5ho+jOsQek0BqjTesZ npMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KhjGFpVb89HwIODM64QA3thRtuQAnzTVaT5loV4riVk=; b=i2s+a+MxsK3FginMbe6ednTYFTylnzswslO9LCke2iWunBi/v70us0dxL3fC9nTZNc OLuxLQjTAqlehngjOA6KTOxsLfP3QsDI9oboFrfb98DcGeK6mELLqsCd5vGJKDUgAdxG 6753zJsWhMBIwIwz+6cxM/N1O8p42oYrLISQgD5/ES+d93pVXVgvADJtVfRfITPoVMip nHPG3s5PkKA/sRXH5v1PoGTc7wfWozaLrZrJJE3SICFyDqEFPGJhA+Rlb3+yzKds98FP sciaU7yov/5R7RWKN8Sk+Wa5Bdj4nWasvHrXMS/ROXq11jaT31xpY+DycimvvaMC6ZOX 0iNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=QTjf25se; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r205si6356722oig.174.2020.03.31.01.45.49; Tue, 31 Mar 2020 01:46:03 -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; dkim=pass header.i=@ffwll.ch header.s=google header.b=QTjf25se; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729955AbgCaInZ (ORCPT + 99 others); Tue, 31 Mar 2020 04:43:25 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:39161 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726299AbgCaInZ (ORCPT ); Tue, 31 Mar 2020 04:43:25 -0400 Received: by mail-ot1-f67.google.com with SMTP id x11so21230832otp.6 for ; Tue, 31 Mar 2020 01:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KhjGFpVb89HwIODM64QA3thRtuQAnzTVaT5loV4riVk=; b=QTjf25seCttencnQvo+PixAAJ0nogbqdPicz8zjLP+HsTFetaLD0s5kkcZAyZZFlSl 0ohsirzgdu2NNtBmP+5Su+hQnnTHoLDjrG4od5f4pVRAeONcvnIcBPIyuu1qXNW2Cvu2 RH94VhWTQaWzLvd8OelOR/1tTjSHi1rfrB1cw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KhjGFpVb89HwIODM64QA3thRtuQAnzTVaT5loV4riVk=; b=BALuQvvPuAgLO+QotbjE8GwQqp6tbfbPbOl7ZfVJqhRc0p48PpDYmrK+a1HmUEGthr WGc08rPVaW2iqeSC+GMqZIfAdq0z31DPQ0US1Gzgrb5o3zuDk27sNZWsP9oMmY5hYeL3 phXMwGZgcgR9IUsi6EMCb4X9Y3GOGtc/Q/Acg9QaaZbfivnoW/gogp9XZR883LcyaZpl 5rrEtcOCvc/INWKoq+xzWS14I0LWnNBy0uRzhA4dzbFvaMS8two+4g9cFhAEHfBanpwz 69Z2vsSW2i5kRVGXkP2ELFVM6wa5+vTm8fafyGI7qaMYFOlVdAC033tN6yHZIHHQy3Tb bSbw== X-Gm-Message-State: ANhLgQ3Z3vDPAFYEXzJ+Bnso6DFF+Dmm4mMbWMH6pDjo+Oq39M15aKp/ Zm2oddQo5VA2tFmpYSpwBHvfbf/zNoAv8flkXl6TTA== X-Received: by 2002:a9d:554d:: with SMTP id h13mr12119479oti.303.1585644202736; Tue, 31 Mar 2020 01:43:22 -0700 (PDT) MIME-Version: 1.0 References: <20200330190759.GE7594@ravnborg.org> In-Reply-To: <20200330190759.GE7594@ravnborg.org> From: Daniel Vetter Date: Tue, 31 Mar 2020 10:43:11 +0200 Message-ID: Subject: Re: [PATCH v2] vt: don't use kmalloc() for the unicode screen buffer To: Sam Ravnborg Cc: Nicolas Pitre , Greg KH , Chen Wandun , Adam Borowski , Jiri Slaby , Bartlomiej Zolnierkiewicz , Lukas Wunner , ghalat@redhat.com, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 30, 2020 at 9:08 PM Sam Ravnborg wrote: > > Hi Nicolas > > On Sat, Mar 28, 2020 at 10:25:11PM -0400, Nicolas Pitre wrote: > > Even if the actual screen size is bounded in vc_do_resize(), the unicode > > buffer is still a little more than twice the size of the glyph buffer > > and may exceed MAX_ORDER down the kmalloc() path. This can be triggered > > from user space. > > > > Since there is no point having a physically contiguous buffer here, > > let's avoid the above issue as well as reducing pressure on high order > > allocations by using vmalloc() instead. > > > > Signed-off-by: Nicolas Pitre > > Cc: > > > > --- > > > > Changes since v1: > > > > - Added missing include, found by kbuild test robot. > > Strange that my own build doesn't complain. > > When I did the drmP.h removal vmalloc was one of the header files > that turned up missing in many cases - but only for some architectures. > I learned to include alpha in the build. > If it survived building for alpha then I had fixed the majority > of the issues related to random inherited includes. > > The patch itself looks good. > > Acked-by: Sam Ravnborg Greg, I'm assuming you'll pick this up through the tty tree? I kinda want to stop the habit of merging vt patches, maybe then get_maintainers will stop thinking I'm responsible somehow :-) -Daniel > > > > > diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c > > index 15d2769805..d9eb5661e9 100644 > > --- a/drivers/tty/vt/vt.c > > +++ b/drivers/tty/vt/vt.c > > @@ -81,6 +81,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -350,7 +351,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows) > > /* allocate everything in one go */ > > memsize = cols * rows * sizeof(char32_t); > > memsize += rows * sizeof(char32_t *); > > - p = kmalloc(memsize, GFP_KERNEL); > > + p = vmalloc(memsize); > > if (!p) > > return NULL; > > > > @@ -366,7 +367,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows) > > > > static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr) > > { > > - kfree(vc->vc_uni_screen); > > + vfree(vc->vc_uni_screen); > > vc->vc_uni_screen = new_uniscr; > > } > > -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch