From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 0B75B2F39C1 for ; Mon, 26 Jan 2026 04:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769400006; cv=none; b=rnLfKM6eKH/Ib20VrN+Alev/XH743s59FaC7mryySjOQvB9csvlqNsoXRfyVHIdZZVnVmEMS81CRMnQ7CSuKGtqpw5FAwaKkUz3+aQVszy5gZYbVF+Rpn4teJaMus2qy2KiSJ95aRUozgBh1+iMm3J3LA9aI92VWa/bP4Y8AI88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769400006; c=relaxed/simple; bh=dWe/Ofg1Ju70PTF+2ND9l7SJJ9rV2eyZ7T92BJiX644=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CyC1a9AoFZ/vjmrlQsyJejTYT+MQ5InsoHGvsRNM/lRjUE7Uvfbq4lFDMaj6PfMdA46K9qDkn9EQ8yXggzZhseMKVGVtfijBIN81p6JcUIL2sLe0Wf8owCETqeIvv1LiRygznn+n8LiIn8rSIEFDV+lJt1piXoGxkyt2yjEAujw= 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.167.49 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-lf1-f49.google.com with SMTP id 2adb3069b0e04-59b6f267721so3764292e87.2 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=RpG0J74tuWOQe5+hxkyomOowgvGLbyUjHssDlf+HFecdC9D/kD3bBVnIBPvrsdxiVr wvI+4H1U0x0aQpZKfYckD4WWwQG5KbOsvMDe2UtSes221ZMBm61YG2Dt/NGCHOnxS0FG sJaSIkKUsPs7lT4H/koDmvQXd97jezW57KohQ0aM3LtsvIINCfbDqh+k2kbZAhWTUwH6 Y7vdaNVhiIeXXei4tOvA3QKmYFXz6rUY4vB0xwU/C+aIhGrWMAMRF5NEbDaWMAdbCkZg ZTRP8hDADCsRCvKzJFqBMEiCFu5Uw8kvo3+R+8WoI6TX+q/vFr1fZnlHzFjfbphlyHad T/qA== X-Forwarded-Encrypted: i=1; AJvYcCXoF1ii/UjPMUFsF6fmMxTbk1tfnHtjkjDMxh2+r9F0G2GH6DJooyDwH+RJjoMmikSlCbDZusWnAnxd@vger.kernel.org X-Gm-Message-State: AOJu0YwfYEHTsv45mRXXdG+F44tzMx/Z5iWLDo/w0sv2jARHB8GLsBRJ fdwwclVA2idRb9HnUwdzXhXlCIs+6SXcuYmT0Pi4G044XU8+7UWX0Ea5 X-Gm-Gg: AZuq6aJgg5eYYF9MFnqexN1YoljHBRGgzFwCeVMmiqql+6ilfPXM4z3Obk4kPA9AbaR rLP9vUfgAP7aahSmFHVEwKaM40eBMXLUhjYg73m/g0Pj7uQ8XVcG5+Y3CEOj9Vnqrmjkqsw9nq2 E+OOzJRA7RLWbbgEkUgagxqPudHyL+zZ9QlFa0eGIQxw+pzIk/Lkv819d9/LlQBZr8n27gqPFLT hgfBBWF5LYyGxnFBdqGIAXEFhXzond+AagOEd8xg1ZGKukWKrSqKJmVCtQPmfRIlwt21SbgFYeq zWgGy2IejsXWlcCaX/db7i7+rwBaKDlYG2bgXCjqgxkbsGPShr7Y8nYXeIgrRUD2/lNIONfYrOq lGiJTe+iup0TYW9TA6grP+oiEyS/112XTirIEZSD3KqdV/B75D6I1gBkJJH6ucC/X6+LUjoTK0l 4X1Czju2p2gGAO/UDZnUFzZfJ5+KbMDNeF 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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The BIT() macro uses unsigned long, which is 32 bits on 32-bit architectures. When iterating over GPIO pins with index >= 32, the expression (*value & BIT(i)) causes undefined behavior due to shifting by a value >= 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 readability") Signed-off-by: Denis Sergeev --- 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 <= 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-core.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_physical_address address, mutex_unlock(&achip->conn_lock); if (function == ACPI_WRITE) - gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i))); + gpiod_set_raw_value_cansleep(desc, !!(*value & BIT_ULL(i))); else *value |= (u64)gpiod_get_raw_value_cansleep(desc) << i; } -- 2.50.1