Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp112853rdb; Tue, 19 Dec 2023 10:49:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2UJKKVeqMYCXSmmVsarSX4XCWTOPl5V5rHKyiWKIRFMlvLB9yr74pAK5S9RiSSlY1NSsD X-Received: by 2002:a05:6870:d88d:b0:203:d175:8d40 with SMTP id oe13-20020a056870d88d00b00203d1758d40mr2560245oac.71.1703011742000; Tue, 19 Dec 2023 10:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703011741; cv=none; d=google.com; s=arc-20160816; b=y4CT1OUldapf/uzB64PRFY7mNC919WdkS7Pc5PKd+0Ctf0wBZAS3/SS+G9WY0voFzk PqwQX2JdCU0ojaVMuPWPmVQGFtdrIFUWVbnYaCdwUQJxDd1ZqrAS2tGAcViT6XOJD4tW gcUhiJ5bXzIntxvl2BOo1gMHSENsxdm4d26Kh5TxOh2uBH3axPTlJjoJhESTIB4jMoWd MZiTrWEzkQ4o1uzKehP/aDCH4D+XNcbAylF3NLPWIibkvgM5aEjXU88A7I0lXWLXAUum YFRdSEpdlbiO6wC137g8H/jOSd8BBRKLumXHbLByVm2EvhnTvsTKtGHAwlxCbOaIvtdV DKew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=xbybSsV/bS+3WyIy5bQjflj1d8kB/aeheYO00KzfCc4=; fh=FbtzLkgqPrL2lUNNvz5lQHVZdp+H3VgNt+iftcSmFZE=; b=Ab5GzevMH4ywyPy2+aVE/yKf5ZDrdZH4phxbGA7MpA3BOa47RbyEIGesyroKRkuGxE BdXhVc6h5fOYyHO7ceZCEkcRdGLNOY28g/8saNGDYN2fSTwz+lZm6HM/JOe7A3QQTtys gaBijlRp7bf4t3I61VtXkTOD0zve+RdMxOZpaIhxLsydz2/q7Ii4Bmgk+thxopywQK2x XcVM8//t5gv/tS78iBIvY6YpSwLndWAI2y5Due0W4p392+I/QiGeGyk6qPCMO49kBoFN V+f8EFflwbct2Zrhodl58tlCzLaVHHyL/8SBShglKYgI6MwNlBhRxKm/GuYI+vZ6ybeT yRgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=k0ibUbA+; spf=pass (google.com: domain of linux-kernel+bounces-5829-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bx2-20020a056a02050200b005bdf59618e3si88979pgb.497.2023.12.19.10.49.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 10:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5829-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=k0ibUbA+; spf=pass (google.com: domain of linux-kernel+bounces-5829-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 67E15B22239 for ; Tue, 19 Dec 2023 18:48:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0203838FBE; Tue, 19 Dec 2023 18:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="k0ibUbA+" X-Original-To: linux-kernel@vger.kernel.org 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 7E730381A2 for ; Tue, 19 Dec 2023 18:48:06 +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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5e786bb28a4so13919547b3.0 for ; Tue, 19 Dec 2023 10:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703011685; x=1703616485; 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=xbybSsV/bS+3WyIy5bQjflj1d8kB/aeheYO00KzfCc4=; b=k0ibUbA+WFfOqLoeNglvZ9mkuddQovKw1lLFXQffRxzqLwRspUl3PHYGWHcF2l9Bi9 EkQKR9sBFzc9SCk2GRaVWQhBy+3mZNEHkZT/eJ8/kqr8E/4806M6j+yMHUK9Zgxw2jhD YkplWMIrE/L+9cYPnNFV+vieEXdTz5kCrQK8893pi1yt40/7KlFHOQ0gqMcOQuP++6SM F0cafn7BvXr7JkcwekeHsYkeAY16TfIcaxVM+9JrrLtO8DQ2k5r9UO0rWFUNBRDBfasF qFzu2MX0ekz+YDXQ32/sd2j7EZjVePOclgyJzOql19Z1zE/6JLXqnYBgUxT0s+BKER1E T36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703011685; x=1703616485; 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=xbybSsV/bS+3WyIy5bQjflj1d8kB/aeheYO00KzfCc4=; b=A9yoOALGvHpz4Ics291lKg/VaYMT+Fk0yK8y4JIvGcHJCQjl+gkOm0cc01eM4JQJDV wLynTuomONbOnN/klyXEmnxRIzQnru/0sVe4mfeTShszcL9FVA0uo/j81jBadj3rHajD 7Q8JQMZY7w7WwuWgqP190vkDCvX5zMIrPL7zfSpXinqndMguq/PbU4NdyrlKIKNCYr2k SXs97W57YrLSd/EB1kx2UGm5b8cmHNNsc8F6h+W5VNIOnrC4pwuO2uwK83cq+QZ6pxAe 6P/hL2r11fNFZfEHdJTynFAliQ8r431msflhHeDGj32vKwF0HSbZ4B33rzjRFugwrimX 82Ow== X-Gm-Message-State: AOJu0YyA0Wux5ZV4s/fj3X3THU1YRpSFEwNqWBfGYFqq+sRsTKM4qHDO 4+n0JKwaBexfW6f7I7TBTyrzXx1/TvpjQMcXQ8s= X-Received: from tanz.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:c4a]) (user=tanzirh job=sendgmr) by 2002:a05:6902:f04:b0:dbc:decd:3c7d with SMTP id et4-20020a0569020f0400b00dbcdecd3c7dmr557649ybb.6.1703011685613; Tue, 19 Dec 2023 10:48:05 -0800 (PST) Date: Tue, 19 Dec 2023 18:47:53 +0000 In-Reply-To: <20231219-libstringheader-v5-0-206d4afd309a@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231219-libstringheader-v5-0-206d4afd309a@google.com> X-Developer-Key: i=tanzirh@google.com; a=ed25519; pk=UeRjcUcv5W9AeLGEbAe2+0LptQpcY+o1Zg0LHHo7VN4= X-Developer-Signature: v=1; a=ed25519-sha256; t=1703011682; l=6067; i=tanzirh@google.com; s=20231204; h=from:subject:message-id; bh=2//M5tR0AMdNBe14AksDgWdDSCB4lFtXwH0yxJGuKqc=; b=0wmsNcdXgytnPMUQvnsztAk4CPsOO6DiKEvruiUTRlJ1Ec/U96tpLNk6uO1ykcSCazR27+OH1 V7GtQSZN5kdB9PuFsG3n3TZ5PPGH978S7Q18bokVz9NK9uJm3d82VHu X-Mailer: b4 0.12.4 Message-ID: <20231219-libstringheader-v5-1-206d4afd309a@google.com> Subject: [PATCH v5 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" This patch creates wordpart.h and includes it in asm/word-at-a-time.h for the 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 --- arch/arm/include/asm/word-at-a-time.h | 2 +- arch/arm64/include/asm/word-at-a-time.h | 2 +- arch/powerpc/include/asm/word-at-a-time.h | 2 +- arch/riscv/include/asm/word-at-a-time.h | 2 +- arch/s390/include/asm/word-at-a-time.h | 2 +- arch/sh/include/asm/word-at-a-time.h | 1 + arch/x86/include/asm/word-at-a-time.h | 1 + fs/namei.c | 2 +- include/asm-generic/word-at-a-time.h | 2 +- include/linux/kernel.h | 7 ------- include/linux/wordpart.h | 14 ++++++++++++++ 11 files changed, 23 insertions(+), 14 deletions(-) diff --git a/arch/arm/include/asm/word-at-a-time.h b/arch/arm/include/asm/word-at-a-time.h index 352ab213520d..e08304996121 100644 --- a/arch/arm/include/asm/word-at-a-time.h +++ b/arch/arm/include/asm/word-at-a-time.h @@ -8,7 +8,7 @@ * Little-endian word-at-a-time zero byte handling. * Heavily based on the x86 algorithm. */ -#include +#include 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/asm/word-at-a-time.h index f3b151ed0d7a..bd8cfbc2b9c3 100644 --- a/arch/arm64/include/asm/word-at-a-time.h +++ b/arch/arm64/include/asm/word-at-a-time.h @@ -9,7 +9,7 @@ #ifndef __AARCH64EB__ -#include +#include 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/include/asm/word-at-a-time.h index 30a12d208687..26e4f718a674 100644 --- a/arch/powerpc/include/asm/word-at-a-time.h +++ b/arch/powerpc/include/asm/word-at-a-time.h @@ -5,7 +5,7 @@ * Word-at-a-time interfaces for PowerPC. */ -#include +#include #include #include diff --git a/arch/riscv/include/asm/word-at-a-time.h b/arch/riscv/include/asm/word-at-a-time.h index 7c086ac6ecd4..94bec2f7ba53 100644 --- a/arch/riscv/include/asm/word-at-a-time.h +++ b/arch/riscv/include/asm/word-at-a-time.h @@ -9,7 +9,7 @@ #define _ASM_RISCV_WORD_AT_A_TIME_H -#include +#include 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..55e66d9371d6 100644 --- a/arch/s390/include/asm/word-at-a-time.h +++ b/arch/s390/include/asm/word-at-a-time.h @@ -2,7 +2,7 @@ #ifndef _ASM_WORD_AT_A_TIME_H #define _ASM_WORD_AT_A_TIME_H -#include +#include #include #include diff --git a/arch/sh/include/asm/word-at-a-time.h b/arch/sh/include/asm/word-at-a-time.h index 4aa398455b94..663658cea69a 100644 --- a/arch/sh/include/asm/word-at-a-time.h +++ b/arch/sh/include/asm/word-at-a-time.h @@ -5,6 +5,7 @@ #ifdef CONFIG_CPU_BIG_ENDIAN # include #else +#include /* * Little-endian version cribbed from x86. */ diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h index 46b4f1f7f354..c002c864a63e 100644 --- a/arch/x86/include/asm/word-at-a-time.h +++ b/arch/x86/include/asm/word-at-a-time.h @@ -3,6 +3,7 @@ #define _ASM_WORD_AT_A_TIME_H #include +#include /* * This is largely generic for little-endian machines, but the diff --git a/fs/namei.c b/fs/namei.c index 71c13b2990b4..03db8ca3f394 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h index 95a1d214108a..6f088b2b0b03 100644 --- a/include/asm-generic/word-at-a-time.h +++ b/include/asm-generic/word-at-a-time.h @@ -2,7 +2,7 @@ #ifndef _ASM_WORD_AT_A_TIME_H #define _ASM_WORD_AT_A_TIME_H -#include +#include #include #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 @@ #define STACK_MAGIC 0xdeadbeef -/** - * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value - * @x: value to repeat - * - * NOTE: @x is not checked for > 0xff; larger values produce odd results. - */ -#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) /* 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 value + * @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 + -- 2.43.0.472.g3155946c3a-goog