Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp715405ybz; Wed, 15 Apr 2020 17:21:28 -0700 (PDT) X-Google-Smtp-Source: APiQypI7Sq/misVDyZxJxOoDs8qivxVCotwuc9GyIAk1uepht4z7FxE9GX6xhdRApWuDxOKmeWpt X-Received: by 2002:a50:e842:: with SMTP id k2mr15771794edn.328.1586996488336; Wed, 15 Apr 2020 17:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586996488; cv=none; d=google.com; s=arc-20160816; b=rSFgqF3GA55wx8+4zASIRjtNQzHe7syqXlwsQ2T+9qP4SpSrhS5ddzMydk74WaN7hl c9UxKdneQ6rkBf7HSlV+O8LrrPW/9BJVN4AjjjOra4kO5QH0om4pEbDTC1RliATWmGSR FDsk15vWwcxJpGm2qG8JUw8vPmZ8JROGH7QeMq1bfvKqbBiFAlo6A0ntlZVJK7ub+7rk gEXG1VHTzjEImBmH47QuvOCDZO/kxjtIa34TC/eB5Zv2uqbSIIGkv7bktuK39QMye241 Y+TSG05gJwYiyL1VwWI4gX03O8lhtgKExL1dMnWGdgltsoIuthwQKxHaWb4xMvXJjefw ICJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=76FV3ox/3TPbATAAAJw9w7kb0H0TlBYb5fVvS13JcLY=; b=LDEhscBg6mfKjlEVl5s3gLFVz5JPCGm8DG9E3lNvP6ool2gsbAvT04jpnI1IsS8cY8 C+GhQUk2g/V7kDwQXsZNpjysLesztXbS/fAbvMdwstIjBohBJu/VX/ZwhneVsVggFtL0 npzynVn5p65n6S8GKaYrNp3jU2WxRpoMxL00AcnGcqMkCQe8CQ+SVxJkczcbmC11Cc0o 5oPiXna6T0BAS3SLyXJvAIOMT0gePSPyGmkPIkUe0OmVmf5RXPUlIGc3QBpy9F9qV1fV HOy8EgoZRVq1IiuVfq6lgDCvY4Lt8M2/MQLNWPgmeYDilMCie5a67XIQ/rd2sYKmTC3s etww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="G/nt7PIU"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org ([23.128.96.18]) by mx.google.com with ESMTP id z1si12979714edp.464.2020.04.15.17.21.05; Wed, 15 Apr 2020 17:21:28 -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=@broadcom.com header.s=google header.b="G/nt7PIU"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1416009AbgDOQ2r (ORCPT + 99 others); Wed, 15 Apr 2020 12:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1415989AbgDOQ22 (ORCPT ); Wed, 15 Apr 2020 12:28:28 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9756BC061A0C for ; Wed, 15 Apr 2020 09:28:28 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id d17so557693wrg.11 for ; Wed, 15 Apr 2020 09:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=76FV3ox/3TPbATAAAJw9w7kb0H0TlBYb5fVvS13JcLY=; b=G/nt7PIUIjDbbyNK0gIoeOLcY8ZJ6ogrh7xIpJK5ptEMrpyqCvnEq1Gpc5ntN7Nohb FbLVbkv/SqyxTIKPSI8ArbB3aQC2cnsW7CNY285Nq6a2PjxHNIr/8pFYAG+7EVv0mbSo E9pam/kjTQC+Xto1u4FPAB7uQLe+D9C1L1s3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=76FV3ox/3TPbATAAAJw9w7kb0H0TlBYb5fVvS13JcLY=; b=seDoYeiOBohqSzYeFkPsWbMyRZza6EOLEpe9ATpOpc64nj4htFNL+6UfnTfnQbtF9Q NsjWuco3wZfWXy12v8UtqawFITb7qjB0NZmRTP11vFoL7sNYTCNiPMJzInlszeDxTzqQ yGMObepFqcQh/yXulQtjPEIQmOFJq+HoDhIQD+RebcTOLpRNpgLFZpYyzvg3+NgIFQ1a o8ifleR8wTQPUz19EjuppyCkbG2bK1Scny9UBuwgX0I3ILnhhqfwC2iTxER+Sbys12oy WtjuZYy6enyiAckjri8zWaoJuQ0PByPSkMfvKMq5VI9raUW20JnZgd4kaTONve7gWHEt 87Xw== X-Gm-Message-State: AGi0PuYn33UR7UarqpXKIp8dwlzMxTqUVjrXAt0b6e/f/H4HJvIp6yId 2/hLLuhpSpmOJSDDln6pcRBx0w== X-Received: by 2002:a5d:5742:: with SMTP id q2mr29365255wrw.414.1586968107226; Wed, 15 Apr 2020 09:28:27 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id h2sm5682392wro.9.2020.04.15.09.28.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Apr 2020 09:28:26 -0700 (PDT) Subject: Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx To: Kees Cook 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 References: <20200415002517.4328-1-scott.branden@broadcom.com> <202004142010.C0847F5@keescook> From: Scott Branden Message-ID: Date: Wed, 15 Apr 2020 09:28:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <202004142010.C0847F5@keescook> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > >> 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 >>