Content-Type: multipart/mixed; boundary="===============2131230064262479471==" MIME-Version: 1.0 From: Julia Lawall To: kbuild-all@lists.01.org Subject: Re: [bpf-next:master 801/821] kernel/bpf/bpf_iter.c:148:15-20: ERROR: invalid reference to the index variable of the iterator on line 133 (fwd) Date: Sun, 10 May 2020 19:26:05 +0200 Message-ID: In-Reply-To: <7d7b88ce-e9a5-2681-d185-8e99db2bb9f9@fb.com> List-Id: --===============2131230064262479471== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Sun, 10 May 2020, Yonghong Song wrote: > > > On 5/10/20 6:35 AM, Julia Lawall wrote: > > Hello, > > > > If the list_for_each_entry loop can exit normally (ie not by the break), > > then tinfo can be an invalid pointer after the loop. > > This should not happen since tinfo only accessed later when existed is tr= ue. I > guess initializing tinfo =3D NULL will be able to silence this > warning? Sorry, I didn't notice the use of existed. It's fine as is. julia > > > > > julia > > > > > > ---------- Forwarded message ---------- > > Date: Sun, 10 May 2020 12:01:28 +0800 > > From: kbuild test robot > > To: kbuild(a)lists.01.org > > Cc: lkp(a)intel.com, Julia Lawall > > Subject: [bpf-next:master 801/821] kernel/bpf/bpf_iter.c:148:15-20: ERR= OR: > > invalid reference to the index variable of the iterator on line 133 > > > > CC: kbuild-all(a)lists.01.org > > TO: Yonghong Song > > CC: Alexei Starovoitov > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git > > master > > head: b4563facdcae55c83039d5efcc3b45a63da14d2f > > commit: de4e05cac46d206f9090051ef09930514bff73e4 [801/821] bpf: Support= bpf > > tracing/iter programs for BPF_LINK_CREATE > > :::::: branch date: 3 hours ago > > :::::: commit date: 4 hours ago > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kbuild test robot > > Reported-by: Julia Lawall > > > > > > coccinelle warnings: (new ones prefixed by >>) > > > > > > kernel/bpf/bpf_iter.c:148:15-20: ERROR: invalid reference to the in= dex > > > > variable of the iterator on line 133 > > > > # > > https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit= /?id=3Dde4e05cac46d206f9090051ef09930514bff73e4 > > git remote add bpf-next > > https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git > > git remote update bpf-next > > git checkout de4e05cac46d206f9090051ef09930514bff73e4 > > vim +148 kernel/bpf/bpf_iter.c > > > > de4e05cac46d20 Yonghong Song 2020-05-09 118 > > de4e05cac46d20 Yonghong Song 2020-05-09 119 int bpf_iter_link_attach(= const > > union bpf_attr *attr, struct bpf_prog *prog) > > de4e05cac46d20 Yonghong Song 2020-05-09 120 { > > de4e05cac46d20 Yonghong Song 2020-05-09 121 struct bpf_link_primer > > link_primer; > > de4e05cac46d20 Yonghong Song 2020-05-09 122 struct > > bpf_iter_target_info *tinfo; > > de4e05cac46d20 Yonghong Song 2020-05-09 123 struct bpf_iter_link > > *link; > > de4e05cac46d20 Yonghong Song 2020-05-09 124 bool existed =3D false; > > de4e05cac46d20 Yonghong Song 2020-05-09 125 u32 prog_btf_id; > > de4e05cac46d20 Yonghong Song 2020-05-09 126 int err; > > de4e05cac46d20 Yonghong Song 2020-05-09 127 > > de4e05cac46d20 Yonghong Song 2020-05-09 128 if > > (attr->link_create.target_fd || attr->link_create.flags) > > de4e05cac46d20 Yonghong Song 2020-05-09 129 return > > -EINVAL; > > de4e05cac46d20 Yonghong Song 2020-05-09 130 > > de4e05cac46d20 Yonghong Song 2020-05-09 131 prog_btf_id =3D > > prog->aux->attach_btf_id; > > de4e05cac46d20 Yonghong Song 2020-05-09 132 > > mutex_lock(&targets_mutex); > > de4e05cac46d20 Yonghong Song 2020-05-09 @133 > > list_for_each_entry(tinfo, &targets, list) { > > de4e05cac46d20 Yonghong Song 2020-05-09 134 if > > (tinfo->btf_id =3D=3D prog_btf_id) { > > de4e05cac46d20 Yonghong Song 2020-05-09 135 > > existed =3D true; > > de4e05cac46d20 Yonghong Song 2020-05-09 136 break; > > de4e05cac46d20 Yonghong Song 2020-05-09 137 } > > de4e05cac46d20 Yonghong Song 2020-05-09 138 } > > de4e05cac46d20 Yonghong Song 2020-05-09 139 > > mutex_unlock(&targets_mutex); > > de4e05cac46d20 Yonghong Song 2020-05-09 140 if (!existed) > > de4e05cac46d20 Yonghong Song 2020-05-09 141 return > > -ENOENT; > > de4e05cac46d20 Yonghong Song 2020-05-09 142 > > de4e05cac46d20 Yonghong Song 2020-05-09 143 link =3D > > kzalloc(sizeof(*link), GFP_USER | __GFP_NOWARN); > > de4e05cac46d20 Yonghong Song 2020-05-09 144 if (!link) > > de4e05cac46d20 Yonghong Song 2020-05-09 145 return > > -ENOMEM; > > de4e05cac46d20 Yonghong Song 2020-05-09 146 > > de4e05cac46d20 Yonghong Song 2020-05-09 147 > > bpf_link_init(&link->link, BPF_LINK_TYPE_ITER, &bpf_iter_link_lops, pro= g); > > de4e05cac46d20 Yonghong Song 2020-05-09 @148 link->tinfo =3D tinfo; > > > > --- > > 0-DAY CI Kernel Test Service, Intel Corporation > > https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__lists.01.org_hyp= erkitty_list_kbuild-2Dall-40lists.01.org&d=3DDwIBAg&c=3D5VD0RTtNlTh3ycd41b3= MUw&r=3DDA8e1B5r073vIqRrFz7MRA&m=3DPkP59UHFyGOAoJKPUFdFJnDyFmkguITHCnAlNvAC= 8Ps&s=3DwyaOKjgZYqmGKbpSGySELSko78H58Q5MgcpNoGHUW5k&e=3D > > > --===============2131230064262479471==--