From nobody Fri Dec 19 09:42:08 2025 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 9CAC850252 for ; Tue, 26 Dec 2023 18:00:51 +0000 (UTC) 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--tanzirh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jH+DIUcj" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5e73e6a17d5so82458887b3.0 for ; Tue, 26 Dec 2023 10:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703613650; x=1704218450; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zRl3IvQBK/S8r0wMAY81Jjlb+fSoxXp/kN5gJ/doMRc=; b=jH+DIUcjmAFsYlTqQ5L8izcIDoMWM3Z1fM5HpqQQ5USLhDXh863nQ33Op1EwVGvs0V heiPNSVwogU0XKA7IATn0SqnkLrj5tKZBfTEt+HUqLk/ayZbMmHZuQpo8K2KLWja4E5P +kXlwzV4kvbJoYsG49YmJKqlc4fmxfgqYs9jQVTiJsEyg5vLhGHZ4vXOQPBPkn8ROza9 6LGkukiPNqBi7x+qtBAhkwuwxJvp+IfgfKFHORnY4UrHrQVF+LWkw2xJeEz8uIqHPhyp FBiPmMCfdB9lpXmO4oAYUWiXHkwQN6tcQFzl0URcojeB1C9r8Ma2esU9e5cfriKjp+s5 LAAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703613650; x=1704218450; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zRl3IvQBK/S8r0wMAY81Jjlb+fSoxXp/kN5gJ/doMRc=; b=JXgwtjD0o+mEZz8K0PQA2h/AstV3JcanXcb/aKZNz7JQf/wyqUt+KpzomUIFB4USek hWs0Ail0PsLPrJWQQlslTzD9/WqyHQz6W6GxjN5smg3wauOtCBvzYO8R2jNF3eh/sksn C949iGgXZCRawFbMWygL8E13dFhJX6U76IN0sWJIiBnIHGT+/ESXIw2mCI0MObUQbw4B V4qrTcRU7A6ziA6oIdHHOLrNzGjMlMvqLe3TRTNURbqZEqAmEXJsSdFhtMo1htOX0Myc cyWNgibmSvb97TshPLiN8IwV+HCSRpbgZMla6tUut6bwz7sD1OcID3WP/66JC1QRq1jW vRHQ== X-Gm-Message-State: AOJu0YztS5awlU7e/BG/NI+pD18IevmRU4aufPk3do7vQks4qGaktDU4 rrZxcw8yKr+gqd+Mm6qjJ0yqqIF60WYW6DhbW+o= X-Google-Smtp-Source: AGHT+IFRPUKj51WecaqI4THLAuvY5XiRmjq7J5vmGoW3BOStZVw2cSXzhLAT58EK9vhe2LUl55MdwfThsnfj X-Received: from tanz.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:c4a]) (user=tanzirh job=sendgmr) by 2002:a05:690c:368c:b0:5d3:8857:b78e with SMTP id fu12-20020a05690c368c00b005d38857b78emr3998773ywb.10.1703613650634; Tue, 26 Dec 2023 10:00:50 -0800 (PST) Date: Tue, 26 Dec 2023 18:00:00 +0000 In-Reply-To: <20231226-libstringheader-v6-0-80aa08c7652c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231226-libstringheader-v6-0-80aa08c7652c@google.com> X-Developer-Key: i=tanzirh@google.com; a=ed25519; pk=UeRjcUcv5W9AeLGEbAe2+0LptQpcY+o1Zg0LHHo7VN4= X-Developer-Signature: v=1; a=ed25519-sha256; t=1703613647; l=6769; i=tanzirh@google.com; s=20231204; h=from:subject:message-id; bh=hIYeBjXsSax2iHEZlDh3Xt19cOiTxbSkrynkTtDAKho=; b=1b4ZUQXbUSIDZ1hxa5E5zrunUIoOIn1VeJ8hz3PiqfvblTOESIGkFCuK0H3AONFcHdMQUnTM+ vFtTl8nVvYcAvcAO5K3/jd6Mrp97rLOHO9ZBPfMblEBk+13qCWDnvkP X-Mailer: b4 0.12.4 Message-ID: <20231226-libstringheader-v6-1-80aa08c7652c@google.com> Subject: [PATCH v6 1/2] kernel.h: removed REPEAT_BYTE from kernel.h From: Tanzir Hasan To: Kees Cook , Nick Desaulniers Cc: Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Greg KH , llvm@lists.linux.dev, Al Viro , Andy Shevchenko , Tanzir Hasan Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch creates wordpart.h and includes it in asm/word-at-a-time.h for all architectures. WORD_AT_A_TIME_CONSTANTS depends on kernel.h because of REPEAT_BYTE. Moving this to another header and including it where necessary allows us to not include the bloated kernel.h. Making this implicit dependency on REPEAT_BYTE explicit allows for later improvements in the lib/string.c inclusion list. Suggested-by: Al Viro Suggested-by: Andy Shevchenko Signed-off-by: Tanzir Hasan Reviewed-by: Andy Shevchenko --- arch/arm/include/asm/word-at-a-time.h | 3 ++- arch/arm64/include/asm/word-at-a-time.h | 3 ++- arch/powerpc/include/asm/word-at-a-time.h | 4 ++-- arch/riscv/include/asm/word-at-a-time.h | 3 ++- arch/s390/include/asm/word-at-a-time.h | 3 ++- arch/sh/include/asm/word-at-a-time.h | 2 ++ arch/x86/include/asm/word-at-a-time.h | 3 ++- arch/x86/kvm/mmu/mmu.c | 1 + fs/namei.c | 2 +- include/asm-generic/word-at-a-time.h | 3 ++- include/linux/kernel.h | 7 ------- include/linux/wordpart.h | 14 ++++++++++++++ 12 files changed, 32 insertions(+), 16 deletions(-) diff --git a/arch/arm/include/asm/word-at-a-time.h b/arch/arm/include/asm/w= ord-at-a-time.h index 352ab213520d..f9a3897b06e7 100644 --- a/arch/arm/include/asm/word-at-a-time.h +++ b/arch/arm/include/asm/word-at-a-time.h @@ -8,7 +8,8 @@ * Little-endian word-at-a-time zero byte handling. * Heavily based on the x86 algorithm. */ -#include +#include +#include =20 struct word_at_a_time { const unsigned long one_bits, high_bits; diff --git a/arch/arm64/include/asm/word-at-a-time.h b/arch/arm64/include/a= sm/word-at-a-time.h index f3b151ed0d7a..14251abee23c 100644 --- a/arch/arm64/include/asm/word-at-a-time.h +++ b/arch/arm64/include/asm/word-at-a-time.h @@ -9,7 +9,8 @@ =20 #ifndef __AARCH64EB__ =20 -#include +#include +#include =20 struct word_at_a_time { const unsigned long one_bits, high_bits; diff --git a/arch/powerpc/include/asm/word-at-a-time.h b/arch/powerpc/inclu= de/asm/word-at-a-time.h index 30a12d208687..54653a863414 100644 --- a/arch/powerpc/include/asm/word-at-a-time.h +++ b/arch/powerpc/include/asm/word-at-a-time.h @@ -4,8 +4,8 @@ /* * Word-at-a-time interfaces for PowerPC. */ - -#include +#include +#include #include #include =20 diff --git a/arch/riscv/include/asm/word-at-a-time.h b/arch/riscv/include/a= sm/word-at-a-time.h index 7c086ac6ecd4..fae33cc04f8d 100644 --- a/arch/riscv/include/asm/word-at-a-time.h +++ b/arch/riscv/include/asm/word-at-a-time.h @@ -9,7 +9,8 @@ #define _ASM_RISCV_WORD_AT_A_TIME_H =20 =20 -#include +#include +#include =20 struct word_at_a_time { const unsigned long one_bits, high_bits; diff --git a/arch/s390/include/asm/word-at-a-time.h b/arch/s390/include/asm= /word-at-a-time.h index 2579f1694b82..203acd6e431b 100644 --- a/arch/s390/include/asm/word-at-a-time.h +++ b/arch/s390/include/asm/word-at-a-time.h @@ -2,7 +2,8 @@ #ifndef _ASM_WORD_AT_A_TIME_H #define _ASM_WORD_AT_A_TIME_H =20 -#include +#include +#include #include #include =20 diff --git a/arch/sh/include/asm/word-at-a-time.h b/arch/sh/include/asm/wor= d-at-a-time.h index 4aa398455b94..95100ce128d6 100644 --- a/arch/sh/include/asm/word-at-a-time.h +++ b/arch/sh/include/asm/word-at-a-time.h @@ -5,6 +5,8 @@ #ifdef CONFIG_CPU_BIG_ENDIAN # include #else +#include +#include /* * Little-endian version cribbed from x86. */ diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/w= ord-at-a-time.h index 46b4f1f7f354..e8d7d4941c4c 100644 --- a/arch/x86/include/asm/word-at-a-time.h +++ b/arch/x86/include/asm/word-at-a-time.h @@ -2,7 +2,8 @@ #ifndef _ASM_WORD_AT_A_TIME_H #define _ASM_WORD_AT_A_TIME_H =20 -#include +#include +#include =20 /* * This is largely generic for little-endian machines, but the diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index c57e181bba21..75d0f6b11a48 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -47,6 +47,7 @@ #include #include #include +#include =20 #include #include diff --git a/fs/namei.c b/fs/namei.c index 71c13b2990b4..189ea53ad635 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -17,8 +17,8 @@ =20 #include #include -#include #include +#include #include #include #include diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/wor= d-at-a-time.h index 95a1d214108a..ef3f841c6625 100644 --- a/include/asm-generic/word-at-a-time.h +++ b/include/asm-generic/word-at-a-time.h @@ -2,7 +2,8 @@ #ifndef _ASM_WORD_AT_A_TIME_H #define _ASM_WORD_AT_A_TIME_H =20 -#include +#include +#include #include =20 #ifdef __BIG_ENDIAN diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d9ad21058eed..162660af5b7d 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -39,13 +39,6 @@ =20 #define STACK_MAGIC 0xdeadbeef =20 -/** - * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long va= lue - * @x: value to repeat - * - * NOTE: @x is not checked for > 0xff; larger values produce odd results. - */ -#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) =20 /* generic data direction definitions */ #define READ 0 diff --git a/include/linux/wordpart.h b/include/linux/wordpart.h new file mode 100644 index 000000000000..43c1a8ae5152 --- /dev/null +++ b/include/linux/wordpart.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_WORDPART_H +#define _LINUX_WORDPART_H +/** + * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long va= lue + * @x: value to repeat + * + * NOTE: @x is not checked for > 0xff; larger values produce odd results. + */ +#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) + +#endif // _LINUX_WORDPART_H + --=20 2.43.0.472.g3155946c3a-goog From nobody Fri Dec 19 09:42:08 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 62F6C51C32 for ; Tue, 26 Dec 2023 18:00:53 +0000 (UTC) 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--tanzirh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="f73C2U3/" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dbdb46770d7so5562076276.1 for ; Tue, 26 Dec 2023 10:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703613652; x=1704218452; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GQnopqwXCPJwf1o31D0QkbeUw9iOW+EHq9+aREsG9fw=; b=f73C2U3/jNohZsnmPU/1qJJSEHwpxbCFXOoE9tPRapD5CwVVDo0yHg+mM79FLkOWNI 4mR58BHVjKgFv1TKAYARakV188mPY/1ccQJb3TdP4PIAJKozZJJ80uVli1e18KP5rN68 ty6wSj731PBpSLR9EGyZQ1AkjqVHqanNjMHwo5V/cZTkBH8uQA89d0R+reqchBdfSkbT nAV0K9PuFsyioln/BtGO6nWGOJvDXIFYXMq5rUad4es2lHZNN4TE/ATbzI06u7RQ+Obp Ivf6V4fh8lC5n/vtF3qkpam/aESr4vLiaEho8QfFu5ZtekC/EG6/zEsBUYS5F0DohQy7 TdEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703613652; x=1704218452; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GQnopqwXCPJwf1o31D0QkbeUw9iOW+EHq9+aREsG9fw=; b=c6/8qdKFjfSBlx5R2Z6QItj6PlqYkyNutEt3Y6dDljU86B8m/i0NLdkPMarcwzSfV4 Bc/Brt7uUc1P9JGpGzyiLiN+uaSU6Z9tU2k+QNTVpp0CVGDWg2sCGDc67GtiR0sP1F3U iMLOC9d55RO0Hj8vhwL7xYVZM+DGnW1DsY4DHaga2yt6WOVJbgNuyxg/rjIbbz2L72id mdplGjBWjgq5gVjDDdFa0hDuOeoNwWMgbZoJgTQz9HZwO8h1YbzAMi2UVGwBAfI8DYmE fTOe2Ex64kUQBT/qdDTHZ5/ltjFJABebzYmDQUr39ihjAfzksKB53glRXOdHl266m7Id cjaQ== X-Gm-Message-State: AOJu0YwmJxwpMX/6IkHuEHKfHgJt0xClq3jr1vMTjBM6mrD/fFzsPZTu Y6h0Iw2ezHl6bqls+OalJOkmTj45On2OFQXcs0c= X-Google-Smtp-Source: AGHT+IFnQX1XkxS5gH/MspqNzbGruimeDM9Y6sSzYazzjx6BG39h+lL/hwfcAIIYMQak4etQSIZs9fP7PwkI X-Received: from tanz.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:c4a]) (user=tanzirh job=sendgmr) by 2002:a05:6902:1369:b0:db5:4692:3ab7 with SMTP id bt9-20020a056902136900b00db546923ab7mr2904081ybb.8.1703613652544; Tue, 26 Dec 2023 10:00:52 -0800 (PST) Date: Tue, 26 Dec 2023 18:00:01 +0000 In-Reply-To: <20231226-libstringheader-v6-0-80aa08c7652c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231226-libstringheader-v6-0-80aa08c7652c@google.com> X-Developer-Key: i=tanzirh@google.com; a=ed25519; pk=UeRjcUcv5W9AeLGEbAe2+0LptQpcY+o1Zg0LHHo7VN4= X-Developer-Signature: v=1; a=ed25519-sha256; t=1703613647; l=1528; i=tanzirh@google.com; s=20231204; h=from:subject:message-id; bh=kLkju4pFci+nx2b0Vi+mSe3j1L2n+dGn+lmNlbPb2hw=; b=mnCi82pkDQhlhIICzaZ9DKF5LW8Zyzd5r/uBAp0bJK6KM0spwTVgAqlizK/vym/fbXNq9suqF X+rsoO7J6/2AhGVmTzCIFtKYKnxLFv7kczzhqPaEYO9mne7MtTmJCDp X-Mailer: b4 0.12.4 Message-ID: <20231226-libstringheader-v6-2-80aa08c7652c@google.com> Subject: [PATCH v6 2/2] lib/string: shrink lib/string.i via IWYU From: Tanzir Hasan To: Kees Cook , Nick Desaulniers Cc: Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Greg KH , llvm@lists.linux.dev, Tanzir Hasan Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This diff uses an open source tool include-what-you-use (IWYU) to modify the include list, changing indirect includes to direct includes. IWYU is implemented using the IWYUScripts github repository which is a tool that is currently undergoing development. These changes seek to improve build times. This change to lib/string.c resulted in a preprocessed size of lib/string.i from 26371 lines to 5321 lines (-80%) for the x86 defconfig. Link: https://github.com/ClangBuiltLinux/IWYUScripts Reviewed-by: Kees Cook Signed-off-by: Tanzir Hasan Reviewed-by: Andy Shevchenko --- lib/string.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/string.c b/lib/string.c index be26623953d2..06d9b46875ef 100644 --- a/lib/string.c +++ b/lib/string.c @@ -15,19 +15,20 @@ */ =20 #define __NO_FORTIFY -#include -#include -#include -#include -#include +#include #include +#include #include -#include +#include +#include +#include +#include +#include =20 +#include +#include #include -#include #include -#include =20 #ifndef __HAVE_ARCH_STRNCASECMP /** --=20 2.43.0.472.g3155946c3a-goog