All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	syzbot <syzbot+06fa1063cca8163ea541@syzkaller.appspotmail.com>,
	syzkaller-bugs@googlegroups.com,
	Andrew Morton <akpm@linux-foundation.org>,
	"Starke, Daniel" <daniel.starke@siemens.com>,
	Lee Jones <lee@kernel.org>, Fedor Pchelkin <pchelkin@ispras.ru>,
	linux-kernel@vger.kernel.org,
	linux-serial <linux-serial@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] tty: n_gsm: restrict tty devices to attach
Date: Tue, 6 Feb 2024 14:28:22 +0000	[thread overview]
Message-ID: <2024020615-stir-dragster-aeb6@gregkh> (raw)
In-Reply-To: <1eab9734-8e4a-431b-8996-fb30f0c6b173@I-love.SAKURA.ne.jp>

On Sat, Feb 03, 2024 at 10:45:53PM +0900, Tetsuo Handa wrote:
> On 2024/01/24 22:14, Greg Kroah-Hartman wrote:
> >> @@ -3630,6 +3631,17 @@ static int gsmld_open(struct tty_struct *tty)
> >>  	if (tty->ops->write == NULL)
> >>  		return -EINVAL;
> >>  
> >> +	major = tty->driver->major;
> >> +	/* Reject Virtual consoles */
> >> +	if (major == 4 && tty->driver->minor_start == 1)
> >> +		return -EINVAL;
> >> +	/* Reject Unix98 PTY masters/slaves */
> >> +	if (major >= 128 && major <= 143)
> >> +		return -EINVAL;
> >> +	/* Reject BSD PTY masters/slaves */
> >> +	if (major >= 2 && major <= 3)
> >> +		return -EINVAL;
> > 
> > That is a lot of hard-coded magic numbers, why aren't these defined
> > anywhere?
> 
> Well, include/uapi/linux/major.h defines
> 
>   #define TTY_MAJOR 4
>   #define UNIX98_PTY_MASTER_MAJOR 128
>   #define UNIX98_PTY_MAJOR_COUNT 8
>   #define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT)
>   #define PTY_MASTER_MAJOR 2
>   #define PTY_SLAVE_MAJOR 3
> 
> but does not define end of UNIX98_PTY_SLAVE_MAJOR range, and
> no file defines start of minor number for virtual consoles.

Then use the ones you have, don't make us be forced to figure out what
is going on please.

> Does fixing this bug worth updating include/uapi/linux/major.h and adding
> include/uapi/linux/minor.h ? Since these numbers won't change, I feel that
> a line of comment is sufficient.

No, don't add new ones where not needed.

> > But really, this is only for fuzz testers, why can't they just not ever
> > bind this to a console?  Why do we have to have these checks in the
> > kernel to prevent userspace from doing dumb things that no real
> > userspace will ever do?
> 
> Fuzz testing is for testing unexpected arguments. This bug is nothing but
> missing validation that should be fixed on the kernel side rather than
> trying to tune fuzzers.

I'll push back on this, fuzzers, running as root, can easily crash the
kernel as root can crash the kernel easily.  So trying to keep the
kernel from hurting itself like this is odd to me.

Again, just tell the fuzzers to not do this.  I don't want random
hard-coded numbers in here, that's adding maintance requirements on us
in the kernel for random userspace tools doing random things :(

thanks,

greg k-h

  reply	other threads:[~2024-02-06 14:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18  9:51 [syzbot] [dri?] BUG: scheduling while atomic in drm_atomic_helper_wait_for_flip_done syzbot
2024-01-18 14:18 ` Tetsuo Handa
2024-01-20 10:34   ` [PATCH] tty: vt: check for atomic context in con_write() Tetsuo Handa
2024-01-21  3:48     ` Hillf Danton
2024-01-21 11:34       ` Tetsuo Handa
2024-01-22  6:48     ` Jiri Slaby
2024-01-22 14:08       ` Tetsuo Handa
2024-01-24 10:06         ` [PATCH] tty: n_gsm: restrict tty devices to attach Tetsuo Handa
2024-01-24 13:14           ` Greg Kroah-Hartman
2024-02-03 13:45             ` Tetsuo Handa
2024-02-06 14:28               ` Greg Kroah-Hartman [this message]
2024-04-20 11:17 ` [syzbot] [dri?] BUG: scheduling while atomic in drm_atomic_helper_wait_for_flip_done Tetsuo Handa

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=2024020615-stir-dragster-aeb6@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=daniel.starke@siemens.com \
    --cc=jirislaby@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=pchelkin@ispras.ru \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=syzbot+06fa1063cca8163ea541@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.