linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Ning Qiang <sohu0106@126.com>
Cc: dan.carpenter@oracle.com, greg@kroah.com, security@kernel.org,
	linux-mips@vger.kernel.org, tsbogend@alpha.franken.de
Subject: Re: [PATCH] MIPS: vpe: fix integer overflow in vpe_write()
Date: Thu, 14 Jul 2022 10:34:13 -0700	[thread overview]
Message-ID: <CAADWXX9rrESSEGmA4C9F85E9jo7H-pv+CUtyAU_kyB=DfcHRpA@mail.gmail.com> (raw)
In-Reply-To: <20220714141705.2375-1-sohu0106@126.com>

[ This was in my spambox, it may have been marked as spam for others too ]

On Thu, Jul 14, 2022 at 7:17 AM Ning Qiang <sohu0106@126.com> wrote:
>
> In the vpe_write function of arch/mips/kernel/vpe.c,parameter "size_t
> count" is pass by userland, if "count" is very large, it will bypass
> the check of "if ((count + v->len) > v->plen)".(such as
> count=0xffffffffffffffff).

We reject oversized IO requests to read/write, and clamp them at
MAX_RW_COUNT (which is basically INT_MAX rounded down to a page size).

Exactly to avoid issues like this.

So you shouldn't be able to pass in those kinds of counts, and it
won't be able to overflow the arithmetic unless 'v->len' can grow
boundlessly, which I don't think it can.

So I suspect this is not actually possible, but if you have a
test-case that shows me wrong, that woudl be interesing.

That said: that 'vpe_write()' thing is *odd*. Why is it using that
'v->len' thing, instead of using the passed-in offset?

So there is certainly somewhat strange code in there, and it would
probably be good to take a look at it. But being a very special MIPS
driver, I'm not sure how many people care...

               Linus

      parent reply	other threads:[~2022-07-14 17:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 14:17 [PATCH] MIPS: vpe: fix integer overflow in vpe_write() Ning Qiang
2022-07-14 14:21 ` Dan Carpenter
2022-07-14 17:34 ` Linus Torvalds [this message]

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='CAADWXX9rrESSEGmA4C9F85E9jo7H-pv+CUtyAU_kyB=DfcHRpA@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=greg@kroah.com \
    --cc=linux-mips@vger.kernel.org \
    --cc=security@kernel.org \
    --cc=sohu0106@126.com \
    --cc=tsbogend@alpha.franken.de \
    /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).