mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Stefan Berger' <stefanb@linux.ibm.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	"linux-integrity@vger.kernel.org"
	<linux-integrity@vger.kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>,
	Alejandro Cabrera <alejandro.cabreraaldaya@tuni.fi>,
	Jarkko Sakkinen <jarkko.sakkinen@tuni.fi>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	Stefan Berger <stefanb@linux.vnet.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH RFC v2] tpm: tpm_vtpm_proxy: do not reference kernel memory as user memory
Date: Wed, 31 May 2023 07:47:30 +0000	[thread overview]
Message-ID: <26ee6ae4411645b99c351917b38d9b83@AcuMS.aculab.com> (raw)
In-Reply-To: <b2657b55-355d-80cb-23cc-d11825f64ad1@linux.ibm.com>

From: Stefan Berger
> Sent: 30 May 2023 18:46
> 
> On 5/29/23 22:01, Jarkko Sakkinen wrote:
> > From: Jarkko Sakkinen <jarkko.sakkinen@tuni.fi>
> >
> 
> > -	rc = copy_to_user(buf, proxy_dev->buffer, len);
> > +	if (buf)
> > +		rc = copy_to_user(buf, proxy_dev->buffer, len);
> > +
> 
> Looking through other drivers it seems buf is always expected to be a valid non-NULL pointer on
> file_operations.read().

If the user passes NULL the copy_to/from_user() fails and
-EFAULT is returned.

Adding the NULL check makes the request silently succeed.
I doubt that is anywhere near right when you ignore copy_from_user().

I'm not sure what the rational/subject is about either.
copy_to/from_user() calls access_ok() and will fail on
a kernel address.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2023-05-31  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30  2:01 Jarkko Sakkinen
2023-05-30 17:36 ` Stefan Berger
2023-05-30 17:45 ` Stefan Berger
2023-05-31  7:47   ` David Laight [this message]
2023-05-31 17:17   ` Jarkko Sakkinen
2023-05-31 17:20     ` Stefan Berger

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=26ee6ae4411645b99c351917b38d9b83@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=alejandro.cabreraaldaya@tuni.fi \
    --cc=jarkko.sakkinen@tuni.fi \
    --cc=jarkko@kernel.org \
    --cc=jgg@nvidia.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefanb@linux.ibm.com \
    --cc=stefanb@linux.vnet.ibm.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

all inboxes | Powered by JetHome®