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: <241f8d27d05a21873342c971080e245f9333d12e.camel@perches.com>
Date:   Sat, 02 Mar 2019 19:02:02 -0800
From:   Joe Perches <joe@...ches.com>
To:     Aditya Pakki <pakki001@....edu>
Cc:     kjlu@....edu, Amitkumar Karwar <amitkarwar@...il.com>,
        Siva Rebbagondla <siva8118@...il.com>,
        Kalle Valo <kvalo@...eaurora.org>,
        "David S. Miller" <davem@...emloft.net>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rsi: Fix NULL pointer dereference in kmalloc

On Sat, 2019-03-02 at 14:31 -0600, Aditya Pakki wrote:
> kmalloc can fail in rsi_register_rates_channels but memcpy still attempts
> to write to channels. The patch checks and avoids such a situation.
[]
> diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
[]
> @@ -197,6 +197,11 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)

It'd be better to make this return -ENOMEM on failure
and test in the caller and push the failure up-stack.

>  
>  	if (band == NL80211_BAND_2GHZ) {
>  		channels = kmalloc(sizeof(rsi_2ghz_channels), GFP_KERNEL);
> +		if (!channels) {
> +			rsi_dbg(ERR_ZONE, "Failed to allocate memory\n");

Allocation error messages aren't really useful
as there's a generic OOM message.

> +			return;
> +		}
> +
>  		memcpy(channels,
>  		       rsi_2ghz_channels,
>  		       sizeof(rsi_2ghz_channels));
> @@ -206,6 +211,11 @@ static void rsi_register_rates_channels(struct rsi_hw *adapter, int band)
>  		sbands->n_bitrates = ARRAY_SIZE(rsi_rates);
>  	} else {
>  		channels = kmalloc(sizeof(rsi_5ghz_channels), GFP_KERNEL);
> +		if (!channels) {
> +			rsi_dbg(ERR_ZONE, "Failed to allocate memory\n");
> +			return;
> +		}
> +
>  		memcpy(channels,
>  		       rsi_5ghz_channels,
>  		       sizeof(rsi_5ghz_channels));

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ