linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/ipic: Fix a bounds check in ipic_set_priority()
@ 2018-12-03 14:48 Dan Carpenter
  2018-12-05  3:26 ` Michael Ellerman
  0 siblings, 1 reply; 11+ messages in thread
From: Dan Carpenter @ 2018-12-03 14:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Kim Phillips
  Cc: kernel-janitors, Paul Mackerras, linuxppc-dev

The ipic_info[] array only has 95 elements so I have made the bounds
check smaller to prevent a read overflow.  It was Smatch that found
this issue:

    arch/powerpc/sysdev/ipic.c:784 ipic_set_priority()
    error: buffer overflow 'ipic_info' 95 <= 127

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I wasn't able to find any callers of this code.  Maybe we removed the
last one in commit b9f0f1bb2bca ("[POWERPC] Adapt ipic driver to new
host_ops interface, add set_irq_type to set IRQ sense").  So perhaps we
should just remove it.  I'm not really comfortable doing that myself,
because I don't know the code well enough and can't build test
it properly.

 arch/powerpc/sysdev/ipic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 6300123ce965..9d70d0687cd9 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -779,7 +779,7 @@ int ipic_set_priority(unsigned int virq, unsigned int priority)
 
 	if (priority > 7)
 		return -EINVAL;
-	if (src > 127)
+	if (src >= ARRAY_SIZE(ipic_info))
 		return -EINVAL;
 	if (ipic_info[src].prio == 0)
 		return -EINVAL;
-- 
2.11.0


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

end of thread, other threads:[~2018-12-11 14:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 14:48 [PATCH] powerpc/ipic: Fix a bounds check in ipic_set_priority() Dan Carpenter
2018-12-05  3:26 ` Michael Ellerman
2018-12-05  8:11   ` Julia Lawall
2018-12-05 12:04     ` Michael Ellerman
2018-12-05 12:06       ` Julia Lawall
2018-12-06  7:18   ` Christophe LEROY
2018-12-06  8:12     ` Julia Lawall
2018-12-11 14:26       ` Dan Carpenter
2018-12-07  2:07     ` Michael Ellerman
2018-12-10 12:05       ` Christophe Leroy
2018-12-06  9:34   ` Dan Carpenter

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