wifi: rtw89: fw: add blacklist to avoid obsolete secure firmware
[ Upstream commit f11d042b3a2e92ab1aa10e0da8e290bcdcf31d39 ] To ensure secure chip only runs expected secure firmware, stop using obsolete firmware in blacklist which weakness or flaw was found. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250217064308.43559-2-pkshih@realtek.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6ffcf25e63
commit
7dafba4e85
@@ -17,6 +17,7 @@ struct rtw89_dev;
|
||||
struct rtw89_pci_info;
|
||||
struct rtw89_mac_gen_def;
|
||||
struct rtw89_phy_gen_def;
|
||||
struct rtw89_fw_blacklist;
|
||||
struct rtw89_efuse_block_cfg;
|
||||
struct rtw89_h2c_rf_tssi;
|
||||
struct rtw89_fw_txpwr_track_cfg;
|
||||
@@ -4232,6 +4233,7 @@ struct rtw89_chip_info {
|
||||
bool try_ce_fw;
|
||||
u8 bbmcu_nr;
|
||||
u32 needed_fw_elms;
|
||||
const struct rtw89_fw_blacklist *fw_blacklist;
|
||||
u32 fifo_size;
|
||||
bool small_fifo_size;
|
||||
u32 dle_scc_rsvd_size;
|
||||
|
||||
@@ -38,6 +38,16 @@ struct rtw89_arp_rsp {
|
||||
|
||||
static const u8 mss_signature[] = {0x4D, 0x53, 0x53, 0x4B, 0x50, 0x4F, 0x4F, 0x4C};
|
||||
|
||||
const struct rtw89_fw_blacklist rtw89_fw_blacklist_default = {
|
||||
.ver = 0x00,
|
||||
.list = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
},
|
||||
};
|
||||
EXPORT_SYMBOL(rtw89_fw_blacklist_default);
|
||||
|
||||
union rtw89_fw_element_arg {
|
||||
size_t offset;
|
||||
enum rtw89_rf_path rf_path;
|
||||
@@ -315,6 +325,46 @@ ignore:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __check_secure_blacklist(struct rtw89_dev *rtwdev,
|
||||
struct rtw89_fw_bin_info *info,
|
||||
struct rtw89_fw_hdr_section_info *section_info,
|
||||
const void *content)
|
||||
{
|
||||
const struct rtw89_fw_blacklist *chip_blacklist = rtwdev->chip->fw_blacklist;
|
||||
const union rtw89_fw_section_mssc_content *section_content = content;
|
||||
struct rtw89_fw_secure *sec = &rtwdev->fw.sec;
|
||||
u8 byte_idx;
|
||||
u8 bit_mask;
|
||||
|
||||
if (!sec->secure_boot)
|
||||
return 0;
|
||||
|
||||
if (!info->secure_section_exist || section_info->ignore)
|
||||
return 0;
|
||||
|
||||
if (!chip_blacklist) {
|
||||
rtw89_err(rtwdev, "chip no blacklist for secure firmware\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
byte_idx = section_content->blacklist.bit_in_chip_list >> 3;
|
||||
bit_mask = BIT(section_content->blacklist.bit_in_chip_list & 0x7);
|
||||
|
||||
if (section_content->blacklist.ver > chip_blacklist->ver) {
|
||||
rtw89_err(rtwdev, "chip blacklist out of date (%u, %u)\n",
|
||||
section_content->blacklist.ver, chip_blacklist->ver);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (chip_blacklist->list[byte_idx] & bit_mask) {
|
||||
rtw89_err(rtwdev, "firmware %u in chip blacklist\n",
|
||||
section_content->blacklist.ver);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __parse_security_section(struct rtw89_dev *rtwdev,
|
||||
struct rtw89_fw_bin_info *info,
|
||||
struct rtw89_fw_hdr_section_info *section_info,
|
||||
@@ -340,7 +390,7 @@ static int __parse_security_section(struct rtw89_dev *rtwdev,
|
||||
info->secure_section_exist = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return __check_secure_blacklist(rtwdev, info, section_info, content);
|
||||
}
|
||||
|
||||
static int rtw89_fw_hdr_parser_v1(struct rtw89_dev *rtwdev, const u8 *fw, u32 len,
|
||||
|
||||
@@ -639,6 +639,11 @@ struct rtw89_fw_mss_pool_hdr {
|
||||
} __packed;
|
||||
|
||||
union rtw89_fw_section_mssc_content {
|
||||
struct {
|
||||
u8 pad[0x20];
|
||||
u8 bit_in_chip_list;
|
||||
u8 ver;
|
||||
} __packed blacklist;
|
||||
struct {
|
||||
u8 pad[58];
|
||||
__le32 v;
|
||||
@@ -649,6 +654,13 @@ union rtw89_fw_section_mssc_content {
|
||||
} __packed key_sign_len;
|
||||
} __packed;
|
||||
|
||||
struct rtw89_fw_blacklist {
|
||||
u8 ver;
|
||||
u8 list[32];
|
||||
};
|
||||
|
||||
extern const struct rtw89_fw_blacklist rtw89_fw_blacklist_default;
|
||||
|
||||
static inline void SET_CTRL_INFO_MACID(void *table, u32 val)
|
||||
{
|
||||
le32p_replace_bits((__le32 *)(table) + 0, val, GENMASK(6, 0));
|
||||
|
||||
@@ -2443,6 +2443,7 @@ const struct rtw89_chip_info rtw8851b_chip_info = {
|
||||
.try_ce_fw = true,
|
||||
.bbmcu_nr = 0,
|
||||
.needed_fw_elms = 0,
|
||||
.fw_blacklist = NULL,
|
||||
.fifo_size = 196608,
|
||||
.small_fifo_size = true,
|
||||
.dle_scc_rsvd_size = 98304,
|
||||
|
||||
@@ -2159,6 +2159,7 @@ const struct rtw89_chip_info rtw8852a_chip_info = {
|
||||
.try_ce_fw = false,
|
||||
.bbmcu_nr = 0,
|
||||
.needed_fw_elms = 0,
|
||||
.fw_blacklist = NULL,
|
||||
.fifo_size = 458752,
|
||||
.small_fifo_size = false,
|
||||
.dle_scc_rsvd_size = 0,
|
||||
|
||||
@@ -797,6 +797,7 @@ const struct rtw89_chip_info rtw8852b_chip_info = {
|
||||
.try_ce_fw = true,
|
||||
.bbmcu_nr = 0,
|
||||
.needed_fw_elms = 0,
|
||||
.fw_blacklist = &rtw89_fw_blacklist_default,
|
||||
.fifo_size = 196608,
|
||||
.small_fifo_size = true,
|
||||
.dle_scc_rsvd_size = 98304,
|
||||
|
||||
@@ -731,6 +731,7 @@ const struct rtw89_chip_info rtw8852bt_chip_info = {
|
||||
.try_ce_fw = true,
|
||||
.bbmcu_nr = 0,
|
||||
.needed_fw_elms = RTW89_AX_GEN_DEF_NEEDED_FW_ELEMENTS_NO_6GHZ,
|
||||
.fw_blacklist = &rtw89_fw_blacklist_default,
|
||||
.fifo_size = 458752,
|
||||
.small_fifo_size = true,
|
||||
.dle_scc_rsvd_size = 98304,
|
||||
|
||||
@@ -2936,6 +2936,7 @@ const struct rtw89_chip_info rtw8852c_chip_info = {
|
||||
.try_ce_fw = false,
|
||||
.bbmcu_nr = 0,
|
||||
.needed_fw_elms = 0,
|
||||
.fw_blacklist = &rtw89_fw_blacklist_default,
|
||||
.fifo_size = 458752,
|
||||
.small_fifo_size = false,
|
||||
.dle_scc_rsvd_size = 0,
|
||||
|
||||
@@ -2632,6 +2632,7 @@ const struct rtw89_chip_info rtw8922a_chip_info = {
|
||||
.try_ce_fw = false,
|
||||
.bbmcu_nr = 1,
|
||||
.needed_fw_elms = RTW89_BE_GEN_DEF_NEEDED_FW_ELEMENTS,
|
||||
.fw_blacklist = &rtw89_fw_blacklist_default,
|
||||
.fifo_size = 589824,
|
||||
.small_fifo_size = false,
|
||||
.dle_scc_rsvd_size = 0,
|
||||
|
||||
Reference in New Issue
Block a user