From: Stanislav Fomichev <sdf@fomichev.me>
To: Jann Horn <jannh@google.com>
Cc: Stanislav Fomichev <sdf@google.com>,
Network Development <netdev@vger.kernel.org>,
bpf@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
jakub.kicinski@netronome.com, quentin.monnet@netronome.com
Subject: Re: [PATCH bpf-next v2 1/2] bpf: support BPF_PROG_QUERY for BPF_FLOW_DISSECTOR attach_type
Date: Wed, 24 Apr 2019 14:06:39 -0700 [thread overview]
Message-ID: <20190424210639.GD1247@mini-arch> (raw)
In-Reply-To: <CAG48ez1aEenkwonZ2UXFOE46kdPWhsiOMNory4gQgK9J5kz1ug@mail.gmail.com>
On 04/24, Jann Horn wrote:
> On Wed, Apr 24, 2019 at 6:09 PM Stanislav Fomichev <sdf@google.com> wrote:
> > target_fd is target namespace. If there is a flow dissector BPF program
> > attached to that namespace, its (single) id is returned.
> >
> > v2:
> > * don't sleep in rcu critical section (Jakub Kicinski)
> > * check input prog_cnt (exit early)
> >
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
> [...]
> > +int skb_flow_dissector_prog_query(const union bpf_attr *attr,
> > + union bpf_attr __user *uattr)
> > +{
> [...]
> > + net = get_net_ns_by_fd(attr->query.target_fd);
> > + if (IS_ERR(net))
> > + return PTR_ERR(net);
>
> At this point, you're holding a refcounted reference to `net`. It
> looks like that reference is never dropped?
Ah, indeed, put_net is missing, thanks!
> > +
> > + rcu_read_lock();
> > + attached = rcu_dereference(net->flow_dissector_prog);
> > + if (attached) {
> > + prog_cnt = 1;
> > + prog_id = attached->aux->id;
> > + }
> > + rcu_read_unlock();
> > +
> > + if (copy_to_user(&uattr->query.attach_flags, &flags, sizeof(flags)))
> > + return -EFAULT;
> [...]
> > +}
prev parent reply other threads:[~2019-04-24 21:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 16:09 [PATCH bpf-next v2 1/2] bpf: support BPF_PROG_QUERY for BPF_FLOW_DISSECTOR attach_type Stanislav Fomichev
2019-04-24 16:09 ` [PATCH bpf-next v2 2/2] bpftool: show flow_dissector attachment status Stanislav Fomichev
2019-04-24 21:01 ` [PATCH bpf-next v2 1/2] bpf: support BPF_PROG_QUERY for BPF_FLOW_DISSECTOR attach_type Jann Horn
2019-04-24 21:06 ` Stanislav Fomichev [this message]
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=20190424210639.GD1247@mini-arch \
--to=sdf@fomichev.me \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=jannh@google.com \
--cc=netdev@vger.kernel.org \
--cc=quentin.monnet@netronome.com \
--cc=sdf@google.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).