mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Gardner <gardner.ben@gmail.com>
To: Michael Buesch <mb@bu3sch.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: FW: [PATCH] cs5535_gpio: Fix root triggerable integer underflow
Date: Fri, 24 Jul 2009 12:40:28 -0500	[thread overview]
Message-ID: <808c8e9d0907241040i2783d27aw948aa239f521336c@mail.gmail.com> (raw)
In-Reply-To: <F06EB2894F3F0D45AD9BEA7246DE9C900E542FE2@WCSEXCMBS1.ad.wabtec.com>

Hi Michael,

> This patch fixes a possible root triggerable (I hope the device is only
> readable by root?) integer underflow.
> Well, it's not really an underflow, but as loff_t is a signed type, the
> range check at the start of the function is incomplete. It needs to
> check for <0, too.
> Otherwise the loop below will poke into random memory and I/O space.
> This could be used to crash the machine, at least.
>
> This patch is only compiletested, because I do not have the hardware.
>
> Signed-off-by: Michael Buesch <mb@bu3sch.de>
>
> ---
>
> I'm not sure if this bug is exploitable. I _guess_ the device is only
> readable by root
> on a standard setup.

The cs5525_gpio driver uses the default seek, which doesn't allow
negative position values.
So, I don't think it necessary to check for negative values.

Ben

> ---
>  drivers/char/cs5535_gpio.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- linux-2.6.orig/drivers/char/cs5535_gpio.c
> +++ linux-2.6/drivers/char/cs5535_gpio.c
> @@ -124,21 +124,21 @@ static ssize_t cs5535_gpio_write(struct
>  static ssize_t cs5535_gpio_read(struct file *file, char __user *buf,
>                                size_t len, loff_t *ppos)
>  {
>        u32     m = iminor(file->f_path.dentry->d_inode);
>        u32     base = gpio_base + cs5535_lowhigh_base(m);
>        int     rd_bit = 1 << (m & 0x0f);
>        int     i;
>        char    ch;
>        ssize_t count = 0;
>
> -       if (*ppos >= ARRAY_SIZE(rm))
> +       if (*ppos < 0 || *ppos >= ARRAY_SIZE(rm))
>                return 0;
>
>        for (i = *ppos; (i < (*ppos + len)) && (i < ARRAY_SIZE(rm));
> i++) {
>                ch = (inl(base + rm[i].rd_offset) & rd_bit) ?
>                     rm[i].on : rm[i].off;
>
>                if (put_user(ch, buf+count))
>                        return -EFAULT;
>
>                count++;
>
> --
> Greetings, Michael.

       reply	other threads:[~2009-07-24 17:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <F06EB2894F3F0D45AD9BEA7246DE9C900E542FE2@WCSEXCMBS1.ad.wabtec.com>
2009-07-24 17:40 ` Ben Gardner [this message]
2009-07-24 19:00   ` Michael Buesch

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=808c8e9d0907241040i2783d27aw948aa239f521336c@mail.gmail.com \
    --to=gardner.ben@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.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

all inboxes | Powered by JetHome®