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] [day] [month] [year] [list]
Date:   Wed, 24 Feb 2021 22:14:18 +0100
From:   Marc Kleine-Budde <mkl@...gutronix.de>
To:     Oliver Hartkopp <socketcan@...tkopp.net>
Cc:     Eric Dumazet <edumazet@...gle.com>,
        Oleksij Rempel <o.rempel@...gutronix.de>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Robin van der Gracht <robin@...tonic.nl>,
        Andre Naujoks <nautsch2@...il.com>, kernel@...gutronix.de,
        linux-can@...r.kernel.org, netdev <netdev@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net v3 1/1] can: can_skb_set_owner(): fix ref counting if
 socket was closed before setting skb ownership

On 24.02.2021 21:32:29, Oliver Hartkopp wrote:
> > > To fix this problem, only set skb ownership to sockets which have still
> > > a ref count > 0.
> > > 
> > > Cc: Oliver Hartkopp <socketcan@...tkopp.net>
> > > Cc: Andre Naujoks <nautsch2@...il.com>
> > > Suggested-by: Eric Dumazet <edumazet@...gle.com>
> > > Fixes: 0ae89beb283a ("can: add destructor for self generated skbs")
> > > Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
> > 
> > SGTM
> > 
> > Reviewed-by: Eric Dumazet <edumazet@...gle.com>
> > 
> > > ---
> > >   include/linux/can/skb.h | 3 +--
> > >   1 file changed, 1 insertion(+), 2 deletions(-)
> > > 
> > > diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
> > > index 685f34cfba20..655f33aa99e3 100644
> > > --- a/include/linux/can/skb.h
> > > +++ b/include/linux/can/skb.h
> > > @@ -65,8 +65,7 @@ static inline void can_skb_reserve(struct sk_buff *skb)
> > > 
> > >   static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
> > >   {
> > > -       if (sk) {
> > > -               sock_hold(sk);
> 
> Although the commit message gives a comprehensive reason for this patch: Can
> you please add some comment here as I do not think the use of
> refcount_inc_not_zero() makes clear what is checked here.

Good point. What about:

If the socket has already been closed by user space, the refcount may
already be 0 (and the socket will be freed after the last TX skb has
been freed). So only increase socket refcount if the refcount is > 0.

regards
Marc

P.S.: Have you had time to look at my ISOTOP RFC patch?

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ