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]
Date:   Sat, 17 Sep 2016 15:09:09 +0300
From:   Konstantin Khlebnikov <koct9i@...il.com>
To:     Cyrill Gorcunov <gorcunov@...il.com>
Cc:     Joe Perches <joe@...ches.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Sam Varshavchik <mrsam@...rier-mta.com>,
        Ingo Molnar <mingo@...nel.org>,
        Laura Abbott <labbott@...hat.com>, Brent <fix@...realm.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Christian Borntraeger <borntraeger@...ibm.com>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [REGRESSION] RLIMIT_DATA crashes named

On Sat, Sep 17, 2016 at 12:09 PM, Cyrill Gorcunov <gorcunov@...il.com> wrote:
> On Sat, Sep 17, 2016 at 11:33:56AM +0300, Konstantin Khlebnikov wrote:
>> >
>> > do_just_once just isn't a good name for a global
>> > rate limited mechanism that does something very
>> > different than the name.
>> >
>> > Maybe allow_once_per_ratelimit or the like
>> >
>> > There could be an equivalent do_once
>> >
>> > https://lkml.org/lkml/2009/5/22/3
>> >
>>
>> What about this printk_reriodic() and pr_warn_once_per_minute()?
>>
>> It simply remembers next jiffies to print rather than using that
>> complicated ratelimiting engine.
>
> +#define printk_periodic(period, fmt, ...)                      \
> +({                                                             \
> +       static unsigned long __print_next __read_mostly = INITIAL_JIFFIES; \
> +       bool __do_print = time_after_eq(jiffies, __print_next); \
> +                                                               \
> +       if (__do_print) {                                       \
> +               __print_next = jiffies + (period);              \
> +               printk(fmt, ##__VA_ARGS__);                     \
> +       }                                                       \
> +       unlikely(__do_print);                                   \
> +})
>
> Seems I don't understand the bottom unlikely...

This is gcc extrension:  https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
Here macro works as a function which returns bool

After second though macro should update __print_next if it's too far
if first warning happens too late here will long period of silence
untill next jiffies overlap.

something like

#define printk_periodic(period, fmt, ...)
({
static unsigned long __print_next = INITIAL_JIFFIES;
unsigned long __print_jiffies = jiffies;
bool __do_print = time_after_eq(__print_jiffies, __print_next);

if (__do_print) {
        __print_next = __print_jiffies + (period);
        printk(fmt, ##__VA_ARGS__);
} else if (time_after(__print_next, __print_jiffies + (period))
        __print_next = __print_jiffies + (period);
unlikely(__do_print);
})

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ