linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Nathan Lynch <nathanl@linux.ibm.com>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH] powerpc/rtas: Prevent Spectre v1 gadget construction in sys_rtas()
Date: Fri, 31 May 2024 10:20:58 -0700	[thread overview]
Message-ID: <ZloG+sK1aZ7mSnKj@gmail.com> (raw)
In-Reply-To: <87le3q3p6r.fsf@li-e15d104c-2135-11b2-a85c-d7ef17e56be6.ibm.com>

On Fri, May 31, 2024 at 11:45:48AM -0500, Nathan Lynch wrote:
> Breno Leitao <leitao@debian.org> writes:
> 
> > On Thu, May 30, 2024 at 07:44:12PM -0500, Nathan Lynch via B4 Relay wrote:
> >> From: Nathan Lynch <nathanl@linux.ibm.com>

> >> +	nargs = array_index_nospec(nargs, ARRAY_SIZE(args.args));
> >> +	nret = array_index_nospec(nret, ARRAY_SIZE(args.args) - nargs);
> >
> > On an unrelated note, can nargs and nret are integers and could be
> > eventually negative. Is this a valid use case?
> 
> No, it's not valid for a caller to provide negative nargs or nret. I
> convinced myself that this bounds check:
> 
> 	nargs = be32_to_cpu(args.nargs);
> 	nret  = be32_to_cpu(args.nret);
> 
> 	if (nargs >= ARRAY_SIZE(args.args)
> 	    || nret > ARRAY_SIZE(args.args)
> 	    || nargs + nret > ARRAY_SIZE(args.args))
> 		return -EINVAL;
> 
> rejects negative values of nargs or nret due to C's "usual arithmetic
> conversions", where nargs and nret are implicitly converted to size_t
> for the comparisons.
> 
> However I don't see any value in keeping them as signed int. I have some
> changes in progress in this area and I'll plan on making these unsigned.

yea, I think it will help to make this code easier to read/review.

Thanks again for fixing it.

  reply	other threads:[~2024-05-31 17:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  0:44 [PATCH] powerpc/rtas: Prevent Spectre v1 gadget construction in sys_rtas() Nathan Lynch via B4 Relay
2024-05-31 13:45 ` Breno Leitao
2024-05-31 16:45   ` Nathan Lynch
2024-05-31 17:20     ` Breno Leitao [this message]
2024-07-06 23:10 ` Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2024-12-13  3:44 haixiao.yan.cn
2024-12-13 11:14 ` Greg KH
2024-12-13 11:15 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZloG+sK1aZ7mSnKj@gmail.com \
    --to=leitao@debian.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nathanl@linux.ibm.com \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=npiggin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).