Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-22 Thread Herbert Xu
On Tue, Apr 22, 2025 at 01:24:22PM +0300, Dan Carpenter wrote: > > This is exactly what Kees did with the mass conversion to > struct_size(). I occasionally run across places where Kees's mass > conversion patches did fix real integer overflow bugs. The point is that the reqsize shouldn't even ex

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-22 Thread Dan Carpenter
On Mon, Apr 21, 2025 at 08:05:43PM +0800, Herbert Xu wrote: > On Mon, Apr 21, 2025 at 01:51:06PM +0800, Su Hui wrote: > > > > @@ -433,7 +434,7 @@ static inline struct aead_request > > *aead_request_alloc(struct crypto_aead *tfm, > > { > > struct aead_request *req; > > > > - req = kmalloc(

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Su Hui
On 2025/4/21 20:05, Herbert Xu wrote: On Mon, Apr 21, 2025 at 01:51:06PM +0800, Su Hui wrote: @@ -433,7 +434,7 @@ static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, { struct aead_request *req; - req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp)

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Herbert Xu
On Mon, Apr 21, 2025 at 01:51:06PM +0800, Su Hui wrote: > > @@ -433,7 +434,7 @@ static inline struct aead_request > *aead_request_alloc(struct crypto_aead *tfm, > { > struct aead_request *req; > > - req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp); > + req = kmalloc(siz

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Su Hui
On 2025/4/21 16:46, Su Hui wrote: On 2025/4/21 16:32, Christophe JAILLET wrote: Le 21/04/2025 à 09:43, Su Hui a écrit : On 2025/4/21 15:10, Christophe JAILLET wrote: Le 21/04/2025 à 07:51, Su Hui a écrit : It's safer to use size_add() to replace open-coded aithmetic in allocator arguments, b

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Su Hui
On 2025/4/21 16:32, Christophe JAILLET wrote: Le 21/04/2025 à 09:43, Su Hui a écrit : On 2025/4/21 15:10, Christophe JAILLET wrote: Le 21/04/2025 à 07:51, Su Hui a écrit : It's safer to use size_add() to replace open-coded aithmetic in allocator arguments, because size_add() can prevent possi

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Christophe JAILLET
Le 21/04/2025 à 09:43, Su Hui a écrit : On 2025/4/21 15:10, Christophe JAILLET wrote: Le 21/04/2025 à 07:51, Su Hui a écrit : 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 -

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Su Hui
On 2025/4/21 15:10, Christophe JAILLET wrote: Le 21/04/2025 à 07:51, Su Hui a écrit : 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 | 3 ++-  

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-21 Thread Christophe JAILLET
Le 21/04/2025 à 07:51, Su Hui a écrit : 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 | 3 ++- include/crypto/akcipher.h | 4 +++- include/cry

Re: [PATCH] crypto: using size_add() for kmalloc()

2025-04-20 Thread Su Hui
On 2025/4/21 13:51, Su Hui wrote: 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 | 3 ++- include/crypto/akcipher.h | 4 +++- include/crypto/kp

[PATCH] crypto: using size_add() for kmalloc()

2025-04-20 Thread Su Hui
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 | 3 ++- include/crypto/akcipher.h | 4 +++- include/crypto/kpp.h | 3 ++- 3 files changed, 7 in