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] [day] [month] [year] [list]
Date: Mon, 15 Apr 2024 19:32:43 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Christophe Leroy" <christophe.leroy@...roup.eu>,
 "Michael Ellerman" <mpe@...erman.id.au>,
 "Adrian Hunter" <adrian.hunter@...el.com>
Cc: "Peter Zijlstra" <peterz@...radead.org>,
 "Dave Hansen" <dave.hansen@...ux.intel.com>,
 "John Stultz" <jstultz@...gle.com>, "H. Peter Anvin" <hpa@...or.com>,
 "Alexander Gordeev" <agordeev@...ux.ibm.com>,
 "Vincenzo Frascino" <vincenzo.frascino@....com>,
 "linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
 "Naresh Kamboju" <naresh.kamboju@...aro.org>,
 "x86@...nel.org" <x86@...nel.org>,
 "Aneesh Kumar K.V" <aneesh.kumar@...nel.org>,
 "Ingo Molnar" <mingo@...hat.com>,
 "Naveen N. Rao" <naveen.n.rao@...ux.ibm.com>,
 "Christian Borntraeger" <borntraeger@...ux.ibm.com>,
 "Vasily Gorbik" <gor@...ux.ibm.com>,
 "Heiko Carstens" <hca@...ux.ibm.com>,
 "Nicholas Piggin" <npiggin@...il.com>, "Borislav Petkov" <bp@...en8.de>,
 "Andy Lutomirski" <luto@...nel.org>,
 "Bjorn Helgaas" <bhelgaas@...gle.com>,
 "Thomas Gleixner" <tglx@...utronix.de>,
 "Anna-Maria Gleixner" <anna-maria@...utronix.de>,
 "Stephen Boyd" <sboyd@...nel.org>,
 "Randy Dunlap" <rdunlap@...radead.org>,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
 "Sven Schnelle" <svens@...ux.ibm.com>,
 "linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>
Subject: Re: [PATCH] bug: Fix no-return-statement warning with !CONFIG_BUG

On Mon, Apr 15, 2024, at 19:07, Christophe Leroy wrote:
> Le 15/04/2024 à 17:35, Arnd Bergmann a écrit :
>> 
>> I haven't seen a good solution here. Ideally we'd just define
>> the functions unconditionally and have IS_ENABLED() take care
>> of letting the compiler drop them silently, but that doesn't
>> build because of missing struct members.
>> 
>> I won't object to either an 'extern' declaration or the
>> 'BUILD_BUG_ON()' if you and others prefer that, both are better
>> than BUG() here. I still think my suggestion would be a little
>> simpler.
>
> The advantage of the BUILD_BUG() against the extern is that the error 
> gets detected at buildtime. With the extern it gets detected only at 
> link-time.
>
> But agree with you, the missing struct members defeats the advantages of 
> IS_ENABLED().
>
> At the end, how many instances of struct timekeeper do we have in the 
> system ? With a quick look I see only two instances: tkcore.timekeeper 
> and shadow_timekeeper. If I'm correct, wouldn't it just be simpler to 
> have the three debug struct members defined at all time ?

Sure, this version looks fine to me, and passes a simple build
test without CONFIG_DEBUG_TIMEKEEPING.

    Arnd

diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h
index 84ff2844df2a..485677a98b0b 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -124,7 +124,6 @@ struct timekeeper {
        u32                     ntp_err_mult;
        /* Flag used to avoid updating NTP twice with same second */
        u32                     skip_second_overflow;
-#ifdef CONFIG_DEBUG_TIMEKEEPING
        long                    last_warning;
        /*
         * These simple flag variables are managed
@@ -135,7 +134,6 @@ struct timekeeper {
         */
        int                     underflow_seen;
        int                     overflow_seen;
-#endif
 };
 
 #ifdef CONFIG_GENERIC_TIME_VSYSCALL
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 4e18db1819f8..17f7aed807e1 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -195,7 +195,6 @@ static inline u64 tk_clock_read(const struct tk_read_base *tkr)
        return clock->read(clock);
 }
 
-#ifdef CONFIG_DEBUG_TIMEKEEPING
 #define WARNING_FREQ (HZ*300) /* 5 minute rate-limiting */
 
 static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
@@ -276,15 +275,6 @@ static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr)
        /* timekeeping_cycles_to_ns() handles both under and overflow */
        return timekeeping_cycles_to_ns(tkr, now);
 }
-#else
-static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset)
-{
-}
-static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr)
-{
-       BUG();
-}
-#endif
 
 /**
  * tk_setup_internals - Set up internals to use clocksource clock.
@@ -2173,7 +2163,8 @@ static bool timekeeping_advance(enum timekeeping_adv_mode mode)
                goto out;
 
        /* Do some additional sanity checking */
-       timekeeping_check_update(tk, offset);
+       if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING))
+               timekeeping_check_update(tk, offset);
 
        /*
         * With NO_HZ we may have to accumulate many cycle_intervals

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ