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: <d168f357-e78e-5dc6-09cd-41e6e41e1f4f@kernel.org>
Date:   Wed, 20 Jul 2022 19:37:58 +0200
From:   Daniel Bristot de Oliveira <bristot@...nel.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     Wim Van Sebroeck <wim@...ux-watchdog.org>,
        Guenter Roeck <linux@...ck-us.net>,
        Jonathan Corbet <corbet@....net>,
        Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Will Deacon <will@...nel.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Marco Elver <elver@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        "Paul E. McKenney" <paulmck@...nel.org>,
        Shuah Khan <skhan@...uxfoundation.org>,
        Gabriele Paoloni <gpaoloni@...hat.com>,
        Juri Lelli <juri.lelli@...hat.com>,
        Clark Williams <williams@...hat.com>,
        Tao Zhou <tao.zhou@...ux.dev>,
        Randy Dunlap <rdunlap@...radead.org>,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-trace-devel@...r.kernel.org
Subject: Re: [PATCH V6 02/16] rv: Add runtime reactors interface

On 7/20/22 19:02, Steven Rostedt wrote:
> On Wed, 20 Jul 2022 18:50:39 +0200
> Daniel Bristot de Oliveira <bristot@...nel.org> wrote:
> 
>> On 7/20/22 18:41, Steven Rostedt wrote:
>>> On Tue, 19 Jul 2022 19:27:07 +0200
>>> Daniel Bristot de Oliveira <bristot@...nel.org> wrote:
>>>   
>>>> +/*
>>>> + * reacting_on interface.
>>>> + */
>>>> +static ssize_t reacting_on_read_data(struct file *filp,
>>>> +				     char __user *user_buf,
>>>> +				     size_t count, loff_t *ppos)
>>>> +{
>>>> +	char *buff;
>>>> +
>>>> +	mutex_lock(&rv_interface_lock);
>>>> +	buff = reacting_on ? "1\n" : "0\n";
>>>> +	mutex_unlock(&rv_interface_lock);  
>>> Again, no need for the locks, but perhaps just to keep things sane:
>>>
>>> 	buf = READ_ONCE(reacting_on) ? "1\n" : "0\n";  
>>
>> So, for all files that only read/write a single variable, use READ_ONCE/WRITE_ONCE without
>> locks? (and in all usage of that variable too).
> 
> Only if there's no races.
> 
> That is, taking the locks here provide no benefit over a READ_ONCE().
> 
> If there was some logic that checks if the value is still valid or not,
> then that would be a different story.
> 
> For example:
> 
> static int enable_monitor(struct rv_monitor_def *mdef)
> {
>         int retval;
> 
>         if (!mdef->monitor->enabled) {
>                 retval = mdef->monitor->enable();
>                 if (retval)
>                         return retval;
>         }
> 
>         mdef->monitor->enabled = 1;
> 
>         return 0;
> }
> 
> That has logic that looks to require a lock to protect things from changing
> from underneath.

ack, so the only variable I see we can use READ_ONCE/WRITE_ONCE is the reacting_on...

-- Daniel

> 
> -- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ