[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200930125855.GA1155358@PWN>
Date: Wed, 30 Sep 2020 08:58:55 -0400
From: Peilin Ye <yepeilin.cs@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Vetter <daniel@...ll.ch>
Cc: Jiri Slaby <jirislaby@...nel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
dri-devel <dri-devel@...ts.freedesktop.org>,
Linux Fbdev development list <linux-fbdev@...r.kernel.org>,
linux-kernel-mentees@...ts.linuxfoundation.org,
syzkaller-bugs <syzkaller-bugs@...glegroups.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 0/3] Prevent out-of-bounds access for built-in font data
buffers
On Wed, Sep 30, 2020 at 01:52:11PM +0200, Greg Kroah-Hartman wrote:
> On Wed, Sep 30, 2020 at 01:25:14PM +0200, Daniel Vetter wrote:
> > On Wed, Sep 30, 2020 at 12:56 PM Peilin Ye <yepeilin.cs@...il.com> wrote:
> > > Yes, and built-in fonts don't use refcount. Or maybe we can let
> > > find_font() and get_default_font() kmalloc() a copy of built-in font
> > > data, then keep track of refcount for both user and built-in fonts, but
> > > that will waste a few K of memory for each built-in font we use...
> >
> > A possible trick for this would be to make sure built-in fonts start
> > out with a refcount of 1. So never get freed. Plus maybe a check that
> > if the name is set, then it's a built-in font and if we ever underflow
> > the refcount we just WARN, but don't free anything.
> >
> > Another trick would be kern_font_get/put wrappers (we'd want those
> > anyway if the userspace fonts are refcounted) and if kern_font->name
> > != NULL (i.e. built-in font with name) then we simply don't call
> > kref_get/put.
>
> Ick, don't do that, the first trick of having them start out with an
> increased reference count is the best way here. Makes the code simpler
> and no special cases for the tear-down path.
I see, I'll just let them start out with 1, and only check `->name !=
NULL` in kern_font_put(). Thank you!
Peilin Ye
Powered by blists - more mailing lists