From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: adis_buffer: Fix out-of-bounds memory access
Date: Sun, 29 Nov 2015 14:22:14 +0000 [thread overview]
Message-ID: <565B0A16.80408@kernel.org> (raw)
In-Reply-To: <1448632556-13005-1-git-send-email-lars@metafoo.de>
On 27/11/15 13:55, Lars-Peter Clausen wrote:
> The SPI tx and rx buffers are both supposed to be scan_bytes amount of
> bytes large and a common allocation is used to allocate both buffers. This
> puts the beginning of the tx buffer scan_bytes bytes after the rx buffer.
> The initialization of the tx buffer pointer is done adding scan_bytes to
> the beginning of the rx buffer, but since the rx buffer is of type __be16
> this will actually add two times as much and the tx buffer ends up pointing
> after the allocated buffer.
>
> Fix this by using scan_count, which is scan_bytes / 2, instead of
> scan_bytes when initializing the tx buffer pointer.
>
> Fixes: aacff892cbd5 ("staging:iio:adis: Preallocate transfer message")
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to my local fixes branch - will push out once Greg has caught
up with last pull request - don't want to muddy the waters!
Jonathan
> ---
> Apologies if you got this twice, forgot the mailinglist on the first try.
> ---
> drivers/iio/imu/adis_buffer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
> index cb32b59..36607d5 100644
> --- a/drivers/iio/imu/adis_buffer.c
> +++ b/drivers/iio/imu/adis_buffer.c
> @@ -43,7 +43,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
> return -ENOMEM;
>
> rx = adis->buffer;
> - tx = rx + indio_dev->scan_bytes;
> + tx = rx + scan_count;
>
> spi_message_init(&adis->msg);
>
>
prev parent reply other threads:[~2015-11-29 14:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 13:55 [PATCH] iio: adis_buffer: Fix out-of-bounds memory access Lars-Peter Clausen
2015-11-29 14:22 ` Jonathan Cameron [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=565B0A16.80408@kernel.org \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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.