Skip to contentSkip to conversation

examples/ipsec-secgw: fix partial overflow

PATCH In review Brian Dooley 3 participants 4 messages Nov 15, 2023 – Nov 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/ipsec-secgw: fix partial overflow

Case of partial overflow detected with ASan. Added extra padding to cdev_key structure.

This structure is used for the key in hash table.
Padding is added to force the struct to use 8 bytes,
to ensure memory is notread past this structs boundary
(the hash key calculation reads 8 bytes if this struct is size 5 bytes). The padding should be zeroed.
If fields are modified in this struct, the padding must be updated to ensure multiple of 8 bytes size overall.

Fixes d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application")
---
 examples/ipsec-secgw/ipsec.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
examples/ipsec-secgw/ipsec.h +10 -0
index 5059418456..10e7fc179b 100644
@@ -249,11 +249,21 @@ struct offloads {
 
 extern struct offloads tx_offloads;
 
+/*
+ * This structure is used for the key in hash table.
+ * Padding is added to force the struct to use 8 bytes,
+ * to ensure memory is notread past this structs boundary
+ * (the hash key calculation reads 8 bytes if this struct is size 5 bytes).
+ * The padding should be zeroed.
+ * If fields are modified in this struct, the padding must be updated to
+ * ensure multiple of 8 bytes size overall.
+ */
 struct cdev_key {
 	uint16_t lcore_id;
 	uint8_t cipher_algo;
 	uint8_t auth_algo;
 	uint8_t aead_algo;
+	uint8_t padding[3];
 };
 
 struct socket_ctx {
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines

-----Original Message-----
From: Brian Dooley <[email protected]>
Sent: Wednesday, November 15, 2023 12:31 PM
To: [email protected]
Cc: Dooley, Brian <[email protected]>; [email protected]; [email protected]; Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>
Subject: [PATCH] examples/ipsec-secgw: fix partial overflow

Case of partial overflow detected with ASan. Added extra padding to cdev_key structure.

This structure is used for the key in hash table.
Padding is added to force the struct to use 8 bytes, to ensure memory is notread past this structs boundary (the hash key calculation reads 8 bytes if this struct is size 5 bytes).
The padding should be zeroed.
If fields are modified in this struct, the padding must be updated to ensure multiple of 8 bytes size overall.

Quoted 5 lines
Fixes d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application")
#2 lore raw
Quoted 11 lines
Quoted 11 lines

Case of partial overflow detected with ASan. Added extra padding to cdev_key structure.

This structure is used for the key in hash table.
Padding is added to force the struct to use 8 bytes, to ensure memory is notread past this structs boundary (the hash key calculation reads 8 bytes if this struct is size 5 bytes).
The padding should be zeroed.
If fields are modified in this struct, the padding must be updated to ensure multiple of 8 bytes size overall.

Quoted 7 lines
Quoted 5 lines
Fixes d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application")

Applied and made the comment simpler with this:

uint8_t padding[3]; /* padding to 8-byte size should be zeroed */

#3 lore raw

Thanks Thomas, makes sense.

Quoted 34 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, November 22, 2023 4:38 PM
To: Dooley, Brian <[email protected]>
Cc: [email protected]; [email protected]; Nicolau, Radu <[email protected]>; Akhil Goyal <[email protected]>; Power, Ciara <[email protected]>
Subject: Re: [PATCH] examples/ipsec-secgw: fix partial overflow

Quoted 11 lines
Quoted 11 lines

Case of partial overflow detected with ASan. Added extra padding to cdev_key structure.

This structure is used for the key in hash table. Padding is added to force the struct to use 8 bytes, to ensure memory is notread past this structs boundary (the hash key calculation reads 8 bytes if this struct is size 5 bytes). The padding should be zeroed.
If fields are modified in this struct, the padding must be updated to ensure multiple of 8 bytes size overall.

Quoted 8 lines
Quoted 6 lines
Fixes d299106e8e31 ("examples/ipsec-secgw: add IPsec sample

application")
Cc: [email protected]
Cc: [email protected]

Applied and made the comment simpler with this:

uint8_t padding[3]; /* padding to 8-byte size should be zeroed */