From: Greg KH <greg@kroah.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Gwendal Grignou <gwendal@chromium.org>,
stable@vger.kernel.org, Olof Johansson <olof@lixom.net>
Subject: Re: [PATCH] platform/chrome: cros_ec_dev - Fix security issue
Date: Thu, 18 Mar 2021 09:09:21 +0100 [thread overview]
Message-ID: <YFMKsRWTIDeeuEEk@kroah.com> (raw)
In-Reply-To: <20210318075443.GB2916463@dell>
On Thu, Mar 18, 2021 at 07:54:43AM +0000, Lee Jones wrote:
> On Wed, 17 Mar 2021, Gwendal Grignou wrote:
>
> > commit 5d749d0bbe811c10d9048cde6dfebc761713abfd upstream.
> >
> > Prevent memory scribble by checking that ioctl buffer size parameters
> > are sane.
> > Without this check, on 32 bits system, if .insize = 0xffffffff - 20 and
> > .outsize the amount to scribble, we would overflow, allocate a small
> > amounts and be able to write outside of the malloc'ed area.
> > Adding a hard limit allows argument checking of the ioctl. With the
> > current EC, it is expected .insize and .outsize to be at around 512 bytes
> > or less.
> >
> > Signed-off-by: Olof Johansson <olof@lixom.net>
> > Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> > ---
> > drivers/platform/chrome/cros_ec_dev.c | 4 ++++
> > drivers/platform/chrome/cros_ec_proto.c | 4 ++--
> > include/linux/mfd/cros_ec.h | 6 ++++--
> > 3 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/platform/chrome/cros_ec_dev.c b/drivers/platform/chrome/cros_ec_dev.c
> > index 2b331d5b9e799..e16d82bb36a9d 100644
> > --- a/drivers/platform/chrome/cros_ec_dev.c
> > +++ b/drivers/platform/chrome/cros_ec_dev.c
> > @@ -137,6 +137,10 @@ static long ec_device_ioctl_xcmd(struct cros_ec_dev *ec, void __user *arg)
> > if (copy_from_user(&u_cmd, arg, sizeof(u_cmd)))
> > return -EFAULT;
> >
> > + if ((u_cmd.outsize > EC_MAX_MSG_BYTES) ||
> > + (u_cmd.insize > EC_MAX_MSG_BYTES))
> > + return -EINVAL;
> > +
> > s_cmd = kmalloc(sizeof(*s_cmd) + max(u_cmd.outsize, u_cmd.insize),
> > GFP_KERNEL);
> > if (!s_cmd)
> > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
> > index 5c285f2b3a650..d20190c8f0c06 100644
> > --- a/drivers/platform/chrome/cros_ec_proto.c
> > +++ b/drivers/platform/chrome/cros_ec_proto.c
> > @@ -311,8 +311,8 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev)
> > ec_dev->max_response = EC_PROTO2_MAX_PARAM_SIZE;
> > ec_dev->max_passthru = 0;
> > ec_dev->pkt_xfer = NULL;
> > - ec_dev->din_size = EC_MSG_BYTES;
> > - ec_dev->dout_size = EC_MSG_BYTES;
> > + ec_dev->din_size = EC_PROTO2_MSG_BYTES;
> > + ec_dev->dout_size = EC_PROTO2_MSG_BYTES;
> > } else {
> > /*
> > * It's possible for a test to occur too early when
> > diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
> > index 3ab3cede28eac..93c14e9df6309 100644
> > --- a/include/linux/mfd/cros_ec.h
> > +++ b/include/linux/mfd/cros_ec.h
> > @@ -50,9 +50,11 @@ enum {
> > EC_MSG_TX_TRAILER_BYTES,
> > EC_MSG_RX_PROTO_BYTES = 3,
> >
> > - /* Max length of messages */
> > - EC_MSG_BYTES = EC_PROTO2_MAX_PARAM_SIZE +
> > + /* Max length of messages for proto 2*/
> > + EC_PROTO2_MSG_BYTES = EC_PROTO2_MAX_PARAM_SIZE +
> > EC_MSG_TX_PROTO_BYTES,
>
> Nit: Better to not tab the '=' so far and place it all on one line.
>
> Checkpatch now only complains about lines exceeding 100 chars.
>
> Once fixed, feel free to apply my:
>
> Acked-by: Lee Jones <lee.jones@linaro.org>
This commit is already in 4.7, and is from 2016, so I don't know why you
are reviewing it :)
thanks,
greg k-h
next prev parent reply other threads:[~2021-03-18 8:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 23:55 [PATCH] platform/chrome: cros_ec_dev - Fix security issue Gwendal Grignou
2021-03-18 5:51 ` Greg KH
2021-03-18 7:54 ` Lee Jones
2021-03-18 8:09 ` Greg KH [this message]
2021-03-18 8:20 ` Lee Jones
2021-03-18 18:08 ` Gwendal Grignou
-- strict thread matches above, loose matches on Subject: below --
2016-03-01 20:33 Security hole in cros_ec_dev.c on 32bit chrome hosts Alan Cox
2016-03-03 5:58 ` [PATCH] platform/chrome: cros_ec_dev - Fix security issue Gwendal Grignou
2016-03-03 18:35 ` Randy Dunlap
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=YFMKsRWTIDeeuEEk@kroah.com \
--to=greg@kroah.com \
--cc=gwendal@chromium.org \
--cc=lee.jones@linaro.org \
--cc=olof@lixom.net \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.