Skip to contentSkip to conversation

Fix "NLA_F_NESTED is missing" error

PATCH In review Ossama Othman 2 participants 4 messages Nov 30, 2020

lore
Share & tools
lore
#0 lore raw

cover Fix "NLA_F_NESTED is missing" error

This set of patches addresses a "NLA_F_NESTED is missing" error under strict nested netlink attribute validation by the kernel. Users can work around the error by explicitly setting the NLA_F_NESTED bit in the type passed to l_genl_msg_enter_nested(), but having ELL transparently set the bit seems more appropriate.

Ossama Othman (2):
genl: Add missing NLA_F_NESTED bit
unit: Update expected nested netlink attr data

 ell/genl.c           | 2 +-
 unit/test-genl-msg.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

Hi Ossama,

Quoted 6 lines · Ossama Othman

This set of patches addresses a "NLA_F_NESTED is missing" error under strict nested netlink attribute validation by the kernel. Users can work around the error by explicitly setting the NLA_F_NESTED bit in the type passed to l_genl_msg_enter_nested(), but having ELL transparently set the bit seems more appropriate.

Quoted 8 lines

Ossama Othman (2):
genl: Add missing NLA_F_NESTED bit
unit: Update expected nested netlink attr data

  ell/genl.c           | 2 +-
  unit/test-genl-msg.c | 6 +++---
  2 files changed, 4 insertions(+), 4 deletions(-)

Both applied, thanks.

Regards,
-Denis

#2 lore raw

PATCH 1/2 genl: Add missing NLA_F_NESTED bit

In reply to Ossama Othman

Set the NLA_F_NESTED bit when entering a nested netlink attribute to correct a "NLA_F_NESTED is missing" error exhibited by the kernel under strict netlink attribute validation.

---
 ell/genl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ell/genl.c +1 -1
index c17d337..a4f7252 100644
@@ -1714,7 +1714,7 @@ LIB_EXPORT bool l_genl_msg_enter_nested(struct l_genl_msg *msg, uint16_t type)
 	if (!msg_grow(msg, NLA_HDRLEN))
 		return false;
 
-	msg->nests[msg->nesting_level].type = type;
+	msg->nests[msg->nesting_level].type = type | NLA_F_NESTED;
 	msg->nests[msg->nesting_level].offset = msg->len;
 	msg->nesting_level += 1;
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH 2/2 unit: Update expected nested netlink attr data

In reply to Ossama Othman

Update raw message data used when verifying genl message content to take into account the NLA_F_NESTED attribute type bit that is now set by l_genl_msg_enter_nested().

---
 unit/test-genl-msg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
unit/test-genl-msg.c +3 -3
index 119d01e..1653da1 100644
@@ -128,7 +128,7 @@ static void build_set_station(const void *data)
 static const unsigned char set_rekey_offload_request[] = {
 	0x54, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x59, 0xa3, 0xe1, 0x53,
 	0xba, 0x02, 0x40, 0xe7, 0x4f, 0x00, 0x00, 0x00, 0x08, 0x00, 0x03, 0x00,
-	0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x7a, 0x00, 0x14, 0x00, 0x01, 0x00,
+	0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x7a, 0x80, 0x14, 0x00, 0x01, 0x00,
 	0x2f, 0x82, 0xbb, 0x0d, 0x93, 0x56, 0x60, 0x4b, 0xb1, 0x55, 0x1c, 0x85,
 	0xc0, 0xeb, 0x32, 0x8b, 0x14, 0x00, 0x02, 0x00, 0x43, 0x25, 0xcf, 0x08,
 	0x0b, 0x92, 0xa7, 0x2d, 0x86, 0xdc, 0x43, 0x21, 0xd6, 0x0c, 0x12, 0x03,
@@ -264,10 +264,10 @@ static void build_set_rekey_offload(const void *data)
 static const unsigned char libnl_nested[] = {
 	0x4c, 0x00, 0x00, 0x00, 0x15, 0x00, 0x05, 0x00, 0x72, 0x05, 0x13, 0x55,
 	0x77, 0x68, 0x40, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00,
-	0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x45, 0x00, 0x06, 0x00, 0x46, 0x00,
+	0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x45, 0x80, 0x06, 0x00, 0x46, 0x00,
 	0x66, 0x00, 0x00, 0x00, 0x09, 0x00, 0x47, 0x00, 0x66, 0x6f, 0x6f, 0x62,
 	0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x48, 0x00, 0x66, 0x6f, 0x6f, 0x62,
-	0x61, 0x72, 0x00, 0x00, 0x0c, 0x00, 0x49, 0x00, 0x07, 0x00, 0x50, 0x00,
+	0x61, 0x72, 0x00, 0x00, 0x0c, 0x00, 0x49, 0x80, 0x07, 0x00, 0x50, 0x00,
 	0x62, 0x61, 0x00, 0x00,
 };
 
Signature · 1 line
2.25.1