mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: vme_user: Validate geoid used for VME window address
@ 2024-06-21 10:42 Aleksandr Mishin
  2024-06-21 11:10 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Aleksandr Mishin @ 2024-06-21 10:42 UTC (permalink / raw)
  To: Martyn Welch
  Cc: Aleksandr Mishin, Greg Kroah-Hartman, Soumya Negi,
	Michael Straube, linux-kernel, linux-staging, lvc-project

In tsi148_crcsr_init() value of vme_base used as 3rd parameter in
tsi148_master_set() call is calculated as 'vstat * 0x80000'. vstat value
can be set from module parameter "geoid" which can be any. In this case
the value of an arithmetic expression 'vstat * 0x80000' is a subject to
overflow because its operands are not cast to a larger data type before
performing arithmetic.

Add geoid validation to prevent overflow.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: d22b8ed9a3b0 ("Staging: vme: add Tundra TSI148 VME-PCI Bridge driver")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/staging/vme_user/vme_tsi148.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
index 2ec9c2904404..b601d2b20bed 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -2119,7 +2119,7 @@ static int tsi148_slot_get(struct vme_bridge *tsi148_bridge)
 		slot = ioread32be(bridge->base + TSI148_LCSR_VSTAT);
 		slot = slot & TSI148_LCSR_VSTAT_GA_M;
 	} else {
-		slot = geoid;
+		slot = geoid & TSI148_LCSR_VSTAT_GA_M;
 	}
 
 	return (int)slot;
-- 
2.30.2


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

end of thread, other threads:[~2024-07-01 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21 10:42 [PATCH] staging: vme_user: Validate geoid used for VME window address Aleksandr Mishin
2024-06-21 11:10 ` Dan Carpenter
2024-06-25  9:58   ` [PATCH v2] staging: vme_user: Validate geoid value " Aleksandr Mishin
2024-07-01 14:21     ` Dan Carpenter

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®