linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dmitry Vyukov <dvyukov@google.com>, Cong Wang <xiyou.wangcong@gmail.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	syzbot+37b8770e6d5a8220a039@syzkaller.appspotmail.com,
	David Miller <davem@davemloft.net>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>
Subject: Re: KASAN: use-after-free Read in tcf_block_find
Date: Thu, 27 Sep 2018 06:00:39 -0700	[thread overview]
Message-ID: <de41f26b-efe6-9985-cf38-169c18791cd6@gmail.com> (raw)
In-Reply-To: <CACT4Y+YbQbZ7XTPK1HLvPiR9rmSm7Cz0H2LJAFfYfAta1Y3CiQ@mail.gmail.com>



On 09/27/2018 01:10 AM, Dmitry Vyukov wrote:

> 
> Would a stack trace for call_rcu be helpful here? I have this idea for
> a long time, but never get around to implementing it:
> https://bugzilla.kernel.org/show_bug.cgi?id=198437
> 
> Also FWIW I recently used the following hack for another net bug. It
> made that other bug involving call_rcu way more likely to fire. Maybe
> it will be helpful here too.
> 
> diff --git a/net/core/dst.c b/net/core/dst.c
> index 81ccf20e28265..591a8d0aca545 100644
> --- a/net/core/dst.c
> +++ b/net/core/dst.c
> @@ -187,8 +187,16 @@ void dst_release(struct dst_entry *dst)
>                 if (unlikely(newrefcnt < 0))
>                         net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
>                                              __func__, dst, newrefcnt);
> -               if (!newrefcnt)
> -                       call_rcu(&dst->rcu_head, dst_destroy_rcu);
> +               if (!newrefcnt) {
> +                       if (lock_is_held(&rcu_bh_lock_map) ||
> +                               lock_is_held(&rcu_lock_map) ||
> +                               lock_is_held(&rcu_sched_lock_map)) {
> +                               call_rcu(&dst->rcu_head, dst_destroy_rcu);
> +                       } else {
> +                               synchronize_rcu();

dst_release() can be called in context we hold a spinlock, this would be bad to reschedule here.

> +                               dst_destroy_rcu(&dst->rcu_head);
> +                       }
> +               }
>         }
>  }
> 

  reply	other threads:[~2018-09-27 13:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 15:44 KASAN: use-after-free Read in tcf_block_find syzbot
2018-09-26 21:44 ` Cong Wang
2018-09-26 21:50   ` Eric Dumazet
2018-09-26 21:55     ` Cong Wang
2018-09-27  8:06       ` Dmitry Vyukov
2018-09-27  8:10         ` Dmitry Vyukov
2018-09-27 13:00           ` Eric Dumazet [this message]
2018-09-27 13:02             ` Dmitry Vyukov
2018-09-27 13:24               ` Eric Dumazet
2018-09-27 13:42                 ` Dmitry Vyukov
2018-09-27 17:50           ` Cong Wang
2018-09-27 18:04             ` Dmitry Vyukov

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=de41f26b-efe6-9985-cf38-169c18791cd6@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+37b8770e6d5a8220a039@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xiyou.wangcong@gmail.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).