From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410116; b=VHb8sK/Fpcy9JhE2pxZrbpkmzPMdBR+AVCwZ57OQj44QFKgiCymNgpcQRYFs9WJM5D7E PQRJfv2xApBbEHh/3mr61f9Oei4KtrnU3NXYwl3mbD8jC9jQdGcItrUEYHTAy2xZ23pWD y8/5mUNuPv2cJNCAL5bAQB0CHZLroQRr56y2u5zBAQoti4gcQWmzM2+ibVPusjS3NnKfK ZTzn4lDtglNrT1eirOJSDeqSMhQTkVlSkfesLVfUeO8UIKHrrRQCiksXTA1+iiMx3MBZH I43r86s+WT+Fb0q+WY7jh3o1BbzaqD81Xlbjy6cFRx0anWoV3Jb+NoiEh2UqToqsxiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410116; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=+nHUqN1mKsxEjRxg9p0xZBPBEXPTFPoca6qT8Uuh/UY=; b=QIbVupBhsqiP+TS/we88lP3wDhvyRV4lAuGI9CZqk6yUX30GGOQ+0mzFOMLXqgzxCSJb oJt93D0eib9bbsYPt2P+Kgr7HL7Ra8dzb7sXlCsRhi5BYM0+z+dRjh7k5CgBPJQNnowXs SgfHgsiKDJILQ3mIrSfoxsOQ31caexLDXzC84c8hifk+Qyf51Zv/AKlczIVEvctv0B2Rn 1RLawDqmNhu7ih3xNJvO3Rrt5NEV0unekZTaV3XqafWkt8XaKc9TJIV09lGTzk3svsRg+ Yr50hJKMHsrOfb4i1qheK2m8DMiAilQ2Vw8yfQSa8J8tIOcGm7dPqLXdN1MlUOV+CCQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=J5sKbry8; arc=none smtp.remote-ip=74.125.82.52 Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F7A7606A322 for ; Fri, 4 Dec 2026 18:48:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1F7A7606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=J5sKbry8 Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-1b5ade5e0c1so2247697c88.1 for ; Fri, 04 Dec 2026 10:48:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796410115; x=1797014915; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=+nHUqN1mKsxEjRxg9p0xZBPBEXPTFPoca6qT8Uuh/UY=; b=J5sKbry8CjYTot3xCvSCB2mhJkMAYUrFMuWW4US6ZIhaYDxYhx0R5eIYB7WaebjYvI iBH0NgkYJrImbpp/Lx9IO6tWCGAN4bzlwveNoGX+PhrMnrC/D4Q1d61G43ylzf7+t6Hi srCjYvHlAtGdcF/PCXuuF7xC4VpzyFQFmneR2Z+BTtMiahlN3FUFFkfTJM8LB+JYE6mM MLFFdece/kpNrbwRZzb50a/NaAtEJJlNvOcE6lf43nw8Co2jn0TjMs+lNzFZvRaHV/my kH250rng5oby66g2gEysgNQueftkveqrlRvOVhUXRG2q8N2E/ibiH+o5VfhpO4gFfbdB F2TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796410115; x=1797014915; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+nHUqN1mKsxEjRxg9p0xZBPBEXPTFPoca6qT8Uuh/UY=; b=c7eVpZPdGeCJBzeztDO1bMun/Z1WIRB8UHOdbZoIqKBGMVjapvPjRUSqZGN62GJGXw hEVr+cKiI9fOicqhDrdZq1mmDrCit7hrODqCDSNzsXiALx5UAnXk9R34xaT3LGwy7YZL RgTB4AFKnhWRiK5JE+3TYgHG7rJntPWVMnUZe4sMOHt/XKZv0Guisvut2rbzflmvhBCv XXJ+WIYkkgRkJmIeDCFVSL5J8cCi8ZEFkmeHoBbooQRLeo9YoctYg8oAHsuZmDnxexuz Nb71p+4kRt6xjXbF19DmGD1pIjolNO9ATsgo3JkbXca9dOLDyAPcWXwcV900XI+KEFnl pOPg== X-Forwarded-Encrypted: i=1; AL+hErEJjPCE6ALv4U76T8RaoRDYItWOOcg11M5KKGGVEa8vTivcEaueHzU2jjdbx9L2LOC9QvBMD/qQ3CuTFKFXjMLztlsE@vger.kernel.org X-Gm-Message-State: APuU4Z8Tjkqt9eYoO9hwTYod+77+89NGTfmEt1i4IgpttCPZpBnk+Mv5 vw2HAlxMbz8R8SwrSMBTcO+FEwbMH4WOrowveal6wcgMBL7Naqh7Z8q2 X-Gm-Gg: AZFdTZcykJB/fKOC/z0ztUKSeyy1/7QeRjW89xGF1hXK+tM0hmGwxaBH2T96Eqcv7GW u82yjhWhXq1OMP2H3RhZPoSrAa9dtgLjZQ1G3E5PtvoYjW02ahdUuW277er8i0rZpzLzN2ZeyJq B0Bq41INGW7Jmt3czV87tFuxeHGnbNImVBSNSXrejk1LG01FNZyGN3yw+3Vxa5sc8OIZOsPyu9w 2OgRl2rBk5QODhh+AeH/8FHROHIMpjLBxI0kMIUhhYUB8+OyuZ43n5v4aV1/HD+KOy5LsThUfZF 4XtHj33Ia86u62E0wuAHGbGPiBSEBqbh2S/RWmek3tLfCCqym64whB8w0czrHaV5lmp6zfVAhXy vciC7gg7kgpZ88WbkYr6Wg90VMeRRJFIXAl9FI9SlCZfejfd+KM8cpLc0oeUWt3pSMUZx0YHvO7 tHZw+X0zdl8rbhdtcsTQYBhyf0FcmLRtnbKrSEerhQ/lBZWIAboJ+293BMk2+6tSAGenwGpoKOe WH0pPe57mY1lL3BkppM2r5Y6oQrKSIBQeLebkWhlgpkThQFqcwnau2XTSneY1Y2fCtIFbQmzraL d7BNMfv2yMPwAW/Tir+HzzMaVffCacOD8nVZbOhmSLwqaIWcM8TpCODfy+yo5flzME8= X-Received: by 2002:a05:7022:b191:10b0:19a:20d3:a3d6 with SMTP id a92af1059eb24-1b5d70640fbmr2321429c88.1.1796410115117; Fri, 04 Dec 2026 10:48:35 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d63d04e7sm9090811c88.1.2026.12.04.10.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 10:48:34 -0800 (PST) From: Praneeth Balasubramanian To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: Frank Seidel , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Praneeth Balasubramanian , stable@vger.kernel.org Subject: [PATCH] platform/x86: hdaps: Hold hdaps_mtx when changing the axis inversion Date: Fri, 4 Dec 2026 10:48:25 -0800 Message-Id: <20261204184825.1686301-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hdaps_invert_store() sets hdaps_invert and calls hdaps_calibrate() without hdaps_mtx. The comment above hdaps_calibrate() says that callers must hold the mutex, and hdaps_calibrate_store() and hdaps_mousedev_poll() do. hdaps_calibrate() reads the axes with __hdaps_read_pair(), which runs a refresh/read/complete sequence on the embedded controller's I/O ports and then applies hdaps_invert. A write to the invert attribute can therefore interleave its port accesses with those of the input poller. The poller can also use rest_x/rest_y while they are being recalibrated, or together with an hdaps_invert value they were not measured with. Both lead to wrong position reports. Take hdaps_mtx around the update, as hdaps_calibrate_store() does. The missing lock was found by a static check that turns the locking rule in a function's comment into a Clang context-analysis requirement on its callers. Fixes: 860e1d6b46bd ("[PATCH] updated hdaps driver.") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/platform/x86/hdaps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/platform/x86/hdaps.c b/drivers/platform/x86/hdaps.c index f11f726d2062..993d9889fbf9 100644 --- a/drivers/platform/x86/hdaps.c +++ b/drivers/platform/x86/hdaps.c @@ -435,8 +435,10 @@ static ssize_t hdaps_invert_store(struct device *dev, invert < 0 || invert > HDAPS_BOTH_AXES) return -EINVAL; + mutex_lock(&hdaps_mtx); hdaps_invert = invert; hdaps_calibrate(); + mutex_unlock(&hdaps_mtx); return count; } -- 2.25.1