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: <20180612115525.yg2mnhlcz6ok3dyo@mwanda>
Date:   Tue, 12 Jun 2018 14:55:25 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Zhouyang Jia <jiazhouyang09@...il.com>
Cc:     devel@...verdev.osuosl.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: gdm724x: add error handling for nlmsg_put

On Mon, Jun 11, 2018 at 01:09:24PM +0800, Zhouyang Jia wrote:
> When nlmsg_put fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling nlmsg_put.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@...il.com>
> ---
>  drivers/staging/gdm724x/netlink_k.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c
> index abe2425..4623140 100644
> --- a/drivers/staging/gdm724x/netlink_k.c
> +++ b/drivers/staging/gdm724x/netlink_k.c
> @@ -119,6 +119,9 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
>  	seq++;
>  
>  	nlh = nlmsg_put(skb, 0, seq, type, len, 0);
> +	if (!nlh)
> +		return -EMSGSIZE;

This can't fail.  We just allocated skb on the line before and we
allocated enough space for "len".  Also if we *did* hit a bug here then
we would need to do some more cleanup instead of a direct return.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ