From: Johannes Berg <johannes@sipsolutions.net>
To: "Petr Štetiar" <ynezz@true.cz>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v2] mac80211: fix NULL pointer dereference in ieee80211_key_alloc()
Date: Sun, 27 Mar 2011 13:33:53 +0200 [thread overview]
Message-ID: <1301225633.3826.10.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <1301225486-23597-1-git-send-email-ynezz@true.cz>
On Sun, 2011-03-27 at 13:31 +0200, Petr Štetiar wrote:
> The ieee80211_key struct can be kfree()d several times in the function, for
> example if some of the key setup functions fails beforehand, but there's no
> check if the struct is still valid before we call memcpy() and INIT_LIST_HEAD()
> on it. In some cases (like it was in my case), if there's missing aes-generic
> module it could lead to the following kernel OOPS:
>
> Unable to handle kernel NULL pointer dereference at virtual address 0000018c
> ....
> PC is at memcpy+0x80/0x29c
> ...
> Backtrace:
> [<bf11c5e4>] (ieee80211_key_alloc+0x0/0x234 [mac80211]) from [<bf1148b4>] (ieee80211_add_key+0x70/0x12c [mac80211])
> [<bf114844>] (ieee80211_add_key+0x0/0x12c [mac80211]) from [<bf070cc0>] (__cfg80211_set_encryption+0x2a8/0x464 [cfg80211])
>
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> CC: Johannes Berg <johannes@sipsolutions.net>
Thanks!
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
> ---
> net/mac80211/key.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/mac80211/key.c b/net/mac80211/key.c
> index 8c02469..09cf1f2 100644
> --- a/net/mac80211/key.c
> +++ b/net/mac80211/key.c
> @@ -342,7 +342,7 @@ struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
> if (IS_ERR(key->u.ccmp.tfm)) {
> err = PTR_ERR(key->u.ccmp.tfm);
> kfree(key);
> - key = ERR_PTR(err);
> + return ERR_PTR(err);
> }
> break;
> case WLAN_CIPHER_SUITE_AES_CMAC:
> @@ -360,7 +360,7 @@ struct ieee80211_key *ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
> if (IS_ERR(key->u.aes_cmac.tfm)) {
> err = PTR_ERR(key->u.aes_cmac.tfm);
> kfree(key);
> - key = ERR_PTR(err);
> + return ERR_PTR(err);
> }
> break;
> }
prev parent reply other threads:[~2011-03-27 11:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-26 17:32 [PATCH] mac80211: fix NULL pointer dereference in ieee80211_key_alloc() Petr Štetiar
2011-03-27 9:16 ` Johannes Berg
2011-03-27 11:31 ` [PATCH v2] " Petr Štetiar
2011-03-27 11:33 ` Johannes Berg [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1301225633.3826.10.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=ynezz@true.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).