linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store()
@ 2023-03-22 20:03 Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message() Sasha Levin
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: NeilBrown, Dan Carpenter, Song Liu, Sasha Levin, linux-raid

From: NeilBrown <neilb@suse.de>

[ Upstream commit 3bc57292278a0b6ac4656cad94c14f2453344b57 ]

slot_store() uses kstrtouint() to get a slot number, but stores the
result in an "int" variable (by casting a pointer).
This can result in a negative slot number if the unsigned int value is
very large.

A negative number means that the slot is empty, but setting a negative
slot number this way will not remove the device from the array.  I don't
think this is a serious problem, but it could cause confusion and it is
best to fix it.

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/md/md.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 89d4dcc5253e5..f8c111b369928 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2991,6 +2991,9 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
 		err = kstrtouint(buf, 10, (unsigned int *)&slot);
 		if (err < 0)
 			return err;
+		if (slot < 0)
+			/* overflow */
+			return -ENOSPC;
 	}
 	if (rdev->mddev->pers && slot == -1) {
 		/* Setting 'slot' on an active array requires also
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message()
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 3/9] ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set() Sasha Levin
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Kuninori Morimoto, Takashi Iwai, Sasha Levin, perex, tiwai,
	dengshaomin, alsa-devel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

[ Upstream commit 9026c0bf233db53b86f74f4c620715e94eb32a09 ]

control_message() might be called with pao = NULL.
Here indicates control_message() as sample.

(B)	static void control_message(struct hpi_adapter_obj *pao, ...)
	{                                                   ^^^
		struct hpi_hw_obj *phw = pao->priv;
		...                      ^^^
	}

(A)	void _HPI_6205(struct hpi_adapter_obj *pao, ...)
	{                                      ^^^
		...
		case HPI_OBJ_CONTROL:
(B)			control_message(pao, phm, phr);
			break;          ^^^
		...
	}

	void HPI_6205(...)
	{
		...
(A)		_HPI_6205(NULL, phm, phr);
		...       ^^^^
	}

Therefore, We will get too many warning via cppcheck, like below

	sound/pci/asihpi/hpi6205.c:238:27: warning: Possible null pointer dereference: pao [nullPointer]
		 struct hpi_hw_obj *phw = pao->priv;
		                          ^
	sound/pci/asihpi/hpi6205.c:433:13: note: Calling function '_HPI_6205', 1st argument 'NULL' value is 0
		  _HPI_6205(NULL, phm, phr);
		            ^
	sound/pci/asihpi/hpi6205.c:401:20: note: Calling function 'control_message', 1st argument 'pao' value is 0
	   control_message(pao, phm, phr);
	                   ^
Set phr->error like many functions doing, and don't call _HPI_6205()
with NULL.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ttypeaqz.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/pci/asihpi/hpi6205.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index 2864698436a5f..6a49f897c4d91 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -441,7 +441,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr)
 		pao = hpi_find_adapter(phm->adapter_index);
 	} else {
 		/* subsys messages don't address an adapter */
-		_HPI_6205(NULL, phm, phr);
+		phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
 		return;
 	}
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 3/9] ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set()
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message() Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 4/9] fbdev: tgafb: Fix potential divide by zero Sasha Levin
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Kuninori Morimoto, Takashi Iwai, Sasha Levin, perex, tiwai, dev,
	ye.xingchen, gremlin, alsa-devel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

[ Upstream commit 98e5eb110095ec77cb6d775051d181edbf9cd3cf ]

tuning_ctl_set() might have buffer overrun at (X) if it didn't break
from loop by matching (A).

	static int tuning_ctl_set(...)
	{
		for (i = 0; i < TUNING_CTLS_COUNT; i++)
(A)			if (nid == ca0132_tuning_ctls[i].nid)
				break;

		snd_hda_power_up(...);
(X)		dspio_set_param(..., ca0132_tuning_ctls[i].mid, ...);
		snd_hda_power_down(...);                ^

		return 1;
	}

We will get below error by cppcheck

	sound/pci/hda/patch_ca0132.c:4229:2: note: After for loop, i has value 12
	 for (i = 0; i < TUNING_CTLS_COUNT; i++)
	 ^
	sound/pci/hda/patch_ca0132.c:4234:43: note: Array index out of bounds
	 dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20,
	                                           ^
This patch cares non match case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sfe9eap7.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/pci/hda/patch_ca0132.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index ca8a37388d565..9f0e6bbc523c3 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -3620,8 +3620,10 @@ static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid,
 
 	for (i = 0; i < TUNING_CTLS_COUNT; i++)
 		if (nid == ca0132_tuning_ctls[i].nid)
-			break;
+			goto found;
 
+	return -EINVAL;
+found:
 	snd_hda_power_up(codec);
 	dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20,
 			ca0132_tuning_ctls[i].req,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 4/9] fbdev: tgafb: Fix potential divide by zero
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message() Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 3/9] ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set() Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized Sasha Levin
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wei Chen, Helge Deller, Sasha Levin, tzimmermann, javierm,
	wsa+renesas, linux-fbdev, dri-devel

From: Wei Chen <harperchen1110@gmail.com>

[ Upstream commit f90bd245de82c095187d8c2cabb8b488a39eaecc ]

fb_set_var would by called when user invokes ioctl with cmd
FBIOPUT_VSCREENINFO. User-provided data would finally reach
tgafb_check_var. In case var->pixclock is assigned to zero,
divide by zero would occur when checking whether reciprocal
of var->pixclock is too high.

Similar crashes have happened in other fbdev drivers. There
is no check and modification on var->pixclock along the call
chain to tgafb_check_var. We believe it could also be triggered
in driver tgafb from user site.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/fbdev/tgafb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c
index 65ba9921506e2..9d2912947eef6 100644
--- a/drivers/video/fbdev/tgafb.c
+++ b/drivers/video/fbdev/tgafb.c
@@ -166,6 +166,9 @@ tgafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
 	struct tga_par *par = (struct tga_par *)info->par;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (par->tga_type == TGA_TYPE_8PLANE) {
 		if (var->bits_per_pixel != 8)
 			return -EINVAL;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
                   ` (2 preceding siblings ...)
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 4/9] fbdev: tgafb: Fix potential divide by zero Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 21:08   ` Linus Torvalds
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 6/9] fbdev: nvidia: Fix potential divide by zero Sasha Levin
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Linus Torvalds, Ryan Roberts, Yury Norov, Sasha Levin, mingo,
	peterz, juri.lelli, vincent.guittot

From: Linus Torvalds <torvalds@linux-foundation.org>

[ Upstream commit 6015b1aca1a233379625385feb01dd014aca60b5 ]

The getaffinity() system call uses 'cpumask_size()' to decide how big
the CPU mask is - so far so good.  It is indeed the allocation size of a
cpumask.

But the code also assumes that the whole allocation is initialized
without actually doing so itself.  That's wrong, because we might have
fixed-size allocations (making copying and clearing more efficient), but
not all of it is then necessarily used if 'nr_cpu_ids' is smaller.

Having checked other users of 'cpumask_size()', they all seem to be ok,
either using it purely for the allocation size, or explicitly zeroing
the cpumask before using the size in bytes to copy it.

See for example the ublk_ctrl_get_queue_affinity() function that uses
the proper 'zalloc_cpumask_var()' to make sure that the whole mask is
cleared, whether the storage is on the stack or if it was an external
allocation.

Fix this by just zeroing the allocation before using it.  Do the same
for the compat version of sched_getaffinity(), which had the same logic.

Also, for consistency, make sched_getaffinity() use 'cpumask_bits()' to
access the bits.  For a cpumask_var_t, it ends up being a pointer to the
same data either way, but it's just a good idea to treat it like you
would a 'cpumask_t'.  The compat case already did that.

Reported-by: Ryan Roberts <ryan.roberts@arm.com>
Link: https://lore.kernel.org/lkml/7d026744-6bd6-6827-0471-b5e8eae0be3f@arm.com/
Cc: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/compat.c     | 2 +-
 kernel/sched/core.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/compat.c b/kernel/compat.c
index e4548a9e9c52c..5f320b0db8d09 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -307,7 +307,7 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t,  pid, unsigned int, len,
 	if (len & (sizeof(compat_ulong_t)-1))
 		return -EINVAL;
 
-	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
 		return -ENOMEM;
 
 	ret = sched_getaffinity(pid, mask);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 46227cc48124d..bd06963fc331b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4950,14 +4950,14 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
 	if (len & (sizeof(unsigned long)-1))
 		return -EINVAL;
 
-	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
+	if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
 		return -ENOMEM;
 
 	ret = sched_getaffinity(pid, mask);
 	if (ret == 0) {
 		unsigned int retlen = min(len, cpumask_size());
 
-		if (copy_to_user(user_mask_ptr, mask, retlen))
+		if (copy_to_user(user_mask_ptr, cpumask_bits(mask), retlen))
 			ret = -EFAULT;
 		else
 			ret = retlen;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 6/9] fbdev: nvidia: Fix potential divide by zero
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
                   ` (3 preceding siblings ...)
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 7/9] fbdev: intelfb: " Sasha Levin
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wei Chen, Helge Deller, Sasha Levin, adaplas, linux-fbdev, dri-devel

From: Wei Chen <harperchen1110@gmail.com>

[ Upstream commit 92e2a00f2987483e1f9253625828622edd442e61 ]

variable var->pixclock can be set by user. In case it
equals to zero, divide by zero would occur in nvidiafb_set_par.

Similar crashes have happened in other fbdev drivers. There
is no check and modification on var->pixclock along the call
chain to nvidia_check_var and nvidiafb_set_par. We believe it
could also be triggered in driver nvidia from user site.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/fbdev/nvidia/nvidia.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
index fbeeed5afe350..aa502b3ba25ae 100644
--- a/drivers/video/fbdev/nvidia/nvidia.c
+++ b/drivers/video/fbdev/nvidia/nvidia.c
@@ -766,6 +766,8 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,
 	int pitch, err = 0;
 
 	NVTRACE_ENTER();
+	if (!var->pixclock)
+		return -EINVAL;
 
 	var->transp.offset = 0;
 	var->transp.length = 0;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 7/9] fbdev: intelfb: Fix potential divide by zero
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
                   ` (4 preceding siblings ...)
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 6/9] fbdev: nvidia: Fix potential divide by zero Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 8/9] fbdev: lxfb: " Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 9/9] fbdev: au1200fb: " Sasha Levin
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wei Chen, Helge Deller, Sasha Levin, mbroemme, linux-fbdev, dri-devel

From: Wei Chen <harperchen1110@gmail.com>

[ Upstream commit d823685486a3446d061fed7c7d2f80af984f119a ]

Variable var->pixclock is controlled by user and can be assigned
to zero. Without proper check, divide by zero would occur in
intelfbhw_validate_mode and intelfbhw_mode_to_hw.

Error out if var->pixclock is zero.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/fbdev/intelfb/intelfbdrv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c
index d7463a2a5d83f..c97c0c8514809 100644
--- a/drivers/video/fbdev/intelfb/intelfbdrv.c
+++ b/drivers/video/fbdev/intelfb/intelfbdrv.c
@@ -1215,6 +1215,9 @@ static int intelfb_check_var(struct fb_var_screeninfo *var,
 
 	dinfo = GET_DINFO(info);
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	/* update the pitch */
 	if (intelfbhw_validate_mode(dinfo, var) != 0)
 		return -EINVAL;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 8/9] fbdev: lxfb: Fix potential divide by zero
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
                   ` (5 preceding siblings ...)
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 7/9] fbdev: intelfb: " Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 9/9] fbdev: au1200fb: " Sasha Levin
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wei Chen, Helge Deller, Sasha Levin, dilinger, linux-geode,
	linux-fbdev, dri-devel

From: Wei Chen <harperchen1110@gmail.com>

[ Upstream commit 61ac4b86a4c047c20d5cb423ddd87496f14d9868 ]

var->pixclock can be assigned to zero by user. Without proper
check, divide by zero would occur in lx_set_clock.

Error out if var->pixclock is zero.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/fbdev/geode/lxfb_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/geode/lxfb_core.c b/drivers/video/fbdev/geode/lxfb_core.c
index 138da6cb6cbcd..4345246b4c798 100644
--- a/drivers/video/fbdev/geode/lxfb_core.c
+++ b/drivers/video/fbdev/geode/lxfb_core.c
@@ -247,6 +247,9 @@ static void get_modedb(struct fb_videomode **modedb, unsigned int *size)
 
 static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (var->xres > 1920 || var->yres > 1440)
 		return -EINVAL;
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH AUTOSEL 4.19 9/9] fbdev: au1200fb: Fix potential divide by zero
  2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
                   ` (6 preceding siblings ...)
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 8/9] fbdev: lxfb: " Sasha Levin
@ 2023-03-22 20:03 ` Sasha Levin
  7 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-22 20:03 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Wei Chen, Helge Deller, Sasha Levin, linux-fbdev, dri-devel

From: Wei Chen <harperchen1110@gmail.com>

[ Upstream commit 44a3b36b42acfc433aaaf526191dd12fbb919fdb ]

var->pixclock can be assigned to zero by user. Without
proper check, divide by zero would occur when invoking
macro PICOS2KHZ in au1200fb_fb_check_var.

Error out if var->pixclock is zero.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/video/fbdev/au1200fb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 3872ccef4cb2c..f8e83a9519189 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -1039,6 +1039,9 @@ static int au1200fb_fb_check_var(struct fb_var_screeninfo *var,
 	u32 pixclock;
 	int screen_size, plane;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	plane = fbdev->plane;
 
 	/* Make sure that the mode respect all LCD controller and
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized
  2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized Sasha Levin
@ 2023-03-22 21:08   ` Linus Torvalds
  2023-03-23 12:33     ` Sasha Levin
  0 siblings, 1 reply; 11+ messages in thread
From: Linus Torvalds @ 2023-03-22 21:08 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Ryan Roberts, Yury Norov, mingo, peterz,
	juri.lelli, vincent.guittot

On Wed, Mar 22, 2023 at 1:09 PM Sasha Levin <sashal@kernel.org> wrote:
>
> The getaffinity() system call uses 'cpumask_size()' to decide how big
> the CPU mask is - so far so good.  It is indeed the allocation size of a
> cpumask. [...]

Same comment as about commit 8ca09d5fa354 - this is a fine cleanup /
fix and might be worth backporting just for that, but it didn't really
turn into an actual visible bug until commit 596ff4a09b89.

                Linus

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized
  2023-03-22 21:08   ` Linus Torvalds
@ 2023-03-23 12:33     ` Sasha Levin
  0 siblings, 0 replies; 11+ messages in thread
From: Sasha Levin @ 2023-03-23 12:33 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: linux-kernel, stable, Ryan Roberts, Yury Norov, mingo, peterz,
	juri.lelli, vincent.guittot

On Wed, Mar 22, 2023 at 02:08:54PM -0700, Linus Torvalds wrote:
>On Wed, Mar 22, 2023 at 1:09 PM Sasha Levin <sashal@kernel.org> wrote:
>>
>> The getaffinity() system call uses 'cpumask_size()' to decide how big
>> the CPU mask is - so far so good.  It is indeed the allocation size of a
>> cpumask. [...]
>
>Same comment as about commit 8ca09d5fa354 - this is a fine cleanup /
>fix and might be worth backporting just for that, but it didn't really
>turn into an actual visible bug until commit 596ff4a09b89.

Ack, I'll keep it in anyway. Thanks!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-03-23 12:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 20:03 [PATCH AUTOSEL 4.19 1/9] md: avoid signed overflow in slot_store() Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 2/9] ALSA: asihpi: check pao in control_message() Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 3/9] ALSA: hda/ca0132: fixup buffer overrun at tuning_ctl_set() Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 4/9] fbdev: tgafb: Fix potential divide by zero Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 5/9] sched_getaffinity: don't assume 'cpumask_size()' is fully initialized Sasha Levin
2023-03-22 21:08   ` Linus Torvalds
2023-03-23 12:33     ` Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 6/9] fbdev: nvidia: Fix potential divide by zero Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 7/9] fbdev: intelfb: " Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 8/9] fbdev: lxfb: " Sasha Levin
2023-03-22 20:03 ` [PATCH AUTOSEL 4.19 9/9] fbdev: au1200fb: " Sasha Levin

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