Linux I2C development
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: "Compostella, Jeremy" <jeremy.compostella@intel.com>
Cc: linux-i2c@vger.kernel.org
Subject: Re: i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA
Date: Wed, 17 Jan 2018 15:37:43 +0100	[thread overview]
Message-ID: <20180117143743.mnsmhsbydyp3gv7r@ninjato> (raw)
In-Reply-To: <87k1whpp4b.fsf@jcompost-mobl.amr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1304 bytes --]

Hi Jeremy,

>        unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
> 
> It uses the first element to store the requested length.  Therefore,
> in practice, we hit the issue with "greater than I2C_SMBUS_BLOCK_MAX +
> 1".

Right, there is one extra byte reserved for PEC. So, the actual buffer
overflow will happen at I2C_SMBUS_BLOCK_MAX + 1 since
I2C_SMBUS_I2C_BLOCK_DATA does not have PEC.

> I have a added a little c ternary instruction to keep the same level
> of debug/error information.  If you don't like it we can remove it.

I like it. I just didn't include it in my proof of concept.

> I have updated, tested and attached the new version to this email.  I

Very good, thank you!

> also improved the commit message by adding some information about what
> is expected by the documentation. I don't know what is the process to
> update the patch to the mailing list.  Should I send a new email with
> the new patch instead ?

Technically, yes. Usually, resend it as [PATCH v2] with a small
changelog what changed since last version. Just dig the mail archive for
examples. However, since I really want this in v4.15, I picked this
patch from the attachment and have applied it to i2c/for-current and
attached the stable-tag.

Thank you very much!

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2018-01-17 14:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 19:54 [PATCH] i2c: core-smbus: prevent stack corruption on read I2C_BLOCK_DATA Compostella, Jeremy
2017-11-27 18:38 ` Wolfram Sang
2017-11-27 19:14   ` Compostella, Jeremy
2018-01-15 17:59 ` Wolfram Sang
2018-01-16 19:42   ` Compostella, Jeremy
2018-01-17 14:37     ` Wolfram Sang [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=20180117143743.mnsmhsbydyp3gv7r@ninjato \
    --to=wsa@the-dreams.de \
    --cc=jeremy.compostella@intel.com \
    --cc=linux-i2c@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox