linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc:beyond ARRAY_SIZE of args.args
@ 2009-05-21 19:44 Roel Kluin
  2009-05-21 23:10 ` Paul Mackerras
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-05-21 19:44 UTC (permalink / raw)
  To: paulmck; +Cc: linuxppc-dev, Andrew Morton

Do not go beyond ARRAY_SIZE of args.args

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
I'm quite sure the first is correct, but should maybe `args.nret'
and `nargs + args.nret' also be `>= ARRAY_SIZE(args.args)'?

diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 1f8505c..c94ab76 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -779,7 +779,7 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
 		return -EFAULT;
 
 	nargs = args.nargs;
-	if (nargs > ARRAY_SIZE(args.args)
+	if (nargs >= ARRAY_SIZE(args.args)
 	    || args.nret > ARRAY_SIZE(args.args)
 	    || nargs + args.nret > ARRAY_SIZE(args.args))
 		return -EINVAL;

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

* Re: [PATCH] powerpc:beyond ARRAY_SIZE of args.args
  2009-05-21 19:44 [PATCH] powerpc:beyond ARRAY_SIZE of args.args Roel Kluin
@ 2009-05-21 23:10 ` Paul Mackerras
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2009-05-21 23:10 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linuxppc-dev, Andrew Morton, paulmck

Roel Kluin writes:

> Do not go beyond ARRAY_SIZE of args.args
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> I'm quite sure the first is correct, but should maybe `args.nret'
> and `nargs + args.nret' also be `>= ARRAY_SIZE(args.args)'?

I don't think this change is needed, and it changes a user-visible
API, so I'm nacking it unless you can convince me there's really a
problem.

If nargs == ARRAY_SIZE(args.args), then args.nret must be zero, so
nothing will access *(args.rets).

Paul.

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

end of thread, other threads:[~2009-05-21 23:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-21 19:44 [PATCH] powerpc:beyond ARRAY_SIZE of args.args Roel Kluin
2009-05-21 23:10 ` Paul Mackerras

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