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: <CAE_wzQ9ohsoeGuk-gJ+ZtP4J7yCAB5b2JcO1HbHDZUj2PaQvyA@mail.gmail.com>
Date:   Wed, 25 Sep 2019 13:51:01 -0700
From:   Dmitry Torokhov <dtor@...omium.org>
To:     Nick Crews <ncrews@...omium.org>
Cc:     Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Alessandro Zummo <a.zummo@...ertech.it>,
        linux-rtc@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>,
        Pavel Machek <pavel@....cz>, enric.balletbo@...labora.com,
        Benson Leung <bleung@...omium.org>, dlaurie@...omium.org,
        Daniel Kurtz <djkurtz@...omium.org>
Subject: Re: [PATCH v3] rtc: wilco-ec: Handle reading invalid times

On Wed, Sep 25, 2019 at 1:32 PM Nick Crews <ncrews@...omium.org> wrote:
>
> If the RTC HW returns an invalid time, the rtc_year_days()
> call would crash. This patch adds error logging in this
> situation, and removes the tm_yday and tm_wday calculations.
> These fields should not be relied upon by userspace
> according to man rtc, and thus we don't need to calculate
> them.
>
> Signed-off-by: Nick Crews <ncrews@...omium.org>

Reviewed-by: Dmitry Torokhov <dtor@...omium.org>

> ---
>  drivers/rtc/rtc-wilco-ec.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rtc/rtc-wilco-ec.c b/drivers/rtc/rtc-wilco-ec.c
> index 8ad4c4e6d557..53da355d996a 100644
> --- a/drivers/rtc/rtc-wilco-ec.c
> +++ b/drivers/rtc/rtc-wilco-ec.c
> @@ -110,10 +110,15 @@ static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm)
>         tm->tm_mday     = rtc.day;
>         tm->tm_mon      = rtc.month - 1;
>         tm->tm_year     = rtc.year + (rtc.century * 100) - 1900;
> -       tm->tm_yday     = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
> -
> -       /* Don't compute day of week, we don't need it. */
> -       tm->tm_wday = -1;
> +       /* Ignore other tm fields, man rtc says userspace shouldn't use them. */
> +
> +       if (rtc_valid_tm(tm)) {
> +               dev_err(dev,
> +                        "Time from RTC is invalid: second=%u, minute=%u, hour=%u, day=%u, month=%u, year=%u, century=%u",
> +                        rtc.second, rtc.minute, rtc.hour, rtc.day, rtc.month,
> +                        rtc.year, rtc.century);
> +               return -EIO;
> +       }
>
>         return 0;
>  }
> --
> 2.21.0
>

Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ