From 79a6bd975436d844153a2922e0c7157d22f388b2 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 5 Sep 2022 08:52:12 -0400 Subject: [PATCH] Fixes for 4.9 Signed-off-by: Sasha Levin --- ...avoid-potential-divide-by-zero-error.patch | 53 +++++++++++++++ ...-pmc_atom-fix-slp_typx-bitfield-mask.patch | 67 +++++++++++++++++++ queue-4.9/series | 3 + ...bugfs-fix-return-type-in-ht40allow_m.patch | 41 ++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 queue-4.9/fbdev-fb_pm2fb-avoid-potential-divide-by-zero-error.patch create mode 100644 queue-4.9/platform-x86-pmc_atom-fix-slp_typx-bitfield-mask.patch create mode 100644 queue-4.9/series create mode 100644 queue-4.9/wifi-cfg80211-debugfs-fix-return-type-in-ht40allow_m.patch diff --git a/queue-4.9/fbdev-fb_pm2fb-avoid-potential-divide-by-zero-error.patch b/queue-4.9/fbdev-fb_pm2fb-avoid-potential-divide-by-zero-error.patch new file mode 100644 index 00000000000..f4359f4f6a4 --- /dev/null +++ b/queue-4.9/fbdev-fb_pm2fb-avoid-potential-divide-by-zero-error.patch @@ -0,0 +1,53 @@ +From a60919a7c9b888edd3a17478c9c10affa493aa79 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 18 Aug 2022 18:44:24 +0800 +Subject: fbdev: fb_pm2fb: Avoid potential divide by zero error + +From: Letu Ren + +commit 19f953e7435644b81332dd632ba1b2d80b1e37af upstream. + +In `do_fb_ioctl()` of fbmem.c, if cmd is FBIOPUT_VSCREENINFO, var will be +copied from user, then go through `fb_set_var()` and +`info->fbops->fb_check_var()` which could may be `pm2fb_check_var()`. +Along the path, `var->pixclock` won't be modified. This function checks +whether reciprocal of `var->pixclock` is too high. If `var->pixclock` is +zero, there will be a divide by zero error. So, it is necessary to check +whether denominator is zero to avoid crash. As this bug is found by +Syzkaller, logs are listed below. + +divide error in pm2fb_check_var +Call Trace: + + fb_set_var+0x367/0xeb0 drivers/video/fbdev/core/fbmem.c:1015 + do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1110 + fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1189 + +Reported-by: Zheyu Ma +Signed-off-by: Letu Ren +Signed-off-by: Helge Deller +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/video/fbdev/pm2fb.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c +index 9b32b9fc44a5c..50b569d047b10 100644 +--- a/drivers/video/fbdev/pm2fb.c ++++ b/drivers/video/fbdev/pm2fb.c +@@ -619,6 +619,11 @@ static int pm2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) + return -EINVAL; + } + ++ if (!var->pixclock) { ++ DPRINTK("pixclock is zero\n"); ++ return -EINVAL; ++ } ++ + if (PICOS2KHZ(var->pixclock) > PM2_MAX_PIXCLOCK) { + DPRINTK("pixclock too high (%ldKHz)\n", + PICOS2KHZ(var->pixclock)); +-- +2.35.1 + diff --git a/queue-4.9/platform-x86-pmc_atom-fix-slp_typx-bitfield-mask.patch b/queue-4.9/platform-x86-pmc_atom-fix-slp_typx-bitfield-mask.patch new file mode 100644 index 00000000000..fa1789eb13c --- /dev/null +++ b/queue-4.9/platform-x86-pmc_atom-fix-slp_typx-bitfield-mask.patch @@ -0,0 +1,67 @@ +From e7d23a9e10822ef6dbf6a3db626e7839fef22ba6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 1 Aug 2022 14:37:31 +0300 +Subject: platform/x86: pmc_atom: Fix SLP_TYPx bitfield mask + +From: Andy Shevchenko + +[ Upstream commit 0a90ed8d0cfa29735a221eba14d9cb6c735d35b6 ] + +On Intel hardware the SLP_TYPx bitfield occupies bits 10-12 as per ACPI +specification (see Table 4.13 "PM1 Control Registers Fixed Hardware +Feature Control Bits" for the details). + +Fix the mask and other related definitions accordingly. + +Fixes: 93e5eadd1f6e ("x86/platform: New Intel Atom SOC power management controller driver") +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20220801113734.36131-1-andriy.shevchenko@linux.intel.com +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +Signed-off-by: Sasha Levin +--- + arch/x86/include/asm/pmc_atom.h | 6 ++++-- + arch/x86/platform/atom/pmc_atom.c | 2 +- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/arch/x86/include/asm/pmc_atom.h b/arch/x86/include/asm/pmc_atom.h +index aa8744c77c6d9..b25ac6eb1fdee 100644 +--- a/arch/x86/include/asm/pmc_atom.h ++++ b/arch/x86/include/asm/pmc_atom.h +@@ -16,6 +16,8 @@ + #ifndef PMC_ATOM_H + #define PMC_ATOM_H + ++#include ++ + /* ValleyView Power Control Unit PCI Device ID */ + #define PCI_DEVICE_ID_VLV_PMC 0x0F1C + /* CherryTrail Power Control Unit PCI Device ID */ +@@ -148,9 +150,9 @@ + #define ACPI_MMIO_REG_LEN 0x100 + + #define PM1_CNT 0x4 +-#define SLEEP_TYPE_MASK 0xFFFFECFF ++#define SLEEP_TYPE_MASK GENMASK(12, 10) + #define SLEEP_TYPE_S5 0x1C00 +-#define SLEEP_ENABLE 0x2000 ++#define SLEEP_ENABLE BIT(13) + + extern int pmc_atom_read(int offset, u32 *value); + extern int pmc_atom_write(int offset, u32 value); +diff --git a/arch/x86/platform/atom/pmc_atom.c b/arch/x86/platform/atom/pmc_atom.c +index 964ff4fc61f9b..b5b371d959141 100644 +--- a/arch/x86/platform/atom/pmc_atom.c ++++ b/arch/x86/platform/atom/pmc_atom.c +@@ -213,7 +213,7 @@ static void pmc_power_off(void) + pm1_cnt_port = acpi_base_addr + PM1_CNT; + + pm1_cnt_value = inl(pm1_cnt_port); +- pm1_cnt_value &= SLEEP_TYPE_MASK; ++ pm1_cnt_value &= ~SLEEP_TYPE_MASK; + pm1_cnt_value |= SLEEP_TYPE_S5; + pm1_cnt_value |= SLEEP_ENABLE; + +-- +2.35.1 + diff --git a/queue-4.9/series b/queue-4.9/series new file mode 100644 index 00000000000..efb5a81ff4c --- /dev/null +++ b/queue-4.9/series @@ -0,0 +1,3 @@ +fbdev-fb_pm2fb-avoid-potential-divide-by-zero-error.patch +platform-x86-pmc_atom-fix-slp_typx-bitfield-mask.patch +wifi-cfg80211-debugfs-fix-return-type-in-ht40allow_m.patch diff --git a/queue-4.9/wifi-cfg80211-debugfs-fix-return-type-in-ht40allow_m.patch b/queue-4.9/wifi-cfg80211-debugfs-fix-return-type-in-ht40allow_m.patch new file mode 100644 index 00000000000..a639531f50f --- /dev/null +++ b/queue-4.9/wifi-cfg80211-debugfs-fix-return-type-in-ht40allow_m.patch @@ -0,0 +1,41 @@ +From 4ffd95fc250d99695c775513385835af2bdc471d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 4 Aug 2022 10:03:21 +0300 +Subject: wifi: cfg80211: debugfs: fix return type in ht40allow_map_read() + +From: Dan Carpenter + +[ Upstream commit d776763f48084926b5d9e25507a3ddb7c9243d5e ] + +The return type is supposed to be ssize_t, which is signed long, +but "r" was declared as unsigned int. This means that on 64 bit systems +we return positive values instead of negative error codes. + +Fixes: 80a3511d70e8 ("cfg80211: add debugfs HT40 allow map") +Signed-off-by: Dan Carpenter +Link: https://lore.kernel.org/r/YutvOQeJm0UjLhwU@kili +Signed-off-by: Johannes Berg +Signed-off-by: Sasha Levin +--- + net/wireless/debugfs.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c +index 5d453916a4179..6a7f4432440a5 100644 +--- a/net/wireless/debugfs.c ++++ b/net/wireless/debugfs.c +@@ -68,9 +68,10 @@ static ssize_t ht40allow_map_read(struct file *file, + { + struct wiphy *wiphy = file->private_data; + char *buf; +- unsigned int offset = 0, buf_size = PAGE_SIZE, i, r; ++ unsigned int offset = 0, buf_size = PAGE_SIZE, i; + enum nl80211_band band; + struct ieee80211_supported_band *sband; ++ ssize_t r; + + buf = kzalloc(buf_size, GFP_KERNEL); + if (!buf) +-- +2.35.1 + -- 2.47.3