From: Kees Cook <keescook@chromium.org>
To: Gregory Greenman <gregory.greenman@intel.com>
Cc: Kees Cook <keescook@chromium.org>, 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>,
Johannes Berg <johannes.berg@intel.com>,
Benjamin Berg <benjamin.berg@intel.com>,
Sriram R <quic_srirrama@quicinc.com>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH] wifi: iwlwifi: dvm: Add struct_group for struct iwl_keyinfo keys
Date: Sat, 18 Feb 2023 11:11:00 -0800 [thread overview]
Message-ID: <20230218191056.never.374-kees@kernel.org> (raw)
Function iwlagn_send_sta_key() was trying to write across multiple
structure members in a single memcpy(). Add a struct group "keys" to
let the compiler see the intended bounds of the memcpy, which includes
the tkip keys as well. Silences false positive memcpy() run-time
warning:
memcpy: detected field-spanning write (size 32) of single field "sta_cmd.key.key" at drivers/net/wireless/intel/iwlwifi/dvm/sta.c:1103 (size 16)
Link: https://www.alionet.org/index.php?topic=1469.0
Cc: Gregory Greenman <gregory.greenman@intel.com>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Benjamin Berg <benjamin.berg@intel.com>
Cc: Sriram R <quic_srirrama@quicinc.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/net/wireless/intel/iwlwifi/dvm/commands.h | 10 ++++++----
drivers/net/wireless/intel/iwlwifi/dvm/sta.c | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/commands.h b/drivers/net/wireless/intel/iwlwifi/dvm/commands.h
index 75a4b8e26232..0eceac4b9131 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/commands.h
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/commands.h
@@ -783,10 +783,12 @@ struct iwl_keyinfo {
__le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */
u8 key_offset;
u8 reserved2;
- u8 key[16]; /* 16-byte unicast decryption key */
- __le64 tx_secur_seq_cnt;
- __le64 hw_tkip_mic_rx_key;
- __le64 hw_tkip_mic_tx_key;
+ struct_group(keys,
+ u8 key[16]; /* 16-byte unicast decryption key */
+ __le64 tx_secur_seq_cnt;
+ __le64 hw_tkip_mic_rx_key;
+ __le64 hw_tkip_mic_tx_key;
+ );
} __packed;
/**
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
index cef43cf80620..a1c9e201b058 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
@@ -1093,14 +1093,14 @@ static int iwlagn_send_sta_key(struct iwl_priv *priv,
switch (keyconf->cipher) {
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);
break;
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);
break;
case WLAN_CIPHER_SUITE_WEP104:
key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
--
2.34.1
next reply other threads:[~2023-02-18 19:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 19:11 Kees Cook [this message]
2023-02-19 13:41 ` [PATCH] wifi: iwlwifi: dvm: Add struct_group for struct iwl_keyinfo keys Simon Horman
2023-02-19 15:12 ` Johannes Berg
2023-03-20 17:28 ` Kees Cook
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=20230218191056.never.374-kees@kernel.org \
--to=keescook@chromium.org \
--cc=benjamin.berg@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.greenman@intel.com \
--cc=johannes.berg@intel.com \
--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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.