linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+59997e8d5cbdc486e6f6@syzkaller.appspotmail.com
Subject: Re: [PATCH 2/2] vt: selection, close sel_buffer race
Date: Thu, 13 Feb 2020 08:09:31 +0100	[thread overview]
Message-ID: <d293a76e-5385-9517-8de3-4281b0bb804a@suse.cz> (raw)
In-Reply-To: <20200212195909.GA2081344@kroah.com>

On 12. 02. 20, 20:59, Greg KH wrote:
> On Mon, Feb 10, 2020 at 09:11:31AM +0100, Jiri Slaby wrote:
>> syzkaller reported this UAF:
>> BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x2481/0x2940 drivers/tty/n_tty.c:1741
>> Read of size 1 at addr ffff8880089e40e9 by task syz-executor.1/13184
>>
>> CPU: 0 PID: 13184 Comm: syz-executor.1 Not tainted 5.4.7 #1
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
>> Call Trace:
>> ...
>>  kasan_report+0xe/0x20 mm/kasan/common.c:634
>>  n_tty_receive_buf_common+0x2481/0x2940 drivers/tty/n_tty.c:1741
>>  tty_ldisc_receive_buf+0xac/0x190 drivers/tty/tty_buffer.c:461
>>  paste_selection+0x297/0x400 drivers/tty/vt/selection.c:372
>>  tioclinux+0x20d/0x4e0 drivers/tty/vt/vt.c:3044
>>  vt_ioctl+0x1bcf/0x28d0 drivers/tty/vt/vt_ioctl.c:364
>>  tty_ioctl+0x525/0x15a0 drivers/tty/tty_io.c:2657
>>  vfs_ioctl fs/ioctl.c:47 [inline]
>>
>> It is due to a race between parallel paste_selection (TIOCL_PASTESEL)
>> and set_selection_user (TIOCL_SETSEL) invocations. One uses sel_buffer,
>> while the other frees it and reallocates a new one for another
>> selection. Add a mutex to close this race.
>>
>> The mutex takes care properly of sel_buffer and sel_buffer_lth only. The
>> other selection global variables (like sel_start, sel_end, and sel_cons)
>> are protected only in set_selection_user. The other functions need quite
>> some more work to close the races of the variables there. This is going
>> to happen later.
>>
>> This likely fixes (I am unsure as there is no reproducer provided) bug
>> 206361 too. It was marked as CVE-2020-8648.
>>
>> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
>> Reported-by: syzbot+59997e8d5cbdc486e6f6@syzkaller.appspotmail.com
>> References: https://bugzilla.kernel.org/show_bug.cgi?id=206361
> 
> This needs patch 1 in order to work properly, right?

Not necessarily -- the patches fix two different bugs (endless loop in
kernel vs crash). If you want to apply them in the opposite order, just
let me know.

BTW I completely forgot to add Fixes and Cc: stable tags. Both of the
issues come from 1.x times. (But the crash obviously needs
SMP/preemption, i.e. 2.x.*.)

thanks,
-- 
js
suse labs

  reply	other threads:[~2020-02-13  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10  8:11 [PATCH 1/2] vt: selection, handle pending signals in paste_selection Jiri Slaby
2020-02-10  8:11 ` [PATCH 2/2] vt: selection, close sel_buffer race Jiri Slaby
2020-02-12 19:59   ` Greg KH
2020-02-13  7:09     ` Jiri Slaby [this message]
2020-02-13 19:58       ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d293a76e-5385-9517-8de3-4281b0bb804a@suse.cz \
    --to=jslaby@suse.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=syzbot+59997e8d5cbdc486e6f6@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).