linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: force snprintf for PAGE_SIZE bufs
Date: Sat, 15 Mar 2014 14:45:45 +0000	[thread overview]
Message-ID: <53246799.8080600@kernel.org> (raw)
In-Reply-To: <20140313164643.GA19171@www.outflux.net>

On 13/03/14 16:46, Kees Cook wrote:
> This is a tiny preventative measure to make sure we can't write beyond
> PAGE_SIZE on the buffers being used in sysfs for iio. There is currently
> no way for this to happen, but the change makes this code more robust
> for the future.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
A sensible enough change I guess.

Applied to the togreg branch of iio.git

Jonathan
> ---
>   drivers/iio/industrialio-core.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index acc911a836ca..64bb64f35af8 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -340,7 +340,7 @@ ssize_t iio_enum_read(struct iio_dev *indio_dev,
>   	else if (i >= e->num_items)
>   		return -EINVAL;
>
> -	return sprintf(buf, "%s\n", e->items[i]);
> +	return snprintf(buf, PAGE_SIZE, "%s\n", e->items[i]);
>   }
>   EXPORT_SYMBOL_GPL(iio_enum_read);
>
> @@ -836,7 +836,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
>   				 char *buf)
>   {
>   	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	return sprintf(buf, "%s\n", indio_dev->name);
> +	return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->name);
>   }
>
>   static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
>


      reply	other threads:[~2014-03-15 14:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-13 16:46 [PATCH] iio: force snprintf for PAGE_SIZE bufs Kees Cook
2014-03-15 14:45 ` 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=53246799.8080600@kernel.org \
    --to=jic23@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).