LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: NAME <sohu0106@126.com>
Cc: security@kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] macintosh:fix oob read in do_adb_query function
Date: Wed, 13 Jul 2022 16:03:11 +0200	[thread overview]
Message-ID: <Ys7Qn8dlIbkH/2O0@kroah.com> (raw)
In-Reply-To: <20220713134037.2331-1-sohu0106@126.com>

On Wed, Jul 13, 2022 at 09:40:37PM +0800, NAME wrote:
> From: sohu0106 <sohu0106@126.com>

For obvious reasons, we need a real name here, and in the signed-off-by
line.

> In do_adb_query function of drivers/macintosh/adb.c,
> req->data is copy form userland. The parameter
> "req->data[2]" is Missing check, the array size of
> adb_handler[] is 16, so "adb_handler[req->data[2]].
> original_address" and "adb_handler[req->data[2]].
> handler_id" will lead to oob read.

You can use all 72 columns, if you want to re-wrap these lines when you
resend.

> 
> Signed-off-by: sohu0106 <sohu0106@126.com>
> ---
>  drivers/macintosh/adb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
> index 439fab4eaa85..1bbb9ca08d40 100644
> --- a/drivers/macintosh/adb.c
> +++ b/drivers/macintosh/adb.c
> @@ -647,7 +647,7 @@ do_adb_query(struct adb_request *req)
>  
>  	switch(req->data[1]) {
>  	case ADB_QUERY_GETDEVINFO:
> -		if (req->nbytes < 3)
> +		if (req->nbytes < 3 || req->data[2] >= 16)

Shouldn't 16 be the array size instead of having this hard coded to a
magic number?

Something like "sizeof(adb_handler) / sizeof(struct adb_handler)"?

Maybe not, that's messy, your choice.

thanks,

greg k-h

  reply	other threads:[~2022-07-13 14:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 13:40 [PATCH] macintosh:fix oob read in do_adb_query function NAME
2022-07-13 14:03 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-13 15:37 Ning Qiang
2022-07-13 16:43 ` Greg KH
2022-07-13 18:53 ` Kees Cook
2022-07-14 22:33   ` Benjamin Herrenschmidt
2022-07-14 22:33 ` Benjamin Herrenschmidt
2022-07-29 13:01 ` Michael Ellerman

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=Ys7Qn8dlIbkH/2O0@kroah.com \
    --to=greg@kroah.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=security@kernel.org \
    --cc=sohu0106@126.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