From: "Phil Endecott" <phil_gjouf_endecott@chezphil.org>
To: linux-i2c@vger.kernel.org
Cc: Feng Kan <fkan@apm.com>
Subject: i2c-xgene-slimpro.c : dma_buffer overrun
Date: Thu, 06 Oct 2016 22:22:15 +0100 [thread overview]
Message-ID: <1475788935324@dmwebmail.dmwebmail.chezphil.org> (raw)
Dear Experts,
Can someone please have a look at this declaration in i2c-xgene-slimpro.c:
struct slimpro_i2c_dev {
struct i2c_adapter adapter;
struct device *dev;
struct mbox_chan *mbox_chan;
struct mbox_client mbox_client;
struct completion rd_complete;
u8 dma_buffer[I2C_SMBUS_BLOCK_MAX];
u32 *resp_msg;
};
It seems to me that the size of dma_buffer should be I2C_SMBUS_BLOCK_MAX+2,
to match this in uapi/linux/i2c.h:
union i2c_smbus_data {
__u8 byte;
__u16 word;
__u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
/* and one more for user-space compatibility */
};
My debugging shows that 33 is often passed as readlen to dma_map_single()
in slimpro_i2c_blkrd(). So either the buffer needs to be larger, or the
caller is misbehaving. Certainly increasing the size of dma_buffer by 2
fixes crashes that I have been seeing.
This is the first time I've ever looked at anything in the i2c system so
I may have completely misunderstood everything....
(If I'm right, is anyone aware of any static analysis method that should have
been able to detect this?)
Thanks, Phil.
reply other threads:[~2016-10-06 21:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1475788935324@dmwebmail.dmwebmail.chezphil.org \
--to=phil_gjouf_endecott@chezphil.org \
--cc=fkan@apm.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