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: <20170518131359.GA3311@work>
Date:   Thu, 18 May 2017 15:14:00 +0200
From:   Stefan Schmidt <stefan@....samsung.com>
To:     linzhang <xiaolou4617@...il.com>
Cc:     aar@...gutronix.de, stefan@....samsung.com, davem@...emloft.net,
        linux-wpan@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: ieee802154: fix net_device reference release too
 early

Hello.

On Thu, 2017-05-18 at 15:50, linzhang wrote:
> This patch fixes the kernel oops when release net_device reference in 
> advance. In function raw_sendmsg(i think the dgram_sendmsg has the same 
> problem), there is a race condition between dev_put and dev_queue_xmit
> when the device is gong that maybe lead to dev_queue_ximt to see
> an illegal net_device pointer.
> 

You have a test case to reproduce this oops? I fear I have not seen
one.

> So i think that dev_put should be behind of the dev_queue_xmit.
> 
> Also, explicit set skb->sk is needless, sock_alloc_send_skb is
> already set it.

You could have put this fixup in a different patch.

> Signed-off-by: linzhang <xiaolou4617@...il.com>

This looks more like a username instead of a real name. If you have Lin
Zhang as you English real name that would be better here. :)

> ---
>  net/ieee802154/socket.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/net/ieee802154/socket.c b/net/ieee802154/socket.c
> index eedba76..a60658c 100644
> --- a/net/ieee802154/socket.c
> +++ b/net/ieee802154/socket.c
> @@ -301,15 +301,14 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
>  		goto out_skb;
>  
>  	skb->dev = dev;
> -	skb->sk  = sk;
>  	skb->protocol = htons(ETH_P_IEEE802154);
>  
> -	dev_put(dev);
> -
>  	err = dev_queue_xmit(skb);
>  	if (err > 0)
>  		err = net_xmit_errno(err);
>  
> +	dev_put(dev);
> +
>  	return err ?: size;
>  
>  out_skb:
> @@ -690,15 +689,14 @@ static int dgram_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
>  		goto out_skb;
>  
>  	skb->dev = dev;
> -	skb->sk  = sk;
>  	skb->protocol = htons(ETH_P_IEEE802154);
>  
> -	dev_put(dev);
> -
>  	err = dev_queue_xmit(skb);
>  	if (err > 0)
>  		err = net_xmit_errno(err);
>  
> +	dev_put(dev);
> +
>  	return err ?: size;

Going to give this a test ride here now.

regards
Stefan Schmidt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ