All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Chris Brannon <chris@the-brannons.com>
Cc: Raphael S Carvalho <raphael.scarv@gmail.com>,
	devel@driverdev.osuosl.org, Kirk Reiser <kirk@reisers.ca>,
	speakup@braille.uwo.ca,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH 1/1] staging/speakup/kobjects.c: Code improvement.
Date: Wed, 11 Sep 2013 02:12:29 +0300	[thread overview]
Message-ID: <20130910231228.GF6329@mwanda> (raw)
In-Reply-To: <87y576edm6.fsf@mushroom.PK5001Z>

Good eye for spotting the memory corruption bug!

This is a bug fix, so the fix should go in a separate patch and not
merged with a code cleanup patch.  Ordinary users can trigger this so
it's a security bug and separating it out is extra important.

The checking in spk_set_num_var() is not sufficient as well.  If we use
E_INC then we can hit an integer overflow bug:

drivers/staging/speakup/varhandlers.c
   198                  if (how == E_SET)
   199                          val = input;
   200                  else
   201                          val = var_data->u.n.value;
   202                  if (how == E_INC)
   203                          val += input;

"input" comes from the user.  This addition can overflow so that input
is a very high number and now "val" is a low enough number.

   204                  else if (how == E_DEC)
   205                          val -= input;
   206                  if (val < var_data->u.n.low || val > var_data->u.n.high)
   207                          return -ERANGE;

"val" is valid, but "input" is not valid.  We use "input" in the caller
function as the index to an array.

   208          }

I guess that's simple enough to fix but why is the caller using "input"
instead of "val"?

regards,
dan carpenter


  reply	other threads:[~2013-09-10 23:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02 22:20 [PATCH 1/1] staging/speakup/kobjects.c: Code improvement Raphael S.Carvalho
2013-09-09  3:56 ` Chris Brannon
     [not found]   ` <CACz=WeeE+jxdaxpR_amF60deDcEy8nChYYfY3UA3CNfhmOB8Gw@mail.gmail.com>
2013-09-09  4:16     ` Fwd: " Raphael S Carvalho
2013-09-09  6:02     ` Chris Brannon
2013-09-10 23:12       ` Dan Carpenter [this message]
2013-09-11  1:29         ` Chris Brannon
2013-09-11  7:59           ` Dan Carpenter
2013-09-11 21:01 ` Samuel Thibault
  -- strict thread matches above, loose matches on Subject: below --
2013-06-22  1:54 Raphael S. Carvalho
2013-06-30  8:11 ` Samuel Thibault
2013-07-23 21:39 ` Greg Kroah-Hartman

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=20130910231228.GF6329@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=chris@the-brannons.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kirk@reisers.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raphael.scarv@gmail.com \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=speakup@braille.uwo.ca \
    /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.