linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Kees Cook <keescook@chromium.org>
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 19:34:59 +0100	[thread overview]
Message-ID: <0ec5fe8b6945ee545b335ef2f3bee75b0af458d0.camel@sipsolutions.net> (raw)
In-Reply-To: <641897bd.630a0220.174d9.9d11@mx.google.com>

> > 
> > >  	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.

Yes, I know it's coming in as such - I believe it should be copying 16
bytes instead of the full keylen. TKIP keys are comprised of 16 bytes
encryption/decryption key and 8 bytes TX/RX MIC keys for a total of 32,
but since the device doesn't do MIC calculations, it only needs the
first 16 bytes here (if even that, since we also give it the P1K which
is derived from the TK...? maybe not even that)

But I guess we should test it ... not sure I still have a machine that
takes these NICs (I do have NICs).

johannes

  reply	other threads:[~2023-03-20 18:43 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
2023-03-20 18:34     ` Johannes Berg [this message]
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=0ec5fe8b6945ee545b335ef2f3bee75b0af458d0.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=benjamin.berg@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregory.greenman@intel.com \
    --cc=keescook@chromium.org \
    --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).