lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0g-NNKeXh_m-O+mAL=w3Roae_EMUWA5fbBvi49jhZM07A@mail.gmail.com>
Date: Fri, 23 Aug 2024 18:39:40 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: "Rafael J. Wysocki" <rjw@...ysocki.net>, Linux PM <linux-pm@...r.kernel.org>, 
	LKML <linux-kernel@...r.kernel.org>, Zhang Rui <rui.zhang@...el.com>, 
	Lukasz Luba <lukasz.luba@....com>, Peter Kästle <peter@...e.net>
Subject: Re: [PATCH v1 2/2] thermal: sysfs: Add sanity checks for trip
 temperature and hysteresis

On Fri, Aug 23, 2024 at 5:26 PM Daniel Lezcano
<daniel.lezcano@...aro.org> wrote:
>
> On 22/08/2024 21:48, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> >
> > Add sanity checks for new trip temperature and hysteresis values to
> > trip_point_temp_store() and trip_point_hyst_store() to prevent trip
> > point thresholds from falling below THERMAL_TEMP_INVALID.
> >
> > However, still allow user space to pass THERMAL_TEMP_INVALID as the
> > new trip temperature value to invalidate the trip if necessary.
> >
> > Fixes: be0a3600aa1e ("thermal: sysfs: Rework the handling of trip point updates")
> > Cc: 6.8+ <stable@...r.kernel.org> # 6.8+
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> > ---
> >   drivers/thermal/thermal_sysfs.c |   38 ++++++++++++++++++++++++++------------
> >   1 file changed, 26 insertions(+), 12 deletions(-)
> >
> > Index: linux-pm/drivers/thermal/thermal_sysfs.c
> > ===================================================================
> > --- linux-pm.orig/drivers/thermal/thermal_sysfs.c
> > +++ linux-pm/drivers/thermal/thermal_sysfs.c
> > @@ -111,18 +111,25 @@ trip_point_temp_store(struct device *dev
> >
> >       mutex_lock(&tz->lock);
> >
> > -     if (temp != trip->temperature) {
> > -             if (tz->ops.set_trip_temp) {
> > -                     ret = tz->ops.set_trip_temp(tz, trip, temp);
> > -                     if (ret)
> > -                             goto unlock;
> > -             }
> > +     if (temp == trip->temperature)
> > +             goto unlock;
> >
> > -             thermal_zone_set_trip_temp(tz, trip, temp);
> > +     if (temp != THERMAL_TEMP_INVALID &&
> > +         temp <= trip->hysteresis + THERMAL_TEMP_INVALID) {
>
> It seems to me the condition is hard to understand.

That's not the key consideration here though.

>
>    temp <= trip->hysteresis + THERMAL_TEMP_INVALID

This cannot overflow because trip->hysteresis is non-negative.

>
>           ==>
>
>    temp - trip->hysteresis <= THERMAL_TEMP_INVALID

But this can.

>
>
> Could be the test below simpler to understand ?
>
>         if (trip->hysteresis &&
>             temp - trip->hysteresis < THERMAL_TEMP_INVALID))
>
> I think more sanity check may be needed also.
>
>         if (temp < THERMAL_TEMP_INVALID)

With my version of the check above this is not necessary (unless I'm
missing something}.

> > +             ret = -EINVAL;
> > +             goto unlock;
> > +     }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ