From: Kees Cook <keescook@chromium.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Gregory Greenman <gregory.greenman@intel.com>,
Kalle Valo <kvalo@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Benjamin Berg <benjamin.berg@intel.com>,
Sriram R <quic_srirrama@quicinc.com>,
lukasz.wojnilowicz@gmail.com, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] wifi: iwlwifi: dvm: Add struct_group for struct iwl_keyinfo keys
Date: Mon, 20 Mar 2023 10:28:29 -0700 [thread overview]
Message-ID: <641897bd.630a0220.174d9.9d11@mx.google.com> (raw)
In-Reply-To: <3181a89b49e571883525172a7773b12f046e8b09.camel@sipsolutions.net>
On Sun, Feb 19, 2023 at 04:12:05PM +0100, Johannes Berg wrote:
> On Sat, 2023-02-18 at 11:11 -0800, Kees Cook wrote:
> >
> > case WLAN_CIPHER_SUITE_CCMP:
> > key_flags |= STA_KEY_FLG_CCMP;
> > - memcpy(sta_cmd.key.key, keyconf->key, keyconf->keylen);
> > + memcpy(&sta_cmd.key.keys, keyconf->key, keyconf->keylen);
>
> This should be fine though, only up to 16 bytes for CCMP.
>
> > case WLAN_CIPHER_SUITE_TKIP:
> > key_flags |= STA_KEY_FLG_TKIP;
> > sta_cmd.key.tkip_rx_tsc_byte2 = tkip_iv32;
> > for (i = 0; i < 5; i++)
> > sta_cmd.key.tkip_rx_ttak[i] = cpu_to_le16(tkip_p1k[i]);
> > - memcpy(sta_cmd.key.key, keyconf->key, keyconf->keylen);
> > + memcpy(&sta_cmd.key.keys, keyconf->key, keyconf->keylen);
>
> And that's actually a bug, we should've copied only 16 bytes, I guess.
> DVM didn't support MIC offload anyway (at least the way Linux uses the
> firmware, though I thought it doesn't at all), so we don't need the MIC
> RX/TX keys in there, but anyway the sequence counter values are not part
> of the key material on the host.
>
> I don't think I have a machine now to test this with (nor a TKIP AP, of
> course, but that could be changed) - but I suspect that since we
> actually calculate the TTAK above, we might not even need this memcpy()
> at all?
It's the latter that is triggered in the real world, though. See the
referenced URL and also now on bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=217214
i.e.: drivers/net/wireless/intel/iwlwifi/dvm/sta.c:1103
So keyconf->keylen is coming in as 32. If this is a bug, I'm not sure
where/how to fix it.
Perhaps this patch can be taken as-is, and a WARN_ON added for the >16
case to be tracked down separately?
--
Kees Cook
next prev parent reply other threads:[~2023-03-20 17:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 19:11 [PATCH] wifi: iwlwifi: dvm: Add struct_group for struct iwl_keyinfo keys Kees Cook
2023-02-19 13:41 ` Simon Horman
2023-02-19 15:12 ` Johannes Berg
2023-03-20 17:28 ` Kees Cook [this message]
2023-03-20 18:34 ` Johannes Berg
2023-03-20 19:52 ` Kees Cook
2023-03-21 8:13 ` Johannes Berg
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=641897bd.630a0220.174d9.9d11@mx.google.com \
--to=keescook@chromium.org \
--cc=benjamin.berg@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.greenman@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lukasz.wojnilowicz@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_srirrama@quicinc.com \
/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).