From nobody Sat Feb 7 22:21:30 2026 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 083332F069E for ; Mon, 26 Jan 2026 04:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769400005; cv=none; b=Z5oQeHP9nfU3y9UM4/YJu898TnRIwvAqefQPyhIRhqX42wf8lmX6LhmzCfvbvfXKIXc/iCntq6QraDQp0pndGY2I/X/OudOdQXDGXOW8jg2k6+nR2WkD3N/o3yqoD/CHe1OG0mq8t0cgDmrQSQWo5nITufYtyxHYqKc09fojZc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769400005; c=relaxed/simple; bh=dWe/Ofg1Ju70PTF+2ND9l7SJJ9rV2eyZ7T92BJiX644=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FOFmIWI3cuSi1u917L/KHPzCjLGZsqx3CDXaXal+6LZK1Pmgaew1+R+vs5CEhDP2cGfmBJnsYQeLP4W97kLqa7J+Oyni6UDB/WiWH6ywPoAs9Ub9gnXuzjBCckh0Gf8IKAmmd0177REFYAONUwX95jmys+0poMytPJYAf8J0zR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JXkrTi5C; arc=none smtp.client-ip=209.85.208.173 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.b="JXkrTi5C" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-385b6e77ef9so37601031fa.3 for ; Sun, 25 Jan 2026 20:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769400002; x=1770004802; 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; bh=qOBDD584N2G3qYvT8oMwoUGO5hkpiwx3PvZwbmC4EP0=; b=JXkrTi5CdI2s0Toa/N3GkeOYN0uErSAPQP0IANj5jcMOdEmUx7ppOq5yaDKn7NScMO MHsJDiW4H277NroVipvdzaup0J77u5n0MlPEGu0zJ6mPP3avuONaucfvjLPNrmLCbqby T6J+U9/nqCsr/iztMmKcYNFxUNWgeMxlbLDr9caqVDlUGCNjAAMRR/R1y7XRsn8ssiwY gBIhLwm6yGURaqzUerYmXVVzx56l4gUGAnf8CqI9/8xHntReCiRaosZ8U8xPATzsG+VP BNzQh3cDj21mnHzBw9ng0qRxSy0aKtZ0YnrUTajSn0kg/EOr4LG/fs7M70ELj6HK/AEO j1vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769400002; x=1770004802; 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; bh=qOBDD584N2G3qYvT8oMwoUGO5hkpiwx3PvZwbmC4EP0=; b=hh2ETKi7P7SIqyLsymShBuFN2XUfkPm3wBqhv327Q7s6fJOwTi6ZNBre3woUXoQmVi bzjADgEVmyqo5uGRGsCxap3fxxLfZgF/AV84wrUoMd15uNgjffp4W2436NnsJiDASN+z 1HXyDQ9odBJKUAiYy0AtKBRdoHwehIcQVXMLK5og3BQe/wYpjDmJI3q1Cn4ZfaALQiir JdysBpLtN4Na1CJdRQmes39b1AoFancvsvhQ46m+RueJVHOZ46d0CGtQrnrzjLG1b+N2 uWN+ZKLf4xyAn5tMT8w6UZzZG/JNTShUW0VcFSWWNgMWNbZBdzMnB7Z7dBGa4SAfOzgQ kmaw== X-Forwarded-Encrypted: i=1; AJvYcCVkXiWl4Xqpmz64dhNcFfuAlhfDNbhY0dx7AQXXzbquYo0TPNHW8wbOVYuJNU1u+lNTRu21pgSFP9AuHEo=@vger.kernel.org X-Gm-Message-State: AOJu0YyclNzpi14qnDRWAExM1TB3M74soKgqWpxdKcrP38k9uzJRzrIi VU4pCnSn4jCtHILKqe6Z1L8dA40f1RLeOnsmYO1SkCBbv4YIo6NCpYC2 X-Gm-Gg: AZuq6aIiyLfZ6yhfKsjOuNHqyKhS4tQIy4DQRL7AnPE86vvDlIO81aVKDnXmIGc1cuQ HudE+SrYvKkNR2fujwehkOg3lf8k8D6aihb99vHIEX5JijLrbcfRTR/6/ouVUVjae3AEDRTDa9i ORLvmBIjIJWzs8T0l0ELv/V2fCn/+pAdxsWwyIb4Ap9ul7KqM5H+/6cE41udfosNFSD79FFhS0S Rxx1jQaRdRWMRgJ42eQDOfs3NiCmFApdq0oSJd+2iPNS+C2q4MAWs4fg3LkwJ1QzZ7vxhLljYb9 BWfJyiQ+BXertKMZKNK/YkgYFHifkC4rUSjTl4L3e/Oen5Ay3MWLNfkQHQCDG/4jnTipJ28UGDB EjJDD7XtEa8e+4YM44dJlBvm2F4CMLI6epUfHqbzTwqmxUzhxfmsz+jQAvKkrHYEka9mhebOvNT uaXdYxc6mVn/O4vYvGff6pIi7tzNMdXIhw X-Received: by 2002:a05:6512:304e:b0:59d:f669:c924 with SMTP id 2adb3069b0e04-59df669c967mr685191e87.27.1769400001890; Sun, 25 Jan 2026 20:00:01 -0800 (PST) Received: from happy ([217.15.199.233]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-59de48e5fc6sm2434040e87.34.2026.01.25.19.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 20:00:00 -0800 (PST) From: Denis Sergeev To: westeri@kernel.org, andriy.shevchenko@linux.intel.com, linusw@kernel.org, brgl@kernel.org Cc: linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Denis Sergeev Subject: [PATCH] gpiolib: acpi: use BIT_ULL() for u64 mask in address space handler Date: Mon, 26 Jan 2026 06:59:14 +0300 Message-ID: <20260126035914.16586-1-denserg.edu@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The BIT() macro uses unsigned long, which is 32 bits on 32-bit architectures. When iterating over GPIO pins with index >=3D 32, the expression (*value & BIT(i)) causes undefined behavior due to shifting by a value >=3D type width. Since 'value' is a pointer to u64, use BIT_ULL() to ensure correct 64-bit mask on all architectures. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 2c4d00cb8fc5 ("gpiolib: acpi: Use BIT() macro to increase readabilit= y") Signed-off-by: Denis Sergeev Reviewed-by: Mika Westerberg --- The ACPI specification does not define a strict upper bound for the number of GPIO pins in the Pin Table. The value is derived from 16-bit offsets inside the resource descriptor, which theoretically allows far more than 64 pins. However, the current Linux GPIO ACPI OpRegion handler represents the pin state as a single u64 value, which inherently limits the number of addressable pins to 64. Thus, even though the specification permits larger tables, the existing implementation already assumes a <=3D 64 pin mask. This patch fixes undefined behavior in the valid range [32, 63] on 32-bit architectures. Extending support beyond 64 pins would require a different representation (e.g. bitmap) and is outside the scope of this fix. drivers/gpio/gpiolib-acpi-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib-acpi-core.c b/drivers/gpio/gpiolib-acpi-c= ore.c index 83dd227dbbec..d42f769eeb11 100644 --- a/drivers/gpio/gpiolib-acpi-core.c +++ b/drivers/gpio/gpiolib-acpi-core.c @@ -1159,7 +1159,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physic= al_address address, mutex_unlock(&achip->conn_lock); =20 if (function =3D=3D ACPI_WRITE) - gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i))); + gpiod_set_raw_value_cansleep(desc, !!(*value & BIT_ULL(i))); else *value |=3D (u64)gpiod_get_raw_value_cansleep(desc) << i; } --=20 2.50.1