Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9596834rwd; Wed, 21 Jun 2023 09:17:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EUyhPctylfOSb0c1eeBRFaFjRmPHNg1mQ/uYjUZR3ZywL79M2ZNmrJG0ia/XT7b/V3IDl X-Received: by 2002:a17:90a:3c8f:b0:24e:14a4:9b92 with SMTP id g15-20020a17090a3c8f00b0024e14a49b92mr22476715pjc.5.1687364241076; Wed, 21 Jun 2023 09:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687364241; cv=none; d=google.com; s=arc-20160816; b=NLFBTQnoTzh3q6O2oBM9R+8tYPWeefW5QqxSeXwXUG96AhMTggS+lf1RKkqBr5djZh Zsofz3luSLQuuTMCXp1AuZsu0LtKjurfTN0YSzJjZOpOc6UfdXrdWIbBU+yWI6103NP4 FLuZ9Ck4gipM64A0ynthHmgFMd7XdhPcIIb2Y5GYGVoCgu7hHixqq7eU24MHlm2ULZrq YcGsvIl50gvVN0Gt/pdXcvyzGZRn9ktrAAwGwiCJq/UN437mHxD7M+qEx99MNjpwbPfm vLuiE2EetcrKeKWq1M1H06WmfUcbch8wgbi4GWNeHTwdmsH8a7AF8aoAMGkgpV4rp/x7 YJDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0fCHQizRwe6wJfjeGABMJ7EtlC6+tAboqmFJcKVi+fI=; b=FjXGOpvwz54AKRn627xmCtHLCynGrYn6aYzep5MmyaOXSp7D4E7GI8BbX+3xJYYj5g cQKWtgqZcXN6ozd2ZgMtvAkR/IvhY77dVId0ayHxXSY4ZCPJ9Ysf7mL67KuB2MBWsicN npZg1MTS8sEmHsoUd1VfAdc7pbifOQVMQjwE8tKL4QtSoD/2TEqixATttYN2iHsuwgoa tq8EcrQ5y9qb1R2bqFn8wOlG0qOZyMex4djTN9RD7qy43OIRMDEj9z1Nr6dqEvNVOw0/ +e8uEXh+cbMq0qcHx4viFbCepfSwJz5EVlSmYkPoOJbpHivpeXiaj/SdvF+WDd5zC/uM YFew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="L8o1e/Sh"; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo22-20020a17090b091600b0025e9507ba92si12117149pjb.144.2023.06.21.09.17.08; Wed, 21 Jun 2023 09:17:21 -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=@redhat.com header.s=mimecast20190719 header.b="L8o1e/Sh"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233703AbjFUP4M (ORCPT + 99 others); Wed, 21 Jun 2023 11:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbjFUP4L (ORCPT ); Wed, 21 Jun 2023 11:56:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24BFDBC for ; Wed, 21 Jun 2023 08:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687362927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0fCHQizRwe6wJfjeGABMJ7EtlC6+tAboqmFJcKVi+fI=; b=L8o1e/Sh/x/QhxtTFKYWBbaCRCcfhTnkq6ev9VE4qYP8tskBtgoLOgFLGLkuC4xNE3Opge lNz1epNAoQ8zvhjLIiqXsbJuYgQ77Rc6jbLiKaKsddl43++FjlZV1fDxmpQJNqDWWnl61a /DcU3iJT5Eh8T64wXcxgGH5Z0w1VkYc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-66-Ped06gAhMRSuMJP75JcHxg-1; Wed, 21 Jun 2023 11:55:25 -0400 X-MC-Unique: Ped06gAhMRSuMJP75JcHxg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33F24915180; Wed, 21 Jun 2023 15:55:25 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.45.224.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id B81CF492B02; Wed, 21 Jun 2023 15:55:23 +0000 (UTC) From: Benjamin Tissoires To: Jiri Kosina , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Ludvig Michaelsson Cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: hidraw: fix data race on device refcount Date: Wed, 21 Jun 2023 17:55:14 +0200 Message-Id: <168736288418.3423010.16497710719241305762.b4-ty@redhat.com> In-Reply-To: <20230621-hidraw-race-v1-1-a58e6ac69bab@yubico.com> References: <20230621-hidraw-race-v1-1-a58e6ac69bab@yubico.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 On Wed, 21 Jun 2023 13:17:43 +0200, Ludvig Michaelsson wrote: > The hidraw_open() function increments the hidraw device reference > counter. The counter has no dedicated synchronization mechanism, > resulting in a potential data race when concurrently opening a device. > > The race is a regression introduced by commit 8590222e4b02 ("HID: > hidraw: Replace hidraw device table mutex with a rwsem"). While > minors_rwsem is intended to protect the hidraw_table itself, by instead > acquiring the lock for writing, the reference counter is also protected. > This is symmetrical to hidraw_release(). > > [...] Added stable@ cc tags and Applied to hid/hid.git (for-6.4/upstream-fixes), thanks! [1/1] HID: hidraw: fix data race on device refcount https://git.kernel.org/hid/hid/c/944ee77dc6ec Cheers, -- Benjamin Tissoires