Skip to content

Commit 9f2c358

Browse files
jmberg-intelgregkh
authored andcommitted
cfg80211: limit wiphy names to 128 bytes
commit a7cfebc upstream. There's currently no limit on wiphy names, other than netlink message size and memory limitations, but that causes issues when, for example, the wiphy name is used in a uevent, e.g. in rfkill where we use the same name for the rfkill instance, and then the buffer there is "only" 2k for the environment variables. This was reported by syzkaller, which used a 4k name. Limit the name to something reasonable, I randomly picked 128. Reported-by: syzbot+230d9e642a85d3fec29c@syzkaller.appspotmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3609644 commit 9f2c358

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎include/uapi/linux/nl80211.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,8 @@ enum nl80211_attrs {
26042604
#define NL80211_ATTR_KEYS NL80211_ATTR_KEYS
26052605
#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
26062606

2607+
#define NL80211_WIPHY_NAME_MAXLEN 128
2608+
26072609
#define NL80211_MAX_SUPP_RATES 32
26082610
#define NL80211_MAX_SUPP_HT_RATES 77
26092611
#define NL80211_MAX_SUPP_REG_RULES 64

‎net/wireless/core.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev,
9595

9696
ASSERT_RTNL();
9797

98+
if (strlen(newname) > NL80211_WIPHY_NAME_MAXLEN)
99+
return -EINVAL;
100+
98101
/* prohibit calling the thing phy%d when %d is not its number */
99102
sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
100103
if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {

0 commit comments

Comments
 (0)