All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Scott Branden <scott.branden@broadcom.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	David Brown <david.brown@linaro.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Shuah Khan <shuah@kernel.org>,
	bjorn.andersson@linaro.org,
	Shuah Khan <skhan@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>,
	Olof Johansson <olof@lixom.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Colin Ian King <colin.king@canonical.com>,
	Takashi Iwai <tiwai@suse.de>,
	linux-kselftest@vger.kernel.org, Andy Gross <agross@kernel.org>
Subject: Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx
Date: Wed, 15 Apr 2020 09:44:31 -0700	[thread overview]
Message-ID: <202004150943.01DF9E85@keescook> (raw)
In-Reply-To: <e2b95fde-0ab7-c0d1-2c64-cceffc458673@broadcom.com>

On Wed, Apr 15, 2020 at 09:28:18AM -0700, Scott Branden wrote:
> Hi Kees,
> 
> On 2020-04-14 8:10 p.m., Kees Cook wrote:
> > On Tue, Apr 14, 2020 at 05:25:17PM -0700, Scott Branden wrote:
> > > Remove unnecessary use of test_fw_mutex in test_dev_config_show_xxx
> > > functions that show simple bool, int, and u8.
> > I would expect at least a READ_ONCE(), yes?
> I don't understand why you need a READ_ONCE when removing a mutex around an
> assignment
> of a parameter passed into a function being assigned to a local variable.
> 
> Could you please explain your expectations.

Oops, yes, you're right. I misread and was thinking this was reading
from a global. This looks fine.

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> > 
> > > Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> > > ---
> > >   lib/test_firmware.c | 26 +++-----------------------
> > >   1 file changed, 3 insertions(+), 23 deletions(-)
> > > 
> > > diff --git a/lib/test_firmware.c b/lib/test_firmware.c
> > > index 0c7fbcf07ac5..9fee2b93a8d1 100644
> > > --- a/lib/test_firmware.c
> > > +++ b/lib/test_firmware.c
> > > @@ -310,27 +310,13 @@ static int test_dev_config_update_bool(const char *buf, size_t size,
> > >   	return ret;
> > >   }
> > > -static ssize_t
> > > -test_dev_config_show_bool(char *buf,
> > > -			  bool config)
> > > +static ssize_t test_dev_config_show_bool(char *buf, bool val)
> > >   {
> > > -	bool val;
> > > -
> > > -	mutex_lock(&test_fw_mutex);
> > > -	val = config;
> > > -	mutex_unlock(&test_fw_mutex);
> > > -
> > >   	return snprintf(buf, PAGE_SIZE, "%d\n", val);
> > >   }
> > > -static ssize_t test_dev_config_show_int(char *buf, int cfg)
> > > +static ssize_t test_dev_config_show_int(char *buf, int val)
> > >   {
> > > -	int val;
> > > -
> > > -	mutex_lock(&test_fw_mutex);
> > > -	val = cfg;
> > > -	mutex_unlock(&test_fw_mutex);
> > > -
> > >   	return snprintf(buf, PAGE_SIZE, "%d\n", val);
> > >   }
> > > @@ -354,14 +340,8 @@ static int test_dev_config_update_u8(const char *buf, size_t size, u8 *cfg)
> > >   	return size;
> > >   }
> > > -static ssize_t test_dev_config_show_u8(char *buf, u8 cfg)
> > > +static ssize_t test_dev_config_show_u8(char *buf, u8 val)
> > >   {
> > > -	u8 val;
> > > -
> > > -	mutex_lock(&test_fw_mutex);
> > > -	val = cfg;
> > > -	mutex_unlock(&test_fw_mutex);
> > > -
> > >   	return snprintf(buf, PAGE_SIZE, "%u\n", val);
> > >   }
> > > -- 
> > > 2.17.1
> > > 
> 

-- 
Kees Cook

  reply	other threads:[~2020-04-15 16:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  0:25 [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx Scott Branden
2020-04-15  3:10 ` Kees Cook
2020-04-15 16:28   ` Scott Branden
2020-04-15 16:44     ` Kees Cook [this message]
2020-04-16  6:00       ` Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202004150943.01DF9E85@keescook \
    --to=keescook@chromium.org \
    --cc=agross@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=david.brown@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=olof@lixom.net \
    --cc=rafael@kernel.org \
    --cc=scott.branden@broadcom.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tiwai@suse.de \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.