From: Dan Carpenter <dan.carpenter@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v7] gpio: virtuser: new virtual driver
Date: Wed, 29 May 2024 17:32:46 +0300 [thread overview]
Message-ID: <c5799a51-b39b-49b7-89ef-9cec2509330a@moroto.mountain> (raw)
In-Reply-To: <20240527144054.155503-1-brgl@bgdev.pl>
On Mon, May 27, 2024 at 04:40:54PM +0200, Bartosz Golaszewski wrote:
> +static ssize_t
> +gpio_virtuser_sysfs_consumer_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct gpio_virtuser_line_data *data = to_gpio_virtuser_data(attr);
> + int ret;
> +
> + if (strlen(buf) > GPIO_CONSUMER_NAME_MAX_LEN)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is off by one. strlen() doesn't count the NUL terminator.
> + return -EINVAL;
> +
> + guard(mutex)(&data->consumer_lock);
> +
> + ret = gpiod_set_consumer_name(data->desc, buf);
> + if (ret)
> + return ret;
> +
> + sprintf(data->consumer, buf);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It results in a buffer overflow here.
> +
> + return len;
> +}
regards,
dan carpenter
next prev parent reply other threads:[~2024-05-29 14:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 14:40 Bartosz Golaszewski
2024-05-29 14:32 ` Dan Carpenter [this message]
2024-05-29 21:00 ` Andy Shevchenko
2024-06-10 13:22 ` Bartosz Golaszewski
2024-06-10 14:57 ` Andy Shevchenko
2024-06-12 18:38 ` Bartosz Golaszewski
2024-06-13 18:03 ` Andy Shevchenko
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=c5799a51-b39b-49b7-89ef-9cec2509330a@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=warthog618@gmail.com \
/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
all inboxes | Powered by JetHome®