From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [PATCH bpf] bpf: fix a rcu usage warning in bpf_prog_array_copy_core() Date: Tue, 14 Aug 2018 16:59:45 -0700 Message-ID: <20180814235944.5nufzmj6d2rkknvs@ast-mbp> References: <20180814180112.293058-1-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: ast@fb.com, daniel@iogearbox.net, netdev@vger.kernel.org, kernel-team@fb.com, Roman Gushchin To: Yonghong Song Return-path: Received: from mail-ed1-f67.google.com ([209.85.208.67]:42301 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbeHOCt0 (ORCPT ); Tue, 14 Aug 2018 22:49:26 -0400 Received: by mail-ed1-f67.google.com with SMTP id r4-v6so11025460edp.9 for ; Tue, 14 Aug 2018 16:59:50 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180814180112.293058-1-yhs@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, Aug 14, 2018 at 11:01:12AM -0700, Yonghong Song wrote: > Commit 394e40a29788 ("bpf: extend bpf_prog_array to store pointers > to the cgroup storage") refactored the bpf_prog_array_copy_core() > to accommodate new structure bpf_prog_array_item which contains > bpf_prog array itself. > > In the old code, we had > perf_event_query_prog_array(): > mutex_lock(...) > bpf_prog_array_copy_call(): > prog = rcu_dereference_check(array, 1)->progs > bpf_prog_array_copy_core(prog, ...) > mutex_unlock(...) > > With the above commit, we had > perf_event_query_prog_array(): > mutex_lock(...) > bpf_prog_array_copy_call(): > bpf_prog_array_copy_core(array, ...): > item = rcu_dereference(array)->items; > ... > mutex_unlock(...) > > The new code will trigger a lockdep rcu checking warning. > The fix is to change rcu_dereference() to rcu_dereference_check() > to prevent such a warning. > > Reported-by: syzbot+6e72317008eef84a216b@syzkaller.appspotmail.com > Fixes: 394e40a29788 ("bpf: extend bpf_prog_array to store pointers to the cgroup storage") > Cc: Roman Gushchin > Signed-off-by: Yonghong Song makes sense to me Acked-by: Alexei Starovoitov Roman, would you agree?