Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4378077rwi; Sat, 22 Oct 2022 09:08:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cQAAiSNfp46f1hJp61ODeKC64nJ+7PQcDxpoRWiG1QBABK+7ww0RmLkk8CNB0vYp2zs+L X-Received: by 2002:a17:90a:8c8e:b0:202:883b:2644 with SMTP id b14-20020a17090a8c8e00b00202883b2644mr63865666pjo.89.1666454908260; Sat, 22 Oct 2022 09:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666454908; cv=none; d=google.com; s=arc-20160816; b=cg+qVj9Q/2BjV+fJngWKN+0F9ab6416WCLCKcqfYaLcuUGzNRHyvFg7x8R788aVmMT veLTOv0w3/VJDgXjikDTXcVf82FUYzDq+Zmu55L2FO/Zbu4VH1NUt0NHqR2ZJadHO5mK omFa54K+R/Ha/mbm1zdLHLCXalLxETL5uXTJE85qR79Gt5dR26W7CJY4av3P5pdi7UdL hQyBjZWU0bJwrdvoIp+5nz1C2irsVQcFXeIYJwGnwajhSP6Dn7zZM+L0ClwS01bQCGT5 +wGOZsH7cBD4JJ6BENnNgclk8HTyaYfMz9/9C386oKTQ+4X04YKhf18tgg028GoFf0QV Gxzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=In+jdEa6PaDm6UxK4aTuN5Z+tRddb8x9/v/8UOAx4CM=; b=nHF4qiGXvFQV6J5CHdZXiPjBaeqa8NoNkauobsSaurNLxzSbxHS+8e+1ZvzHYdSeGv clPcuZGCpWxm017nagLiyecltazWbwazEjk8UKjiFIVen73SRlqk5ynXDbETQBzFUd7d 0IYWo41tfYQh4Vb7apl6rWHHF6KjhfAeNJi0mwxcdCJH6FjJt8Wqh2ZWbqZUTQ6/ixac 8ZwPkJGBqrULyoO5f3/qJfYX9K4/T2AZKzav9mWJGgXu6X+7d3XbwEs8OWJ4+ZqJih/w pIHkvoXZmI5rYZeLh/vhPQcPFW/t4X5MBbrx7EqInEeTDUdDVTJwbn5RAK7LKL99pq8P aL6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=avjcX0lG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a63cf45000000b0043c1067ea80si26562564pgj.210.2022.10.22.09.08.05; Sat, 22 Oct 2022 09:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=avjcX0lG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiJVPME (ORCPT + 99 others); Sat, 22 Oct 2022 11:12:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbiJVPMD (ORCPT ); Sat, 22 Oct 2022 11:12:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B16AE70; Sat, 22 Oct 2022 08:12:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 72974600A0; Sat, 22 Oct 2022 15:12:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A0AFC433D6; Sat, 22 Oct 2022 15:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666451520; bh=In+jdEa6PaDm6UxK4aTuN5Z+tRddb8x9/v/8UOAx4CM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=avjcX0lGs5FKvcorr1rpwJrsynEOYAg7eZCBvamwCXmQjykE5sZcFKeG7ynty2vnB lPCC+DgCSCcY6//vEXcP/TZwPQb251pZyc2mbOpCtgSdW21X3+P9nN3sKHxeUZ5V1N uWW7Xdw/ycciT0Y2+qf9W8E7qHS7mdVvpMf8dTY2w1g4xteLcAr6ObnbE/B9bRAzcj fAy7W8DoHvqfW25UGZz5N6pPFsUDbHhl9FQYcbSbf0xuW5kp6lgHJp5JPY8IlRLTCK 8UhYL7bV0qHhDJ6hGvahLp0JUMMuDdjHm5v1oOXmNvAL4KAnaJdPJIM88jE1Zz7N+L /1l0X67CqJ5MA== Date: Sat, 22 Oct 2022 11:11:57 -0400 From: William Breathitt Gray To: William Breathitt Gray Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] counter: 104-quad-8: Fix race getting function mode and direction Message-ID: References: <20221020141121.15434-1-william.gray@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dzif1vsoZY6O8z+P" Content-Disposition: inline In-Reply-To: <20221020141121.15434-1-william.gray@linaro.org> X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --dzif1vsoZY6O8z+P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 20, 2022 at 10:11:21AM -0400, William Breathitt Gray wrote: > The quad8_action_read() function checks the Count function mode and > Count direction without first acquiring a lock. This is a race condition > because the function mode could change by the time the direction is > checked. >=20 > Because the quad8_function_read() already acquires a lock internally, > the quad8_function_read() is refactored to spin out the no-lock code to > a new quad8_function_get() function. >=20 > To resolve the race condition in quad8_action_read(), a lock is acquired > before calling quad8_function_get() and quad8_direction_read() in order > to get both function mode and direction atomically. >=20 > Fixes: f1d8a071d45b ("counter: 104-quad-8: Add Generic Counter interface = support") > Cc: stable@vger.kernel.org > Signed-off-by: William Breathitt Gray Queued for counter-fixes. William Breathitt Gray --dzif1vsoZY6O8z+P Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQSNN83d4NIlKPjon7a1SFbKvhIjKwUCY1QIPQAKCRC1SFbKvhIj K6z5AQCj3RPjeKPKXVs69W7SAqiVcTUbu46rIwXSIikUGSybxwD+JfO7SUyOLwXt qnYk5EPvhrdJJJbHQUFmFGRg35rouQQ= =B0rH -----END PGP SIGNATURE----- --dzif1vsoZY6O8z+P--