Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp35014rdh; Mon, 18 Dec 2023 10:45:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw3kZ9EybfJQXjCPCoicENWnNrTJFX4kJtqwfWTgDzHXCirfaFCwQrs7yJnyuJ6rLyYiPq X-Received: by 2002:a05:6808:2381:b0:3b9:f104:14c0 with SMTP id bp1-20020a056808238100b003b9f10414c0mr22136763oib.73.1702925108999; Mon, 18 Dec 2023 10:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702925108; cv=none; d=google.com; s=arc-20160816; b=jm1jA0NwHz6eIdfaaitoyp+D3Dt38i+R+dCc4g5XPi2noCrSYWYtLimpB945l4ofgn xSdaNijI5ZDXjczrxLJx1oV40BNXxhlVniRyUFgOB+PhSp4VtD5RgugUB8WxiPEAtx+U Y+DhdO+5hpKILmSYVxSmLkX70wTZHxD4tPtbbvEcsr39dopE/T06TpZfeuPVqhClTE9y 3cHSRzJMhdQlsuCbZzPwpZRGHRGcjRp1q4rDiR2Ty7V7PIwwyNnMxga5T3ToOmQSh5ol X1A3a7XhiqNTlKohJyOh+WJP1ivk76oaKO7R5tAG3K914ddnrfOcmSa0E2hA5BvCml6m QNRg== 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=otZZ0TbH3O/9uh/WTuAjWwf68II/fAS101L08F2nen4=; fh=Sn96uMIYbxvXu8NN9D0WQ1og+KuMdWtaWLEr1nKEP5E=; b=q8HXCPTTF8bhnj4jGi63osoK+7TKhb/HUYRyR/rS9Xj62YPFswAVoHXP5nXtyu0FYl Gm65BR+tqzHFdaUh5RaqlMfI5eU0P5O+ADdQVLcjO94+Gdr7sKzN+GRMpiqjLcYOhKlp Sj4fslq0jbs6jKJi3dSxwORORsp1MSM9mkISWofYE1VS2v/Ds0j74araKnbxukHFsp87 73I16RZH5HLHombbGDuNZpoY/3RFcxY4sbhAgfF8AWPXGauFWtu8i0BzsugF1Rex27yk z3PIUJ2Yd1yoY8qiTBH3ah3ZZBBNJxaA7b1CcCTR4BhyDtoUwmizes9Nzsr7p2VmdeUE F0Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Blz8jlYg; spf=pass (google.com: domain of linux-kernel+bounces-4254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v7-20020a0ce1c7000000b0067f4a160ac7si1752271qvl.203.2023.12.18.10.45.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 10:45:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Blz8jlYg; spf=pass (google.com: domain of linux-kernel+bounces-4254-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4254-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 966971C2302C for ; Mon, 18 Dec 2023 18:45:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1A237144F; Mon, 18 Dec 2023 18:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Blz8jlYg" 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 9F81B49891 for ; Mon, 18 Dec 2023 18:44: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 Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5e31a4a893bso41470127b3.1 for ; Mon, 18 Dec 2023 10:44:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702925092; x=1703529892; 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=otZZ0TbH3O/9uh/WTuAjWwf68II/fAS101L08F2nen4=; b=Blz8jlYgNTLbo9ur0a7IHTm7h4SLRi4x25y3LpNDDLTvMo6BE4Wj0cr6YZ6SqKN4WA k6zpkpYvio1CNyFeyUIAPQ0d7NPkFj7iDIvXEA4OXyw4RYqcLdBt/S3qeAYEBo3vdTvd nKlLJRN75uGvvBJI5UBxRVrhCVi1+tT4I8tg6wAaz7g6INdcbiL5aoI6DMSUjzDdAC9m /mB4La1QELzXjLoLC8IYaQfLSa14DvUFCrQ1YPrGlH20W+oBLSF9p9ZiJmXFjLy7OLAP HqHWmYwD8k3Rx5cTtVaxAPYygjQe6oRUQkei1Kf7S6lNJXO/kGuwZ7F3YWYtv4io9s4p ggPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702925092; x=1703529892; 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=otZZ0TbH3O/9uh/WTuAjWwf68II/fAS101L08F2nen4=; b=sYziF5OcrNc5d7U68HqhPgx5PjZo//mO9g22AOTTS1FOVj+zKcEzkjjj3eGJqweXp3 veSW/6nbdsLDFed7XHbKBhmoClQKDe8PjCGMB/29dF6EvuYqwqJ2Sj3bminpiEezhCVz nq3LKPHT9A90j2YVewocUkzDrp8BGephPzdzupxl/taRVUtDZkkBH1EpLOLBzsKSfbzo 7WAWw8Eb4nrO6HEA7piBaJKo9TODYmtDBpZfttyzbufAlZVLJKvhdAxSaqIT2wTnKNF9 z0fp9jXYXfrzoaM91Qhskcy5LOvti4PZ/mDe1Igc+eUm19Iw6A451UMnpTdi2+vKMGfo tu/w== X-Gm-Message-State: AOJu0Yzvwx2lwq9cfm6pBiuEjJ1hdBpdIf3qokogfYELSglqc1MZNoE6 HgRSoqfZXwSieNx6wL/uun9dCG0drQFL X-Received: from tanz.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:c4a]) (user=tanzirh job=sendgmr) by 2002:a05:690c:83:b0:5d5:6a4c:b0b3 with SMTP id be3-20020a05690c008300b005d56a4cb0b3mr2386137ywb.8.1702925092683; Mon, 18 Dec 2023 10:44:52 -0800 (PST) Date: Mon, 18 Dec 2023 18:44:47 +0000 In-Reply-To: <20231218-libstringheader-v3-0-500bd58f0f75@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231218-libstringheader-v3-0-500bd58f0f75@google.com> X-Developer-Key: i=tanzirh@google.com; a=ed25519; pk=UeRjcUcv5W9AeLGEbAe2+0LptQpcY+o1Zg0LHHo7VN4= X-Developer-Signature: v=1; a=ed25519-sha256; t=1702925089; l=5960; i=tanzirh@google.com; s=20231204; h=from:subject:message-id; bh=1zmqDeKrI4VGJQmHkQfCpOMar1eOZu561uUlu020PMg=; b=aIzg8QQKRJufy3r1aZ1mmlDEDn6a3LTdwAfet0aRj6YMycSQOJRraIUquQXmVDA5JL7zMT29f rJ/wSyFr1UNCMHEtmf5jE79LRfjmSb329FbLTMgoDySWVrtjjQPGcsW X-Mailer: b4 0.12.3 Message-ID: <20231218-libstringheader-v3-1-500bd58f0f75@google.com> Subject: [PATCH v3 1/2] kernel.h: removed REPEAT_BYTE from kernel.h From: tanzirh@google.com To: Kees Cook Cc: Andy Shevchenko , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Nick DeSaulniers , Andrew Morton , 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 dependancy 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 | 1 + arch/arm64/include/asm/word-at-a-time.h | 1 + arch/powerpc/include/asm/word-at-a-time.h | 1 + arch/riscv/include/asm/word-at-a-time.h | 1 + arch/s390/include/asm/word-at-a-time.h | 1 + arch/sh/include/asm/word-at-a-time.h | 2 ++ arch/x86/include/asm/word-at-a-time.h | 1 + fs/namei.c | 2 +- include/asm-generic/word-at-a-time.h | 1 + include/linux/kernel.h | 7 ------- include/linux/wordpart.h | 17 +++++++++++++++++ 11 files changed, 27 insertions(+), 8 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..aea6bfe259f5 100644 --- a/arch/arm/include/asm/word-at-a-time.h +++ b/arch/arm/include/asm/word-at-a-time.h @@ -9,6 +9,7 @@ * 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..cf8c28a3bba9 100644 --- a/arch/arm64/include/asm/word-at-a-time.h +++ b/arch/arm64/include/asm/word-at-a-time.h @@ -10,6 +10,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..032a77d324e6 100644 --- a/arch/powerpc/include/asm/word-at-a-time.h +++ b/arch/powerpc/include/asm/word-at-a-time.h @@ -6,6 +6,7 @@ */ #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..9b7ea4c1a616 100644 --- a/arch/riscv/include/asm/word-at-a-time.h +++ b/arch/riscv/include/asm/word-at-a-time.h @@ -10,6 +10,7 @@ #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..5af1d267b4d7 100644 --- a/arch/s390/include/asm/word-at-a-time.h +++ b/arch/s390/include/asm/word-at-a-time.h @@ -3,6 +3,7 @@ #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..3a11158f0143 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/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..fc007fda0b2e 100644 --- a/include/asm-generic/word-at-a-time.h +++ b/include/asm-generic/word-at-a-time.h @@ -3,6 +3,7 @@ #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..6a5ed5d54ba2 --- /dev/null +++ b/include/linux/wordpart.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023 Google LLC + */ + +#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