sock: add sock_kzalloc helper
Subsystems (4)
PATCH 1/6 sock: add sock_kzalloc helper
Add sock_kzalloc() helper - the sock equivalent to kzalloc().
--- include/net/sock.h | 5 +++++ 1 file changed, 5 insertions(+)
include/net/sock.h +5 -0
@@ -1904,6 +1904,11 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);void sock_kzfree_s (struct sock *sk,void *mem,int size);void sk_send_sigurg (struct sock *sk); +static inline void *sock_kzalloc (struct sock *sk,int size,gfp_t priority) +{ +return sock_kmalloc (sk, size, priority | __GFP_ZERO); +} +static inline void sock_replace_proto (struct sock *sk,struct proto *proto) {if (sk->sk_socket)
PATCH 2/6 crypto: af_alg - use sock_kzalloc in af_alg_alloc_areq
Replace sock_kmalloc() followed by memset(0) with sock_kzalloc() to simplify af_alg_alloc_areq().
--- crypto/af_alg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/af_alg.c +1 -3
@@ -1179,12 +1179,10 @@ struct af_alg_async_req *af_alg_alloc_areq(struct sock *sk,if (ctx->inflight)return ERR_PTR (-EBUSY ); - areq =sock_kmalloc (sk, areqlen,GFP_KERNEL ); + areq =sock_kzalloc (sk, areqlen,GFP_KERNEL );if (unlikely (!areq))return ERR_PTR (-ENOMEM ); -memset (areq,0 , areqlen); - ctx->inflight = true; areq->areqlen = areqlen;
Re: [PATCH 2/6] crypto: af_alg - use sock_kzalloc in af_alg_alloc_areq
Quoted 5 lines · Thorsten Blum
Replace
sock_kmalloc()followed by memset(0) withsock_kzalloc()to simplifyaf_alg_alloc_areq().Signed-off-by Thorsten Blum <[email protected]>
PATCH 3/6 crypto: algif_aead - use sock_kzalloc in aead_accept_parent_nokey
In reply to Thorsten BlumReplace sock_kmalloc() followed by memset(0) with sock_kzalloc() to simplify aead_accept_parent_nokey().
--- crypto/algif_aead.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/algif_aead.c +2 -4
@@ -402,17 +402,15 @@ static int aead_accept_parent_nokey(void *private, struct sock *sk)unsigned int len =sizeof (*ctx);unsigned int ivlen =crypto_aead_ivsize (tfm); - ctx =sock_kmalloc (sk, len,GFP_KERNEL ); + ctx =sock_kzalloc (sk, len,GFP_KERNEL );if (!ctx)return -ENOMEM ; -memset (ctx,0 , len); - ctx->iv =sock_kmalloc (sk, ivlen,GFP_KERNEL ); + ctx->iv =sock_kzalloc (sk, ivlen,GFP_KERNEL );if (!ctx->iv) {sock_kfree_s (sk, ctx, len);return -ENOMEM ; } -memset (ctx->iv,0 , ivlen);INIT_LIST_HEAD (&ctx->tsgl_list); ctx->len = len;
Re: [PATCH 3/6] crypto: algif_aead - use sock_kzalloc in aead_accept_parent_nokey
Quoted 5 lines · Thorsten Blum
Replace
sock_kmalloc()followed by memset(0) withsock_kzalloc()to simplifyaead_accept_parent_nokey().Signed-off-by Thorsten Blum <[email protected]>
PATCH 4/6 crypto: af_alg - use sock_kzalloc in alloc_result + accept_parent_nokey
In reply to Thorsten BlumReplace sock_kmalloc() followed by memset(0) with sock_kzalloc() to simplify hash_alloc_result() and hash_accept_parent_nokey().
--- crypto/algif_hash.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
crypto/algif_hash.c +2 -5
@@ -38,12 +38,10 @@ static int hash_alloc_result(struct sock *sk, struct hash_ctx *ctx) ds =crypto_ahash_digestsize (crypto_ahash_reqtfm (&ctx->req)); - ctx->result =sock_kmalloc (sk, ds,GFP_KERNEL ); + ctx->result =sock_kzalloc (sk, ds,GFP_KERNEL );if (!ctx->result)return -ENOMEM ; -memset (ctx->result,0 , ds); -return 0 ; }
@@ -412,11 +410,10 @@ static int hash_accept_parent_nokey(void *private, struct sock *sk)struct hash_ctx *ctx;unsigned int len =sizeof (*ctx) +crypto_ahash_reqsize (tfm); - ctx =sock_kmalloc (sk, len,GFP_KERNEL ); + ctx =sock_kzalloc (sk, len,GFP_KERNEL );if (!ctx)return -ENOMEM ; -memset (ctx,0 , len); ctx->len = len;crypto_init_wait (&ctx->wait);
Re: [PATCH 4/6] crypto: af_alg - use sock_kzalloc in alloc_result + accept_parent_nokey
Quoted 5 lines · Thorsten Blum
Replace
sock_kmalloc()followed by memset(0) withsock_kzalloc()to simplifyhash_alloc_result()andhash_accept_parent_nokey().Signed-off-by Thorsten Blum <[email protected]>
PATCH 5/6 crypto: algif_rng - use sock_kzalloc in rng_accept_parent
In reply to Thorsten BlumReplace sock_kmalloc() followed by memset(0) with sock_kzalloc() to simplify rng_accept_parent().
--- crypto/algif_rng.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
crypto/algif_rng.c +1 -2
@@ -244,11 +244,10 @@ static int rng_accept_parent(void *private, struct sock *sk)struct alg_sock *ask =alg_sk (sk);unsigned int len =sizeof (*ctx); - ctx =sock_kmalloc (sk, len,GFP_KERNEL ); + ctx =sock_kzalloc (sk, len,GFP_KERNEL );if (!ctx)return -ENOMEM ; -memset (ctx,0 , len); ctx->len = len;/*
Re: [PATCH 5/6] crypto: algif_rng - use sock_kzalloc in rng_accept_parent
Quoted 5 lines · Thorsten Blum
Replace
sock_kmalloc()followed by memset(0) withsock_kzalloc()to simplifyrng_accept_parent().Signed-off-by Thorsten Blum <[email protected]>
PATCH 6/6 crypto: algif_skcipher - use sock_kzalloc in accept_parent_nokey
In reply to Thorsten BlumReplace sock_kmalloc() followed by memset(0) with sock_kzalloc() to simplify skcipher_accept_parent_nokey().
--- crypto/algif_skcipher.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
crypto/algif_skcipher.c +2 -5
@@ -383,18 +383,15 @@ static int skcipher_accept_parent_nokey(void *private, struct sock *sk)struct crypto_skcipher *tfm = private;unsigned int len =sizeof (*ctx); - ctx =sock_kmalloc (sk, len,GFP_KERNEL ); + ctx =sock_kzalloc (sk, len,GFP_KERNEL );if (!ctx)return -ENOMEM ; -memset (ctx,0 , len); - ctx->iv =sock_kmalloc (sk,crypto_skcipher_ivsize (tfm), -GFP_KERNEL ); + ctx->iv =sock_kzalloc (sk,crypto_skcipher_ivsize (tfm),GFP_KERNEL );if (!ctx->iv) {sock_kfree_s (sk, ctx, len);return -ENOMEM ; } -memset (ctx->iv,0 ,crypto_skcipher_ivsize (tfm));INIT_LIST_HEAD (&ctx->tsgl_list); ctx->len = len;
Re: [PATCH 6/6] crypto: algif_skcipher - use sock_kzalloc in accept_parent_nokey
Quoted 5 lines · Thorsten Blum
Replace
sock_kmalloc()followed by memset(0) withsock_kzalloc()to simplifyskcipher_accept_parent_nokey().Signed-off-by Thorsten Blum <[email protected]>
Quoted 4 lines · Thorsten Blum
Add
sock_kzalloc()helper - the sock equivalent tokzalloc().Signed-off-by Thorsten Blum <[email protected]>
Hi Herbert,
Quoted 13 lines · Thorsten Blum
Add
sock_kzalloc()helper - the sock equivalent tokzalloc().Signed-off-by Thorsten Blum <[email protected]>--- include/net/sock.h | 5 +++++ 1 file changed, 5 insertions(+)include/net/sock.h +0
-0@@ -1904,6 +1904,11 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);void sock_kzfree_s (struct sock *sk,void *mem,int size);
include/net/sock.h void sock_kfree_s(struct sock *sk, void *mem, int size); · line 1914
Quoted 10 lines
include/net/sock.h +5
-0void sk_send_sigurg (struct sock *sk); +static inline void *sock_kzalloc (struct sock *sk,int size,gfp_t priority) +{ +return sock_kmalloc (sk, size, priority | __GFP_ZERO); +} +static inline void sock_replace_proto (struct sock *sk,struct proto *proto) {if (sk->sk_socket)
Can you take this series or should I resend this to net-next?
Thanks,
Thorsten
Herbert Xu
maintainerQuoted 18 lines · Thorsten Blum
Hi Herbert,
Quoted 15 lines · Thorsten Blum
Add
sock_kzalloc()helper - the sock equivalent tokzalloc().Signed-off-by Thorsten Blum <[email protected]>--- include/net/sock.h | 5 +++++ 1 file changed, 5 insertions(+)include/net/sock.h +0
-0@@ -1904,6 +1904,11 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);void sock_kzfree_s (struct sock *sk,void *mem,int size);void sk_send_sigurg (struct sock *sk);
Quoted 10 lines
include/net/sock.h void sock_kfree_s(struct sock *sk, void *mem, int size); · line 1914
Quoted 8 lines
include/net/sock.h +5
-0+static inline void *sock_kzalloc (struct sock *sk,int size,gfp_t priority) +{ +return sock_kmalloc (sk, size, priority | __GFP_ZERO); +} +static inline void sock_replace_proto (struct sock *sk,struct proto *proto) {if (sk->sk_socket)Can you take this series or should I resend this to net-next?
This patch needs an ack from the netdev maintainers.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 30 lines · Herbert Xu
Quoted 18 lines · Thorsten Blum
Hi Herbert,
Quoted 15 lines · Thorsten Blum
Add
sock_kzalloc()helper - the sock equivalent tokzalloc().Signed-off-by Thorsten Blum <[email protected]>--- include/net/sock.h | 5 +++++ 1 file changed, 5 insertions(+)include/net/sock.h +0
-0@@ -1904,6 +1904,11 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);void sock_kzfree_s (struct sock *sk,void *mem,int size);void sk_send_sigurg (struct sock *sk);Quoted 10 lines
include/net/sock.h void sock_kfree_s(struct sock *sk, void *mem, int size); · line 1914
Quoted 8 lines
include/net/sock.h +5
-0+static inline void *sock_kzalloc (struct sock *sk,int size,gfp_t priority) +{ +return sock_kmalloc (sk, size, priority | __GFP_ZERO); +} +static inline void sock_replace_proto (struct sock *sk,struct proto *proto) {if (sk->sk_socket)Can you take this series or should I resend this to net-next?
Quoted 1 line
This patch needs an ack from the netdev maintainers.
Jakub, netdev folks,
Could you take a look at this small include/net/sock.h addition and provide an Acked-by: tag if you're okay with it going through Herbert's crypto tree?
The series has Reviewed-by: tags from Kuniyuki, but it hadn't been Cc'ed to netdev before.
Thanks,
Thorsten
Jakub Kicinski
maintainerQuoted 6 lines · On Tue, 26 May 2026 15:23:25 +0200 Thorsten Blum wrote:
Could you take a look at this small
include/net/sock.haddition and provide an Acked-by: tag if you're okay with it going through Herbert's crypto tree?The series has Reviewed-by: tags from Kuniyuki, but it hadn't been Cc'ed to netdev before.
IDK, feels like the usage is low enough to border on pointless churn. Other netdev maintainers may feel differently.
Simon Horman
reviewerQuoted 30 lines · Herbert Xu
Quoted 18 lines · Thorsten Blum
Hi Herbert,
Quoted 15 lines · Thorsten Blum
Add
sock_kzalloc()helper - the sock equivalent tokzalloc().Signed-off-by Thorsten Blum <[email protected]>--- include/net/sock.h | 5 +++++ 1 file changed, 5 insertions(+)include/net/sock.h +0
-0@@ -1904,6 +1904,11 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);void sock_kzfree_s (struct sock *sk,void *mem,int size);void sk_send_sigurg (struct sock *sk);Quoted 10 lines
include/net/sock.h void sock_kfree_s(struct sock *sk, void *mem, int size); · line 1914
Quoted 8 lines
include/net/sock.h +5
-0+static inline void *sock_kzalloc (struct sock *sk,int size,gfp_t priority) +{ +return sock_kmalloc (sk, size, priority | __GFP_ZERO); +} +static inline void sock_replace_proto (struct sock *sk,struct proto *proto) {if (sk->sk_socket)Can you take this series or should I resend this to net-next?
Quoted 1 line
This patch needs an ack from the netdev maintainers.
In which case it probably needs to hit the netdev mailing list.
Thanks!