lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190320164911.GH7431@mini-arch.hsd1.ca.comcast.net>
Date:   Wed, 20 Mar 2019 09:49:11 -0700
From:   Stanislav Fomichev <sdf@...ichev.me>
To:     Willem de Bruijn <willemdebruijn.kernel@...il.com>
Cc:     Stanislav Fomichev <sdf@...gle.com>,
        Network Development <netdev@...r.kernel.org>,
        bpf@...r.kernel.org, David Miller <davem@...emloft.net>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        simon.horman@...ronome.com, Willem de Bruijn <willemb@...gle.com>,
        Petar Penkov <peterpenkov96@...il.com>
Subject: Re: [RFC bpf-next v2 2/9] net: introduce skb_net helper

On 03/19, Willem de Bruijn wrote:
> On Tue, Mar 19, 2019 at 6:20 PM Stanislav Fomichev <sdf@...gle.com> wrote:
> >
> > skb_net returns network namespace from the associated device or socket.
> >
> > This will be used in the next commit.
> >
> > I tried to inline it in skbuff.h, but I don't think it's feasible.
> 
> If so, is this helper necessary?
> 
> All existing cases that use it pass both skb_net(skb) and skb to the
> flow dissector, so can continue to call it locally if new argument net
> is NULL.
> 
> The new users are in patch 9/9 in the device drivers, but those should
> pass the device pointer unconditionally.
Good point, I can try to drop it.


> > It depends on 'net/sock.h' for sock_net() and 'linux/netdevice.h' for
> > dev_net(), both of which we don't include from 'linux/skbuff.h' (but
> > both sock.h and netdevice.h include skbuff.h). I though about doing
> > it as a macro/putting it somewhere else, but we will have
> > skb_flow_dissect{_xyz} use it in the next commits.
> >
> > Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
> > ---
> >  include/linux/skbuff.h |  2 ++
> >  net/core/skbuff.c      | 16 ++++++++++++++++
> >  2 files changed, 18 insertions(+)
> >
> > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > index e8c1d5b97f96..75e1d4d73cca 100644
> > --- a/include/linux/skbuff.h
> > +++ b/include/linux/skbuff.h
> > @@ -1275,6 +1275,8 @@ static inline int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr)
> >  }
> >  #endif
> >
> > +struct net *skb_net(const struct sk_buff *skb);
> > +
> >  struct bpf_flow_keys;
> >  bool __skb_flow_bpf_dissect(struct bpf_prog *prog,
> >                             const struct sk_buff *skb,
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index b413354ee709..d81f3a95fb4e 100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -5725,3 +5725,19 @@ void __skb_ext_put(struct skb_ext *ext)
> >  }
> >  EXPORT_SYMBOL(__skb_ext_put);
> >  #endif /* CONFIG_SKB_EXTENSIONS */
> > +
> > +/**
> > + * skb_net - Return network namespace associated with skb.
> > + * @skb: skb
> > + *
> > + * Returns pointer to struct net or NULL.
> > + */
> > +struct net *skb_net(const struct sk_buff *skb)
> > +{
> > +       if (skb->dev)
> > +               return dev_net(skb->dev);
> > +       else if (skb->sk)
> > +               return sock_net(skb->sk);
> > +       return NULL;
> > +}
> > +EXPORT_SYMBOL(skb_net);
> > --
> > 2.21.0.225.g810b269d1ac-goog
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ