* [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation
2025-09-02 9:00 ` PATCH v2 Re: " chuguangqing
@ 2025-09-02 9:00 ` chuguangqing
2025-09-02 13:15 ` Markus Elfring
2025-09-03 8:41 ` Antonio Quartulli
0 siblings, 2 replies; 5+ messages in thread
From: chuguangqing @ 2025-09-02 9:00 UTC (permalink / raw)
To: horms, Antonio Quartulli, Sabrina Dubroca, Andrew Lunn, davem,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, chuguangqing
Replace kmalloc(size * sizeof) with kmalloc_array() for safer memory
allocation and overflow prevention.
Signed-off-by: chuguangqing <chuguangqing@inspur.com>
---
drivers/net/ovpn/crypto_aead.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ovpn/crypto_aead.c b/drivers/net/ovpn/crypto_aead.c
index 2cca759feffa..da0ce4f348e6 100644
--- a/drivers/net/ovpn/crypto_aead.c
+++ b/drivers/net/ovpn/crypto_aead.c
@@ -72,8 +72,9 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,
return -ENOSPC;
/* sg may be required by async crypto */
- ovpn_skb_cb(skb)->sg = kmalloc(sizeof(*ovpn_skb_cb(skb)->sg) *
- (nfrags + 2), GFP_ATOMIC);
+ ovpn_skb_cb(skb)->sg = kmalloc_array(nfrags + 2,
+ sizeof(*ovpn_skb_cb(skb)->sg),
+ GFP_ATOMIC);
if (unlikely(!ovpn_skb_cb(skb)->sg))
return -ENOMEM;
@@ -185,8 +186,9 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,
return -ENOSPC;
/* sg may be required by async crypto */
- ovpn_skb_cb(skb)->sg = kmalloc(sizeof(*ovpn_skb_cb(skb)->sg) *
- (nfrags + 2), GFP_ATOMIC);
+ ovpn_skb_cb(skb)->sg = kmalloc_array(nfrags + 2,
+ sizeof(*ovpn_skb_cb(skb)->sg),
+ GFP_ATOMIC);
if (unlikely(!ovpn_skb_cb(skb)->sg))
return -ENOMEM;
--
2.43.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation
2025-09-02 9:00 ` [PATCH v2 " chuguangqing
@ 2025-09-02 13:15 ` Markus Elfring
2025-09-03 12:17 ` chuguangqing
2025-09-03 8:41 ` Antonio Quartulli
1 sibling, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-09-02 13:15 UTC (permalink / raw)
To: chuguangqing, netdev
Cc: LKML, Andrew Lunn, Antonio Quartulli, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Sabrina Dubroca,
Simon Horman
> Signed-off-by: chuguangqing <chuguangqing@inspur.com>
Would the personal name usually deviate a bit from the email identifier
according to the Developer's Certificate of Origin?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n436
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation
2025-09-02 9:00 ` [PATCH v2 " chuguangqing
2025-09-02 13:15 ` Markus Elfring
@ 2025-09-03 8:41 ` Antonio Quartulli
1 sibling, 0 replies; 5+ messages in thread
From: Antonio Quartulli @ 2025-09-03 8:41 UTC (permalink / raw)
To: chuguangqing
Cc: netdev, linux-kernel, horms, Sabrina Dubroca, Andrew Lunn, davem,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Hello and thanks a lot for contribution!
This is indeed a nice improvement, however, we've been working on
changing this part of the code.
We already have a pending commit in the queue (to be sent to net-next
soonish):
https://github.com/mandelbitdev/ovpn-net-next/commit/9b62844193de705502fdf4a693dfe0f6c7d94f13
With the mentioned patch, the line you are changing does not exist
anymore, therefore I don't think it makes sense to merge your patch
first and then removing it again in the next commit.
Sorry about this!
Please feel free to stick around and submit more patches in the future!
Regards,
--
Antonio Quartulli
OpenVPN Inc.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation
@ 2025-09-03 12:00 Gary Chu(楚光庆)
0 siblings, 0 replies; 5+ messages in thread
From: Gary Chu(楚光庆) @ 2025-09-03 12:00 UTC (permalink / raw)
To: Markus.Elfring@web.de, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, andrew+netdev@lunn.ch,
antonio@openvpn.net, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, sd@queasysnail.net,
horms@kernel.org
[-- Attachment #1: Type: text/plain, Size: 804 bytes --]
Hi Markus,
First of all, thank you for your reminder. According to your suggestion, the format "Chu Guangqing" should be used. However, in line with our company's signature conventions and my previous contributions to the kernel community, I have been using "chuguangqing". Therefore, I have to continue using this signature. The signature should not be changed frequently.
>
> > Signed-off-by: chuguangqing <chuguangqing@inspur.com>
>
> Would the personal name usually deviate a bit from the email identifier
> according to the Developer's Certificate of Origin?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docume
> ntation/process/submitting-patches.rst?h=v6.17-rc4#n436
>
> Regards,
> Markus
Best regards,
Chu Guangqing
<chuguangqing@inspur.com>
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3931 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation
2025-09-02 13:15 ` Markus Elfring
@ 2025-09-03 12:17 ` chuguangqing
0 siblings, 0 replies; 5+ messages in thread
From: chuguangqing @ 2025-09-03 12:17 UTC (permalink / raw)
To: markus.elfring
Cc: andrew+netdev, antonio, chuguangqing, davem, edumazet, horms,
kuba, linux-kernel, netdev, pabeni, sd
Hi Markus,
First of all, thank you for your reminder. According to your suggestion, the format "Chu Guangqing" should be used. However, in line with our company's signature conventions and my previous contributions to the kernel community, I have been using "chuguangqing". Therefore, I have to continue using this signature. The signature should not be changed frequently.
>
> > Signed-off-by: chuguangqing <chuguangqing@inspur.com>
>
> Would the personal name usually deviate a bit from the email identifier
> according to the Developer's Certificate of Origin?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docume
> ntation/process/submitting-patches.rst?h=v6.17-rc4#n436
>
> Regards,
> Markus
Best regards,
Chu Guangqing
<chuguangqing@inspur.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-03 12:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 12:00 [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation Gary Chu(楚光庆)
-- strict thread matches above, loose matches on Subject: below --
2025-09-01 11:21 [PATCH " chuguangqing
2025-09-02 9:00 ` PATCH v2 Re: " chuguangqing
2025-09-02 9:00 ` [PATCH v2 " chuguangqing
2025-09-02 13:15 ` Markus Elfring
2025-09-03 12:17 ` chuguangqing
2025-09-03 8:41 ` Antonio Quartulli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).