Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp715875ybz; Wed, 15 Apr 2020 17:22:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKchF/PyjyQv1mSvXjPIEVAXa0O/3duelpZ2bZUCdnAvHSRNSYMuPmdMqJ6r/XTj7cs7YDR X-Received: by 2002:a50:bb2a:: with SMTP id y39mr14795337ede.292.1586996530937; Wed, 15 Apr 2020 17:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586996530; cv=none; d=google.com; s=arc-20160816; b=Mx7fyQQGtzKD9ZU9AaUczj8xtS9AiJ7V9gsNjgcTcbvreEte+U8Ianq4YLR/u1uu4Y RtH+lbsbUNbNfLYpibPudvmznqgXHBZw6zQMYQ1BcW1uXgWBfCGrvhzQxxNFvSOe49z4 BXfM7bD+coetmofTrFO6xF8Fs+hsV0ytw1b4LfLpzcHIhTZeXkgX2F5L71MgCVbd0dgB EiVl2v3sdMDwStlt0nM9ww6mk0nn9EhoZiU1zwPOVP4jx2LeaoREpcB9qYIE53VwUYCR nF4k0VTo8/wF6VhCozjbCMzrZuf3UHIkm1taUMBlqxdNOp9BGgRV+VGec/hWA1Fq7czU pqqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=pdVhlXTVp5GfPwUXj6VUlKKGPig0Mq5LnblaVWQhsNw=; b=kqtsoqOa+I8pRP6tBM6YaTHMeGvxde/3cylA4wSFhVX1G/gn8olibbOQdV3vPgsOBB 8S6uwWzWjsFl8yneAcNyuvtK1bTY7muSzZrpN+nEDDwrP3FPBe0qyCTcA+bfno+2uQyZ lcUI8wc4PL7c7UFWUsYicL98BjcWepYMSsrVOj2g3HGCfW3DgronqSj2Qgl+HKhXvk5k JiceHdUi098xA1XxBtfl7ymmvRy+AcqLAtoecrFTD17V3fb4v+xHatyrkqKGGIpZDf6u OzdgyzLd7MmBprhhtfdk0uEv2y+QCec+nCAEnGP4nMsiJyN4EaN8/q67WrMOEEed7bCA llcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EwXM2PRV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si322369ejf.493.2020.04.15.17.21.47; Wed, 15 Apr 2020 17:22:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EwXM2PRV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1416180AbgDOQoi (ORCPT + 99 others); Wed, 15 Apr 2020 12:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1416183AbgDOQof (ORCPT ); Wed, 15 Apr 2020 12:44:35 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60117C061A0E for ; Wed, 15 Apr 2020 09:44:34 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a22so78051pjk.5 for ; Wed, 15 Apr 2020 09:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=pdVhlXTVp5GfPwUXj6VUlKKGPig0Mq5LnblaVWQhsNw=; b=EwXM2PRVYwopCctyukNi1Jy9/hg/z0XO7R6ERA5H8lQeF+oXDnWxXzaBvG4/tpnaJk EUS2ZH0ou2TLvBuWGGsNknwi3M1uPK00CvyRUMX/rprb0NidhH4cb7OvpZxH10W+Osnk G83vC8Ey8RWVcyBCcgTMDej9RphYZAOY/eHB8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pdVhlXTVp5GfPwUXj6VUlKKGPig0Mq5LnblaVWQhsNw=; b=QNI/8lQP0XX/l7AwuQtah2esDDV7Zo0jgrCohPX8suk7ZEaGz/lUhRhIg/LhxJO5cB WDH/UzYBY67eQl84SZHm51xLgNz5k1mZ/5XMJ3FT4z/aKoz3ZWPVmLGiTN2kdTSySxaP rQKYasJjSBc9XINVoRWOQlfvO+2LVjUCbWNAvK5oNuYb2i6qo2hFDXiC0oxr8dWe/D6i o6D+SRL9G1vyKnF+POjZFA/UFf+5CzsyIAzgNoCeGhTwaRVCYmK4KJojwunU/2Xe2QKc DLsAf6ic3QtfmUtE34JRCSOAwInJUmlofz354ZnjBUSoH/aLQuk91+7yqTZ5iKNxNPTz 2skw== X-Gm-Message-State: AGi0PuarnxMdpEQ3oekn9QIDULq0CpD8UbVpixT+vguuApeGhgvEIhfx 0tpgsDROoI4Sdkml5WLkmm08+g== X-Received: by 2002:a17:90a:dac2:: with SMTP id g2mr139955pjx.112.1586969073762; Wed, 15 Apr 2020 09:44:33 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q70sm14494021pfc.206.2020.04.15.09.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 09:44:32 -0700 (PDT) Date: Wed, 15 Apr 2020 09:44:31 -0700 From: Kees Cook To: Scott Branden Cc: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross Subject: Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx Message-ID: <202004150943.01DF9E85@keescook> References: <20200415002517.4328-1-scott.branden@broadcom.com> <202004142010.C0847F5@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -Kees > > > > > Signed-off-by: Scott Branden > > > --- > > > 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