From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (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 AE3413B7B6E for ; Mon, 28 Sep 2026 06:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790577510; cv=none; b=G9NV5PkSF5rZKKVV9IoAaFZZXU1ZJEs9njVr3hu8hir5DycQWypw3LjBqeZNnSGUWne7GEB0dyVj3YweaUIOvlwKx/jUwPvybjtwKFDhrvmebf9RlCfLzADw5hbz03+7pfXmcHvAsV/Vx/o3Rg10AuGSUdtPV6FrBK4UGowura8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790577510; c=relaxed/simple; bh=5akO349ziHHQzeFqJy7Iek+neIXejMZDqEsEI4U1ydw=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ELBxDukRa7FYBvh/R+yAgCjh5XECTqfpDambEC8ZYNIm0Hp64/swMnqO60sFFBDpsFDaB4NF0itHFMVr1AGDZv7qb8EiQQzMm8wG0xu6aTJzMv42v+1bbkHeLsWtn4uaD72kv1UNbe18eNzL+wBtyzexJHFrnf1EZqKwLFQaO4c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--morbo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nwB23JKN; arc=none smtp.client-ip=209.85.215.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--morbo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nwB23JKN" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cc11b5dd54dso3962772a12.3 for ; Sun, 27 Sep 2026 23:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790577508; x=1791182308; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0EJUAZOGIk1GIP9JvusI2ZWKGypYDZJOnDVNHDexwyc=; b=nwB23JKNa3LXNkka0N86Hbv9um1DzzBs36tH1eY/jEzsXIF+EDL3OnOgeAz0q33fHP oQN30V0igkAQLKhuUlw/p/GlUVV+ApACW9o2rf9ZO8uZ1HKNCtwfpMa/BQnE8lzQrfA8 YfpSi3tq/SVL5koZIKqh/02KaCHbemoLfBnRUXHyFqngomFm1Ac4q0285zkEAAvXM0QS waSi+1rEn7ux3iBkO8qcODBjIFriqG2xm0Yni6tqStXSPetKcePo/wEw502nyAMoZ/4Y fMKm1HBP0QAGRnvsRSwXABiWUUIhorpBECVRc7MaoVpetoLyFR6LZh3RTXeqaif485qV 4x9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790577508; x=1791182308; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=0EJUAZOGIk1GIP9JvusI2ZWKGypYDZJOnDVNHDexwyc=; b=d9W9rnrbFttAogZqSssUN+jO2DfoXM7GIPJTTKPO5sFkA/rNDU6e3OeIjdCHmEJeMF 1bCQwk9XX6wC9qkcAxxU9apcwSyhItMz327u/PCPUa9hvcdg4YJGsRCpO4AkjoRAFPar Tx1zk3sDvPlN9tZ46fbMHc6W1l+E6+zr/8t8bFrhpGbZ0eS4LwYNf9tIKu19nFwPL9hu 3HiEYzBvD6pAMK46GmYkWaNIduFa2wx0YpV+namGyjg50kQQqqH+Oul7zF8eF4KPMCCw VEWWITVRIF9qU08chA16GT4sdz8KOQmhib3+ZBGdHImC1bptAEauABrMR7+xYd99NcxL Ml2Q== X-Forwarded-Encrypted: i=1; AKwUvBz35Y90K4LHT9KDIqljYISA0mmiLde0Wp3ugeziuzS8Li3SANI9KidqrVxBNBDm957B/X4av6onYbo0Kic=@vger.kernel.org X-Gm-Message-State: AFuF++kYQwRE157N4kv83r34zWNY22gfSeXLbWmVn95WLDC1jv2yh+qL Gm658bi/fdjT3JafH5NnVjwW3zXuPcHizMUNLk5J9xTEsDIJbR1frG1Gs1FSITToq2aBEBGlSOK i X-Received: from pfbdk6.prod.google.com ([2002:a05:6a00:4886:b0:884:61ff:9f80]) (user=morbo job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:68c3:20b0:3de:140a:3e31 with SMTP id adf61e73a8af0-3de140a43aemr6197451637.49.1790577507755; Sun, 27 Sep 2026 23:38:27 -0700 (PDT) Date: Mon, 28 Sep 2026 06:38:24 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.56.0.rc1.315.gc6ed9934b7-goog Message-ID: <20260928063824.1386524-1-morbo@google.com> Subject: [PATCH] gpiolib: annotate struct acpi_gpio_mapping with __counted_by_ptr From: Bill Wendling To: Linus Walleij , Bartosz Golaszewski Cc: Kees Cook , "Gustavo A. R. Silva" , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Bill Wendling , codemender-patching+linux@google.com Content-Type: text/plain; charset="UTF-8" The 'data' pointer field in 'struct acpi_gpio_mapping' is associated with the 'size' field, which represents the number of elements of type 'struct acpi_gpio_params' allocated for 'data'. To improve bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE, annotate 'data' with the __counted_by_ptr attribute. Analysis of allocation, assignment, and access points shows that the pointer is never accessed before the count is set, which guarantees that this annotation is safe and will not cause runtime panics or false-positive bounds checks. Cc: codemender-patching+linux@google.com Assisted-by: LLM Signed-off-by: Bill Wendling --- include/linux/gpio/consumer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index fceeefd5f893..2b80cf7aa7e7 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -667,7 +667,7 @@ struct acpi_gpio_params { struct acpi_gpio_mapping { const char *name; - const struct acpi_gpio_params *data; + const struct acpi_gpio_params *data __counted_by_ptr(size); unsigned int size; /* Ignore IoRestriction field */ -- 2.56.0.rc1.315.gc6ed9934b7-goog