[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAO8sHcmFHLpk2LfJKxHcA_9y6TyouS0sr=8oj09gLGvGmhYavw@mail.gmail.com>
Date: Wed, 11 Oct 2023 21:09:33 +0200
From: Daan De Meyer <daan.j.demeyer@...il.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: bpf@...r.kernel.org, kernel-team@...a.com, martin.lau@...ux.dev,
netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next v10 2/9] bpf: Propagate modified uaddrlen from
cgroup sockaddr programs
> From: Daan De Meyer <daan.j.demeyer@...il.com>
> Date: Wed, 11 Oct 2023 20:37:49 +0200
> > > > @@ -1483,11 +1488,18 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
> > > > if (!ctx.uaddr) {
> > > > memset(&unspec, 0, sizeof(unspec));
> > > > ctx.uaddr = (struct sockaddr *)&unspec;
> > > > - }
> > > > + ctx.uaddrlen = 0;
> > > > + } else
> > > > + ctx.uaddrlen = *uaddrlen;
> > > >
> > > > cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data);
> > > > - return bpf_prog_run_array_cg(&cgrp->bpf, atype, &ctx, bpf_prog_run,
> > > > - 0, flags);
> > > > + ret = bpf_prog_run_array_cg(&cgrp->bpf, atype, &ctx, bpf_prog_run,
> > > > + 0, flags);
> > > > +
> > > > + if (!ret && uaddrlen)
> > >
> > > nit: no need to check uaddrlen here or maybe check ctx.uaddrlen.
> >
> > Are you sure? uaddrlen can still be NULL if uaddr is also NULL
>
> How? In the patch 2 and 4, it seems uaddrlen always points to an
> actual variable.
Right, I was assuming we don't know for sure how callers are calling
this function. It is right that right now no caller calls it with uaddrlen set
to NULL.
It still seems like a good idea to check for uaddr instead of uaddrlen though,
to mimic the same check that is done earlier in this function.
On Wed, 11 Oct 2023 at 20:58, Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
>
> From: Daan De Meyer <daan.j.demeyer@...il.com>
> Date: Wed, 11 Oct 2023 20:37:49 +0200
> > > > @@ -1483,11 +1488,18 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
> > > > if (!ctx.uaddr) {
> > > > memset(&unspec, 0, sizeof(unspec));
> > > > ctx.uaddr = (struct sockaddr *)&unspec;
> > > > - }
> > > > + ctx.uaddrlen = 0;
> > > > + } else
> > > > + ctx.uaddrlen = *uaddrlen;
> > > >
> > > > cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data);
> > > > - return bpf_prog_run_array_cg(&cgrp->bpf, atype, &ctx, bpf_prog_run,
> > > > - 0, flags);
> > > > + ret = bpf_prog_run_array_cg(&cgrp->bpf, atype, &ctx, bpf_prog_run,
> > > > + 0, flags);
> > > > +
> > > > + if (!ret && uaddrlen)
> > >
> > > nit: no need to check uaddrlen here or maybe check ctx.uaddrlen.
> >
> > Are you sure? uaddrlen can still be NULL if uaddr is also NULL
>
> How? In the patch 2 and 4, it seems uaddrlen always points to an
> actual variable.
Powered by blists - more mailing lists