linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Brian Norris <briannorris@chromium.org>
Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brian Norris <computersforpeace@gmail.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Doug Anderson <dianders@chromium.org>
Subject: Re: [PATCH v2] pwm: improve args checking in pwm_apply_state()
Date: Fri, 10 Jun 2016 14:20:30 +0200	[thread overview]
Message-ID: <20160610122030.GA27142@ulmo.ba.sec> (raw)
In-Reply-To: <1464367549-111530-1-git-send-email-briannorris@chromium.org>

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

On Fri, May 27, 2016 at 09:45:49AM -0700, Brian Norris wrote:
> It seems like in the process of refactoring pwm_config() to utilize the
> newly-introduced pwm_apply_state() API, some args/bounds checking was
> dropped.
> 
> In particular, I noted that we are now allowing invalid period
> selections. e.g.:
> 
>   # echo 1 > /sys/class/pwm/pwmchip0/export
>   # cat /sys/class/pwm/pwmchip0/pwm1/period
>   100
>   # echo 101 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
>   [... driver may or may not reject the value, or trigger some logic bug ...]
> 
> It's better to see:
> 
>   # echo 1 > /sys/class/pwm/pwmchip0/export
>   # cat /sys/class/pwm/pwmchip0/pwm1/period
>   100
>   # echo 101 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
>   -bash: echo: write error: Invalid argument
> 
> This patch reintroduces some bounds checks in both pwm_config() (for its
> signed parameters; we don't want to convert negative values into large
> unsigned values) and in pwm_apply_state() (which fix the above described
> behavior, as well as other potential API misuses).
> 
> Fixes: 5ec803edcb70 ("pwm: Add core infrastructure to allow atomic updates")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
> v2:
>  * changed subject, as this covers more scope now
>  * add Fixes tag, as this is a v4.7-rc regression
>  * add more bounds/args checks in pwm_apply_state() and pwm_config()
> 
>  drivers/pwm/core.c  | 3 ++-
>  include/linux/pwm.h | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)

Applied, thanks.

Thierry

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

  parent reply	other threads:[~2016-06-10 12:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 16:45 [PATCH v2] pwm: improve args checking in pwm_apply_state() Brian Norris
2016-05-27 16:54 ` Boris Brezillon
2016-06-10 12:20 ` Thierry Reding [this message]
2016-06-21 14:42 ` Geert Uytterhoeven
2016-06-21 18:37   ` Brian Norris
2016-06-21 21:22     ` Boris Brezillon
2016-06-22  8:04     ` Boris Brezillon
2016-06-22 12:00       ` Thierry Reding
2016-06-22 14:32       ` Geert Uytterhoeven
2016-06-22 19:16       ` Brian Norris
2016-06-22 20:41         ` Boris Brezillon
2016-06-22 20:46           ` Brian Norris
2016-06-23 16:55             ` Thierry Reding

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=20160610122030.GA27142@ulmo.ba.sec \
    --to=thierry.reding@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=briannorris@chromium.org \
    --cc=computersforpeace@gmail.com \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@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).