Message ID | 20190228054627.GC3253@kadam |
---|---|
State | Changes Requested |
Delegated to: | BPF Maintainers |
Headers | show |
Series | tools/libbpf: signedness bug in btf_dedup_ref_type() | expand |
On 2/27/19 9:46 PM, Dan Carpenter wrote: > The "ref_type_id" variable needs to be signed for the error handling > to work. > > Fixes: d5caef5b5655 ("btf: add BTF types deduplication algorithm") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > This goes through the BPF tree probably, although it does apply to > net-next. > > tools/lib/bpf/btf.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > index 68b50e9bbde1..8faed5386124 100644 > --- a/tools/lib/bpf/btf.c > +++ b/tools/lib/bpf/btf.c > @@ -2326,7 +2326,8 @@ static int btf_dedup_ref_type(struct btf_dedup *d, __u32 type_id) > struct btf_type *t, *cand; > /* if we don't find equivalent type, then we are representative type */ > __u32 new_id = type_id; > - __u32 h, ref_type_id; > + __u32 h; > + int ref_type_id; nit. Maybe you can change to int ref_type_id; __u32 h; to maintain kernel declaration reverse christmas tree convention? > > if (d->map[type_id] == BTF_IN_PROGRESS_ID) > return -ELOOP; >
On Thu, Feb 28, 2019 at 06:58:29AM +0000, Yonghong Song wrote: > > > On 2/27/19 9:46 PM, Dan Carpenter wrote: > > The "ref_type_id" variable needs to be signed for the error handling > > to work. > > > > Fixes: d5caef5b5655 ("btf: add BTF types deduplication algorithm") > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > --- > > This goes through the BPF tree probably, although it does apply to > > net-next. > > > > tools/lib/bpf/btf.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > > index 68b50e9bbde1..8faed5386124 100644 > > --- a/tools/lib/bpf/btf.c > > +++ b/tools/lib/bpf/btf.c > > @@ -2326,7 +2326,8 @@ static int btf_dedup_ref_type(struct btf_dedup *d, __u32 type_id) > > struct btf_type *t, *cand; > > /* if we don't find equivalent type, then we are representative type */ > > __u32 new_id = type_id; > > - __u32 h, ref_type_id; > > + __u32 h; > + int ref_type_id; > > nit. Maybe you can change to > int ref_type_id; > __u32 h; > to maintain kernel declaration reverse christmas tree convention? > Yes. Thanks. Let me resend. regards, dan carpenter
On Thu, Feb 28, 2019 at 5:37 AM Dan Carpenter <dan.carpenter@oracle.com> wrote: > > On Thu, Feb 28, 2019 at 06:58:29AM +0000, Yonghong Song wrote: > > > > > > On 2/27/19 9:46 PM, Dan Carpenter wrote: > > > The "ref_type_id" variable needs to be signed for the error handling > > > to work. > > > > > > Fixes: d5caef5b5655 ("btf: add BTF types deduplication algorithm") > > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > > --- > > > This goes through the BPF tree probably, although it does apply to > > > net-next. > > > > > > tools/lib/bpf/btf.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > > > index 68b50e9bbde1..8faed5386124 100644 > > > --- a/tools/lib/bpf/btf.c > > > +++ b/tools/lib/bpf/btf.c > > > @@ -2326,7 +2326,8 @@ static int btf_dedup_ref_type(struct btf_dedup *d, __u32 type_id) > > > struct btf_type *t, *cand; > > > /* if we don't find equivalent type, then we are representative type */ > > > __u32 new_id = type_id; > > > - __u32 h, ref_type_id; > > > + __u32 h; > + int ref_type_id; > > > > nit. Maybe you can change to > > int ref_type_id; > > __u32 h; > > to maintain kernel declaration reverse christmas tree convention? > > > > Yes. Thanks. Let me resend. > Thanks for catching and fixing this! With Yonghong's suggestion, you can add: Acked-by: Andrii Nakryiko <andriin@fb.com> > regards, > dan carpenter >
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 68b50e9bbde1..8faed5386124 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -2326,7 +2326,8 @@ static int btf_dedup_ref_type(struct btf_dedup *d, __u32 type_id) struct btf_type *t, *cand; /* if we don't find equivalent type, then we are representative type */ __u32 new_id = type_id; - __u32 h, ref_type_id; + __u32 h; + int ref_type_id; if (d->map[type_id] == BTF_IN_PROGRESS_ID) return -ELOOP;
The "ref_type_id" variable needs to be signed for the error handling to work. Fixes: d5caef5b5655 ("btf: add BTF types deduplication algorithm") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- This goes through the BPF tree probably, although it does apply to net-next. tools/lib/bpf/btf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)