linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Dmitry Vyukov <dvyukov@google.com>, Jiri Slaby <jslaby@suse.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Matthew Garrett <mjg59@google.com>,
	Andi Kleen <ak@linux.intel.com>,
	"Theodore Y . Ts'o" <tytso@mit.edu>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v2] Add kernel config option for fuzz testing.
Date: Thu, 12 Mar 2020 18:29:35 -0400	[thread overview]
Message-ID: <20200312182935.70ed6516@gandalf.local.home> (raw)
In-Reply-To: <7e0d2bbf-71c2-395c-9a42-d3d6d3ee4fa4@i-love.sakura.ne.jp>

On Fri, 13 Mar 2020 06:59:22 +0900
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:

> On 2020/03/13 4:23, Dmitry Vyukov wrote:
> >> Or teach the fuzz tool not to do specific bad things.  
> > 
> > We do some of this.
> > But generally it's impossible for anything that involves memory
> > indirections, or depends on the exact type of fd (e.g. all ioctl's),
> > etc. Boils down to halting problem and ability to predict exact
> > behavior of arbitrary programs.  
> 
> I would like to enable changes like below only if CONFIG_KERNEL_BUILT_FOR_FUZZ_TESTING=y .
> 
> Since TASK_RUNNING threads are not always running on CPUs (in syzbot, the kernel is
> tested on a VM with only 2 CPUs, which means that many threads are simply waiting for
> CPU time to be assigned), dumping locks held by all threads gives us more clue when
> e.g. khungtask fired. But since lockdep_print_held_locks() is racy, I assume that
> this change won't be accepted unless CONFIG_KERNEL_BUILT_FOR_FUZZ_TESTING=y .
> 
> Also, for another example, limit number of memory pages /dev/ion driver can consume only if
> CONFIG_KERNEL_BUILT_FOR_FUZZ_TESTING=y ( https://github.com/google/syzkaller/issues/1267 ),
> for limiting number of memory pages is a user-visible change while we need to avoid false
> alarms caused by consuming all memory pages.
> 
> In other words, while majority of things CONFIG_KERNEL_BUILT_FOR_FUZZ_TESTING=y would
> do "disable this", there would be a few "enable this" and "change this".

I still fear that people will just disable large sections. I've seen this
before. Developers take the easy way out, and when someone adds a new
feature that may be dangerous, they will just say "oh turn off fuzzing" and
be done with it.

As Linus likes to say, when you need to make changes to the kernel to test
it, you are no longer testing production kernels.

> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 32406ef0d6a2..1bc7878768fc 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -695,6 +695,7 @@ static void print_lock(struct held_lock *hlock)
>  static void lockdep_print_held_locks(struct task_struct *p)
>  {
>  	int i, depth = READ_ONCE(p->lockdep_depth);
> +	bool unreliable;
>  
>  	if (!depth)
>  		printk("no locks held by %s/%d.\n", p->comm, task_pid_nr(p));
> @@ -705,10 +706,12 @@ static void lockdep_print_held_locks(struct task_struct *p)
>  	 * It's not reliable to print a task's held locks if it's not sleeping
>  	 * and it's not the current task.
>  	 */
> -	if (p->state == TASK_RUNNING && p != current)
> -		return;
> +	unreliable = p->state == TASK_RUNNING && p != current;
>  	for (i = 0; i < depth; i++) {
> -		printk(" #%d: ", i);
> +		if (unreliable)
> +			printk(" #%d?: ", i);
> +		else
> +			printk(" #%d: ", i);

Have you tried submitting this? Has Peter nacked it?

-- Steve

>  		print_lock(p->held_locks + i);
>  	}
>  }


  reply	other threads:[~2020-03-12 22:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-07 13:58 [PATCH v2] Add kernel config option for fuzz testing Tetsuo Handa
2020-03-07 16:28 ` Jiri Slaby
2020-03-08  6:52   ` Greg Kroah-Hartman
2020-03-08 16:13     ` Linus Torvalds
2020-03-09 11:22       ` Tetsuo Handa
2020-03-09 13:23         ` Steven Rostedt
2020-03-09 15:39     ` Jiri Slaby
2020-03-10  6:30       ` Dmitry Vyukov
2020-03-11 14:11         ` Steven Rostedt
2020-03-12 19:23           ` Dmitry Vyukov
2020-03-12 21:59             ` Tetsuo Handa
2020-03-12 22:29               ` Steven Rostedt [this message]
2020-03-13  8:31                 ` Peter Zijlstra
2020-03-15  5:54                 ` Dmitry Vyukov
2020-03-21  4:49         ` Tetsuo Handa
2020-03-24 10:37           ` Dmitry Vyukov
2020-03-26 11:10             ` Tetsuo Handa
2020-04-10  4:38               ` Tetsuo Handa
2020-03-08  6:52 ` Greg Kroah-Hartman

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=20200312182935.70ed6516@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dvyukov@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@google.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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).