All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	 Greg KH <gregkh@linuxfoundation.org>
Cc: "Yang, Chenyuan" <cy54@illinois.edu>,
	 "security@kernel.org" <security@kernel.org>,
	 "dm-devel@lists.linux.dev" <dm-devel@lists.linux.dev>,
	 "agk@redhat.com" <agk@redhat.com>,
	 "snitzer@kernel.org" <snitzer@kernel.org>,
	 "syzkaller@googlegroups.com" <syzkaller@googlegroups.com>,
	 "Zhang, Lingming" <lingming@illinois.edu>,
	 "Marinov, Darko" <marinov@illinois.edu>,
	 "Zhao, Zijie" <zijie4@illinois.edu>
Subject: Re: [LInux Kernel Crash] "WARNING: kmalloc bug in ctl_ioctl"
Date: Wed, 3 Jan 2024 20:15:14 +0100 (CET)	[thread overview]
Message-ID: <b7e39bbd-356e-8bae-7fca-e71ff067149@redhat.com> (raw)
In-Reply-To: <2023121655-exporter-deed-6fcb@gregkh>

[-- Attachment #1: Type: text/plain, Size: 1717 bytes --]



On Sat, 16 Dec 2023, Greg KH wrote:

> On Fri, Dec 15, 2023 at 09:47:17PM +0000, Yang, Chenyuan wrote:
> > Hello Linux Kernel community,
> > 
> > We encountered a crash bug when testing the driver implemented in 
> > `drivers/md/dm-ioctl.c` by using Syzkaller. Notably, we generate the 
> > spec for this driver by ourselves and Syzkaller doesn’t have 
> > specification for it.
> > 
> > Based on our understanding, this bug is caused by `dmi = 
> > kvmalloc(param_kernel->data_size, GFP_NOIO | __GFP_HIGH);` in ` 
> > drivers/md/dm-ioctl.c` 
> > (https://github.com/torvalds/linux/blob/3bd7d748816927202268cb335921f7f68b3ca723/drivers/md/dm-ioctl.c#L1966), 
> > which `kvmalloc` a size more than INT_MAX.
> > 
> > A possible patch is to have a more strict check for the 
> > `param_kernel->data_size` in `copy_params` before calling `kvmalloc` 
> > while currently it only checks minimal size 
> > (https://github.com/torvalds/linux/blob/3bd7d748816927202268cb335921f7f68b3ca723/drivers/md/dm-ioctl.c#L1944).
> 
> Great, submit a patch based on this and see if it solves the issue you
> reported!
> 
> thanks,
> 
> greg k-h

Hi

I'd like to ask - what is the proper way of fixing these types of reports? 
(in this case, there is no overflow, and in the other case, there is 
kvcalloc that alrady checks for overflow). The offending ioctl can only be 
called by root - so there is no security danger.

Should we add the INT_MAX test before every kvmalloc call? (but repeating 
the same piece of code is anti-pattern).

Should we use __GFP_NOWARN? (but this would shut up also genuine 
warnings).

Should the warning be dropped from kvmalloc?

Should we do nothing because only root can trigger the warning?

Mikulas

  reply	other threads:[~2024-01-03 19:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 21:47 [LInux Kernel Crash] "WARNING: kmalloc bug in ctl_ioctl" Yang, Chenyuan
2023-12-16  7:36 ` Greg KH
2024-01-03 19:15   ` Mikulas Patocka [this message]
2024-01-03 19:21     ` Linus Torvalds

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=b7e39bbd-356e-8bae-7fca-e71ff067149@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=agk@redhat.com \
    --cc=cy54@illinois.edu \
    --cc=dm-devel@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=lingming@illinois.edu \
    --cc=marinov@illinois.edu \
    --cc=security@kernel.org \
    --cc=snitzer@kernel.org \
    --cc=syzkaller@googlegroups.com \
    --cc=torvalds@linux-foundation.org \
    --cc=zijie4@illinois.edu \
    /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.