From nobody Sun Feb 8 23:06:58 2026 Received: from mail.nfschina.com (unknown [42.101.60.213]) by smtp.subspace.kernel.org (Postfix) with SMTP id 79D8B13C3F6; Mon, 21 Apr 2025 08:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=42.101.60.213 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745224306; cv=none; b=VC8bFzxHOX5vvFhN6Z9VyF0/IKGuZ3G/+kmzDqTF8ymERGUUm83x6EK0EbR22euxrqIH10skgxVEAhnl4kvSr9WRNtX0mzDQikbFmwiQ34/kRIOPywOn5T/TGRPbRV/wMHnGCVj0yhyrIROAbCEX1zQ1+smkLUKZGYfuAf732G8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745224306; c=relaxed/simple; bh=SuprFvyqOOqRDNuoKe72pzRM0BLb5KK2WvwZPlimvrY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version; b=AMAsc8njDyU3dkYdC5ek67SlvLGw9zMGxLtGs2KarRPVCSSAW4PA1Xs2ntnrOKDNK4vq7Hmqb0q+slok+e+54IRT+Glp/CFzfoR9G2QeD303vvcVHA4es39E8D1SzaL4ZWMrTr1pF9gVgxfb0yDve3Eji+wWIyeQFZCBCyaxeoQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com; spf=pass smtp.mailfrom=nfschina.com; arc=none smtp.client-ip=42.101.60.213 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from longsh.shanghai.nfschina.local (unknown [180.167.10.98]) by mail.nfschina.com (MailData Gateway V2.8.8) with ESMTPSA id 371EA60260752; Mon, 21 Apr 2025 16:31:38 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: herbert@gondor.apana.org.au, davem@davemloft.net, christophe.jaillet@wanadoo.fr Cc: Su Hui , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 1/2] crypto: using size_add() for kmalloc() Date: Mon, 21 Apr 2025 16:31:16 +0800 Message-Id: <20250421083116.1161805-2-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250421083116.1161805-1-suhui@nfschina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It's safer to use size_add() to replace open-coded aithmetic in allocator arguments, because size_add() can prevent possible overflow problem. Signed-off-by: Su Hui --- include/crypto/aead.h | 2 +- include/crypto/akcipher.h | 3 ++- include/crypto/kpp.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/crypto/aead.h b/include/crypto/aead.h index 0e8a41638678..8df3d112bf6a 100644 --- a/include/crypto/aead.h +++ b/include/crypto/aead.h @@ -433,7 +433,7 @@ static inline struct aead_request *aead_request_alloc(s= truct crypto_aead *tfm, { struct aead_request *req; =20 - req =3D kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp); + req =3D kmalloc(size_add(sizeof(*req), crypto_aead_reqsize(tfm)), gfp); =20 if (likely(req)) aead_request_set_tfm(req, tfm); diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h index cdf7da74bf2f..6927664bc3d7 100644 --- a/include/crypto/akcipher.h +++ b/include/crypto/akcipher.h @@ -184,7 +184,8 @@ static inline struct akcipher_request *akcipher_request= _alloc( { struct akcipher_request *req; =20 - req =3D kmalloc(sizeof(*req) + crypto_akcipher_reqsize(tfm), gfp); + req =3D kmalloc(size_add(sizeof(*req), + crypto_akcipher_reqsize(tfm)), gfp); if (likely(req)) akcipher_request_set_tfm(req, tfm); =20 diff --git a/include/crypto/kpp.h b/include/crypto/kpp.h index 2d9c4de57b69..ad120bbc8b7c 100644 --- a/include/crypto/kpp.h +++ b/include/crypto/kpp.h @@ -182,7 +182,7 @@ static inline struct kpp_request *kpp_request_alloc(str= uct crypto_kpp *tfm, { struct kpp_request *req; =20 - req =3D kmalloc(sizeof(*req) + crypto_kpp_reqsize(tfm), gfp); + req =3D kmalloc(size_add(sizeof(*req), crypto_kpp_reqsize(tfm)), gfp); if (likely(req)) kpp_request_set_tfm(req, tfm); =20 --=20 2.30.2 From nobody Sun Feb 8 23:06:58 2026 Received: from mail.nfschina.com (unknown [42.101.60.213]) by smtp.subspace.kernel.org (Postfix) with SMTP id 4DC701C860A; Mon, 21 Apr 2025 08:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=42.101.60.213 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745224306; cv=none; b=tZgQdomel+cmO4oMhm8fZ/YsKNqEbNk+3eIk4SXodgGXuc3Js2rKLkbJIKBIUkeJRoqLMUXsvSuSUq2q5NQAntm9MZpIb+3Lib6brzFFlSwXTDe48T4tdtlu0HeGKA/Tn+Wf/pb5xUaVMGYhDvoJ+JzOYgolmIh15VcVloT2py0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745224306; c=relaxed/simple; bh=USPnlJzzzQKBRxXZbuZz2e+0nUzQcDbQjf6E9cWfZcY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:MIME-Version; b=L2XOC8uqGEgSz7ybAPaL3U7HVPr9aI7UfPrg2s73rsMH47EDWTm2VLBYmUrR7xHI/FjWiT5LWKVCWNKw2qGYKILZqnXeHldnXoOQJCbbuXd5p1TZMfP++BT7YV88j1PDYGniLZQC26bH0vhd0WBJkZ4tUOxKT9Aq3pHv1giRv28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com; spf=pass smtp.mailfrom=nfschina.com; arc=none smtp.client-ip=42.101.60.213 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from longsh.shanghai.nfschina.local (unknown [180.167.10.98]) by mail.nfschina.com (MailData Gateway V2.8.8) with ESMTPSA id CC9C260260748; Mon, 21 Apr 2025 16:31:38 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: herbert@gondor.apana.org.au, davem@davemloft.net, steffen.klassert@secunet.com, christophe.jaillet@wanadoo.fr Cc: Su Hui , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2 2/2] crypto: remove some redundant include headers Date: Mon, 21 Apr 2025 16:31:17 +0800 Message-Id: <20250421083116.1161805-3-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250421083116.1161805-1-suhui@nfschina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are some redundant headers, the include relation is: linux/{list,refcount,slab,types}.h <<=3D=3D linux/crypto.h linux/container_of.h <<=3D=3D linux/list.h linux/atomic.h <<=3D=3D linux/refcount.h linux/cached.h <<=3D=3D linux/slab.h So it's no need to include when already included . Remove these redundant headers to save some code space. Also remove when already included . Signed-off-by: Su Hui --- include/crypto/acompress.h | 4 ---- include/crypto/aead.h | 4 ---- include/crypto/aes.h | 1 - include/crypto/akcipher.h | 1 - include/crypto/algapi.h | 3 --- include/crypto/blowfish.h | 1 - include/crypto/cast5.h | 1 - include/crypto/cast6.h | 1 - include/crypto/drbg.h | 2 -- include/crypto/hash.h | 2 -- include/crypto/internal/des.h | 1 - include/crypto/kpp.h | 3 --- include/crypto/krb5.h | 1 - include/crypto/pcrypt.h | 1 - include/crypto/poly1305.h | 1 - include/crypto/polyval.h | 1 - include/crypto/rng.h | 2 -- include/crypto/serpent.h | 1 - include/crypto/skcipher.h | 4 ---- include/crypto/sm4.h | 1 - 20 files changed, 36 deletions(-) diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index c497c73baf13..ac94fa297b90 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -9,16 +9,12 @@ #ifndef _CRYPTO_ACOMP_H #define _CRYPTO_ACOMP_H =20 -#include #include #include -#include #include #include #include -#include #include -#include =20 /* Set this bit if source is virtual address instead of SG list. */ #define CRYPTO_ACOMP_REQ_SRC_VIRT 0x00000002 diff --git a/include/crypto/aead.h b/include/crypto/aead.h index 8df3d112bf6a..77bfebccd735 100644 --- a/include/crypto/aead.h +++ b/include/crypto/aead.h @@ -8,11 +8,7 @@ #ifndef _CRYPTO_AEAD_H #define _CRYPTO_AEAD_H =20 -#include -#include #include -#include -#include =20 /** * DOC: Authenticated Encryption With Associated Data (AEAD) Cipher API diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 9339da7c20a8..1d749887851f 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -6,7 +6,6 @@ #ifndef _CRYPTO_AES_H #define _CRYPTO_AES_H =20 -#include #include =20 #define AES_MIN_KEY_SIZE 16 diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h index 6927664bc3d7..c665773b95af 100644 --- a/include/crypto/akcipher.h +++ b/include/crypto/akcipher.h @@ -8,7 +8,6 @@ #ifndef _CRYPTO_AKCIPHER_H #define _CRYPTO_AKCIPHER_H =20 -#include #include =20 /** diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index 6e07bbc04089..8a009d8ce9d6 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h @@ -9,10 +9,7 @@ =20 #include #include -#include #include -#include -#include #include =20 /* diff --git a/include/crypto/blowfish.h b/include/crypto/blowfish.h index 9b384670b356..075713fb8b00 100644 --- a/include/crypto/blowfish.h +++ b/include/crypto/blowfish.h @@ -6,7 +6,6 @@ #ifndef _CRYPTO_BLOWFISH_H #define _CRYPTO_BLOWFISH_H =20 -#include #include =20 #define BF_BLOCK_SIZE 8 diff --git a/include/crypto/cast5.h b/include/crypto/cast5.h index 3d4ed4ea9c3b..36f6801acc73 100644 --- a/include/crypto/cast5.h +++ b/include/crypto/cast5.h @@ -2,7 +2,6 @@ #ifndef _CRYPTO_CAST5_H #define _CRYPTO_CAST5_H =20 -#include #include #include =20 diff --git a/include/crypto/cast6.h b/include/crypto/cast6.h index 38f490cd50a8..7fd06967b5ae 100644 --- a/include/crypto/cast6.h +++ b/include/crypto/cast6.h @@ -2,7 +2,6 @@ #ifndef _CRYPTO_CAST6_H #define _CRYPTO_CAST6_H =20 -#include #include #include =20 diff --git a/include/crypto/drbg.h b/include/crypto/drbg.h index af5ad51d3eef..19dfffc04dcb 100644 --- a/include/crypto/drbg.h +++ b/include/crypto/drbg.h @@ -46,12 +46,10 @@ #include #include #include -#include #include #include #include #include -#include #include =20 /* diff --git a/include/crypto/hash.h b/include/crypto/hash.h index a67988316d06..6b44a657c58c 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -8,9 +8,7 @@ #ifndef _CRYPTO_HASH_H #define _CRYPTO_HASH_H =20 -#include #include -#include #include =20 /* Set this bit for virtual address instead of SG list. */ diff --git a/include/crypto/internal/des.h b/include/crypto/internal/des.h index 723fe5bf16da..0c8266474b7b 100644 --- a/include/crypto/internal/des.h +++ b/include/crypto/internal/des.h @@ -6,7 +6,6 @@ #ifndef __CRYPTO_INTERNAL_DES_H #define __CRYPTO_INTERNAL_DES_H =20 -#include #include #include #include diff --git a/include/crypto/kpp.h b/include/crypto/kpp.h index ad120bbc8b7c..e56abfcf3fd5 100644 --- a/include/crypto/kpp.h +++ b/include/crypto/kpp.h @@ -9,10 +9,7 @@ #ifndef _CRYPTO_KPP_ #define _CRYPTO_KPP_ =20 -#include -#include #include -#include =20 /** * struct kpp_request diff --git a/include/crypto/krb5.h b/include/crypto/krb5.h index 62d998e62f47..213d00f497f2 100644 --- a/include/crypto/krb5.h +++ b/include/crypto/krb5.h @@ -8,7 +8,6 @@ #ifndef _CRYPTO_KRB5_H #define _CRYPTO_KRB5_H =20 -#include #include #include =20 diff --git a/include/crypto/pcrypt.h b/include/crypto/pcrypt.h index 234d7cf3cf5e..e6d2187540a9 100644 --- a/include/crypto/pcrypt.h +++ b/include/crypto/pcrypt.h @@ -9,7 +9,6 @@ #ifndef _CRYPTO_PCRYPT_H #define _CRYPTO_PCRYPT_H =20 -#include #include #include =20 diff --git a/include/crypto/poly1305.h b/include/crypto/poly1305.h index 090692ec3bc7..4c6cfe69fad7 100644 --- a/include/crypto/poly1305.h +++ b/include/crypto/poly1305.h @@ -6,7 +6,6 @@ #ifndef _CRYPTO_POLY1305_H #define _CRYPTO_POLY1305_H =20 -#include #include =20 #define POLY1305_BLOCK_SIZE 16 diff --git a/include/crypto/polyval.h b/include/crypto/polyval.h index 1d630f371f77..defeab481ca2 100644 --- a/include/crypto/polyval.h +++ b/include/crypto/polyval.h @@ -8,7 +8,6 @@ #ifndef _CRYPTO_POLYVAL_H #define _CRYPTO_POLYVAL_H =20 -#include #include =20 #define POLYVAL_BLOCK_SIZE 16 diff --git a/include/crypto/rng.h b/include/crypto/rng.h index 5ac4388f50e1..5883427eb959 100644 --- a/include/crypto/rng.h +++ b/include/crypto/rng.h @@ -9,8 +9,6 @@ #ifndef _CRYPTO_RNG_H #define _CRYPTO_RNG_H =20 -#include -#include #include =20 struct crypto_rng; diff --git a/include/crypto/serpent.h b/include/crypto/serpent.h index 75c7eaa20853..a6efaa9b38f8 100644 --- a/include/crypto/serpent.h +++ b/include/crypto/serpent.h @@ -6,7 +6,6 @@ #ifndef _CRYPTO_SERPENT_H #define _CRYPTO_SERPENT_H =20 -#include #include =20 #define SERPENT_MIN_KEY_SIZE 0 diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h index 9e5853464345..5a4fc2759e7f 100644 --- a/include/crypto/skcipher.h +++ b/include/crypto/skcipher.h @@ -8,12 +8,8 @@ #ifndef _CRYPTO_SKCIPHER_H #define _CRYPTO_SKCIPHER_H =20 -#include -#include #include -#include #include -#include =20 /* Set this bit if the lskcipher operation is a continuation. */ #define CRYPTO_LSKCIPHER_FLAG_CONT 0x00000001 diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h index 9656a9a40326..5db1f2637f94 100644 --- a/include/crypto/sm4.h +++ b/include/crypto/sm4.h @@ -9,7 +9,6 @@ #ifndef _CRYPTO_SM4_H #define _CRYPTO_SM4_H =20 -#include #include =20 #define SM4_KEY_SIZE 16 --=20 2.30.2