mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: atomisp: reject short _DSM packages
@ 2026-11-03 11:41 Kang Chen
  2026-11-03 11:53 ` Andy Shevchenko
  2026-11-03 12:58 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Kang Chen @ 2026-11-03 11:41 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mauro Carvalho Chehab, Sakari Ailus, Andy Shevchenko,
	Greg Kroah-Hartman, Raushan Kumar, Chelsy Ratnawat, linux-media,
	linux-kernel, linux-staging

gmin_get_config_dsm_var() walks the package returned by the atomisp
_DSM function, but it does not reject packages with fewer than two
elements.  count is unsigned, so an empty package makes count - 1
evaluate to UINT_MAX and the loop walks far past the end of the
elements array, reading unrelated memory.

Require at least two elements before scanning the key/value pairs.

Fixes: 387041cda44e ("media: atomisp: improve sensor detection code to use _DSM table")
Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
---
 drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index d628fe4dca6d..159b72c1eb40 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -1167,6 +1167,13 @@ static int gmin_get_config_dsm_var(struct device *dev,
 		return -EINVAL;
 	}
 
+	if (obj->package.count < 2) {
+		dev_info(dev, "Invalid _DSM package count %u\n",
+			 obj->package.count);
+		ACPI_FREE(obj);
+		return -EINVAL;
+	}
+
 #if 0 /* Just for debugging purposes */
 	for (i = 0; i < obj->package.count; i++) {
 		union acpi_object *cur = &obj->package.elements[i];
-- 
2.34.1


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

* Re: [PATCH] media: atomisp: reject short _DSM packages
  2026-11-03 11:41 [PATCH] media: atomisp: reject short _DSM packages Kang Chen
@ 2026-11-03 11:53 ` Andy Shevchenko
  2026-11-03 12:58 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-11-03 11:53 UTC (permalink / raw)
  To: Kang Chen
  Cc: Hans de Goede, Mauro Carvalho Chehab, Sakari Ailus,
	Andy Shevchenko, Greg Kroah-Hartman, Raushan Kumar,
	Chelsy Ratnawat, linux-media, linux-kernel, linux-staging

On Tue, Nov 03, 2026 at 07:41:21PM +0800, Kang Chen wrote:
> gmin_get_config_dsm_var() walks the package returned by the atomisp
> _DSM function, but it does not reject packages with fewer than two
> elements.  count is unsigned, so an empty package makes count - 1
> evaluate to UINT_MAX and the loop walks far past the end of the
> elements array, reading unrelated memory.
> 
> Require at least two elements before scanning the key/value pairs.

Stop being a meat proxy to AI. Read the code.
NAK.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] media: atomisp: reject short _DSM packages
  2026-11-03 11:41 [PATCH] media: atomisp: reject short _DSM packages Kang Chen
  2026-11-03 11:53 ` Andy Shevchenko
@ 2026-11-03 12:58 ` Dan Carpenter
       [not found]   ` <tencent_283392A22C260EB0040CD271@qq.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2026-11-03 12:58 UTC (permalink / raw)
  To: Kang Chen
  Cc: Hans de Goede, Mauro Carvalho Chehab, Sakari Ailus,
	Andy Shevchenko, Greg Kroah-Hartman, Raushan Kumar,
	Chelsy Ratnawat, linux-media, linux-kernel, linux-staging

On Tue, Nov 03, 2026 at 07:41:21PM +0800, Kang Chen wrote:
> gmin_get_config_dsm_var() walks the package returned by the atomisp
> _DSM function, but it does not reject packages with fewer than two
> elements.  count is unsigned, so an empty package makes count - 1
> evaluate to UINT_MAX and the loop walks far past the end of the
> elements array, reading unrelated memory.
> 
> Require at least two elements before scanning the key/value pairs.
> 
> Fixes: 387041cda44e ("media: atomisp: improve sensor detection code to use _DSM table")
> Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
> ---

Surely, the infromation from ACPI is trusted?

regards,
dan carpenter


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

* Re: 回复:[PATCH] media: atomisp: reject short _DSM packages
       [not found]   ` <tencent_283392A22C260EB0040CD271@qq.com>
@ 2026-11-03 14:04     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-11-03 14:04 UTC (permalink / raw)
  To: Kang Chen
  Cc: Dan Carpenter, Hans de Goede, Mauro Carvalho Chehab,
	Sakari Ailus, Andy Shevchenko, Raushan Kumar, Chelsy Ratnawat,
	linux-media, linux-kernel, linux-staging

On Tue, Nov 03, 2026 at 09:13:16PM +0800, Kang Chen wrote:
> No. In the confidential computing (CVM) threat model, ACPI tables are
> controlled by the host and are untrusted; BadAML (CCS'25) shows malicious
> ACPI/AML can be used to attack the guest.&nbsp;
> And the kernel already validates many ACPI return values
> (e.g. types, package counts, bounds).

Are you sure that Linux supports that threat model at this point in
time?  And that this matters for this specific driver?  I doubt that
this media driver would ever be seriously considered for those types of
situations :)

thanks,

greg k-h

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

end of thread, other threads:[~2026-11-03 14:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 11:41 [PATCH] media: atomisp: reject short _DSM packages Kang Chen
2026-11-03 11:53 ` Andy Shevchenko
2026-11-03 12:58 ` Dan Carpenter
     [not found]   ` <tencent_283392A22C260EB0040CD271@qq.com>
2026-11-03 14:04     ` 回复:[PATCH] " Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®