diff mbox series

[OE-core,Scarthgap] examples: genl: fix wrong attribute size

Message ID 20250923095903.2687733-1-nitin.wankhade333@gmail.com
State New
Headers show
Series [OE-core,Scarthgap] examples: genl: fix wrong attribute size | expand

Commit Message

Nitin Wankhade Sept. 23, 2025, 9:59 a.m. UTC
This example no longer works on more recent kernels:

genl-family-get
error: Invalid argument

dmesg says:
netlink: 'genl-family-get': attribute type 1 has an invalid length.

Fix this and also zero out the reserved field in the genl header,
while not validated yet for dumps this could change.

Upstream-Status: Backport [https://git.netfilter.org/libmnl/patch/?id=54dea548d796653534645c6e3c8577eaf7d77411]

Reported-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
Signed-off-by: Florian Westphal <fw@strlen.de>
(cherry picked from commit 54dea548d796653534645c6e3c8577eaf7d77411)
Signed-off-by: Divyanshu Rathore <divyanshu.rathore@bmwtechworks.in>
---
 ...amples-genl-fix-wrong-attribute-size.patch | 44 +++++++++++++++++++
 meta/recipes-extended/libmnl/libmnl_1.0.5.bb  |  5 ++-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch

Comments

Gyorgy Sarvari Sept. 23, 2025, 11:38 a.m. UTC | #1
Could you please send this to openembedded-core@lists.openembedded.org
so the correct maintainer will find it?

On 9/23/25 11:59, Nitin Wankhade via lists.openembedded.org wrote:
> This example no longer works on more recent kernels:
>
> genl-family-get
> error: Invalid argument
>
> dmesg says:
> netlink: 'genl-family-get': attribute type 1 has an invalid length.
>
> Fix this and also zero out the reserved field in the genl header,
> while not validated yet for dumps this could change.
>
> Upstream-Status: Backport [https://git.netfilter.org/libmnl/patch/?id=54dea548d796653534645c6e3c8577eaf7d77411]
>
> Reported-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> (cherry picked from commit 54dea548d796653534645c6e3c8577eaf7d77411)
> Signed-off-by: Divyanshu Rathore <divyanshu.rathore@bmwtechworks.in>
> ---
>  ...amples-genl-fix-wrong-attribute-size.patch | 44 +++++++++++++++++++
>  meta/recipes-extended/libmnl/libmnl_1.0.5.bb  |  5 ++-
>  2 files changed, 48 insertions(+), 1 deletion(-)
>  create mode 100644 meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch
>
> diff --git a/meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch b/meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch
> new file mode 100644
> index 0000000000..9e06abb9a4
> --- /dev/null
> +++ b/meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch
> @@ -0,0 +1,44 @@
> +From 67ad7abf1fe888c650f9e8ed326a499e1456285c Mon Sep 17 00:00:00 2001
> +From: Florian Westphal <fw@strlen.de>
> +Date: Mon, 15 Sep 2025 14:40:30 +0200
> +Subject: [PATCH] examples: genl: fix wrong attribute size
> +
> +This example no longer works on more recent kernels:
> +
> +genl-family-get
> +error: Invalid argument
> +
> +dmesg says:
> +netlink: 'genl-family-get': attribute type 1 has an invalid length.
> +
> +Fix this and also zero out the reserved field in the genl header,
> +while not validated yet for dumps this could change.
> +
> +Upstream-Status: Backport [https://git.netfilter.org/libmnl/patch/?id=54dea548d796653534645c6e3c8577eaf7d77411]
> +
> +Reported-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
> +Signed-off-by: Florian Westphal <fw@strlen.de>
> +(cherry picked from commit 54dea548d796653534645c6e3c8577eaf7d77411)
> +Signed-off-by: Divyanshu Rathore <divyanshu.rathore@bmwtechworks.in>
> +---
> + examples/genl/genl-family-get.c | 3 ++-
> + 1 file changed, 2 insertions(+), 1 deletion(-)
> +
> +diff --git a/examples/genl/genl-family-get.c b/examples/genl/genl-family-get.c
> +index ba8de12..0c20067 100644
> +--- a/examples/genl/genl-family-get.c
> ++++ b/examples/genl/genl-family-get.c
> +@@ -199,8 +199,9 @@ int main(int argc, char *argv[])
> + 	genl = mnl_nlmsg_put_extra_header(nlh, sizeof(struct genlmsghdr));
> + 	genl->cmd = CTRL_CMD_GETFAMILY;
> + 	genl->version = 1;
> ++	genl->reserved = 0;
> + 
> +-	mnl_attr_put_u32(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
> ++	mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
> + 	if (argc >= 2)
> + 		mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, argv[1]);
> + 	else
> +-- 
> +2.34.1
> +
> diff --git a/meta/recipes-extended/libmnl/libmnl_1.0.5.bb b/meta/recipes-extended/libmnl/libmnl_1.0.5.bb
> index 66b30d7f60..d0bf658eef 100644
> --- a/meta/recipes-extended/libmnl/libmnl_1.0.5.bb
> +++ b/meta/recipes-extended/libmnl/libmnl_1.0.5.bb
> @@ -6,7 +6,10 @@ SECTION = "libs"
>  LICENSE = "LGPL-2.1-or-later"
>  LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
>  
> -SRC_URI = "https://netfilter.org/projects/libmnl/files/libmnl-${PV}.tar.bz2"
> +SRC_URI = "https://netfilter.org/projects/libmnl/files/libmnl-${PV}.tar.bz2 \
> +           file://0001-examples-genl-fix-wrong-attribute-size.patch \
> +"
> +
>  SRC_URI[sha256sum] = "274b9b919ef3152bfb3da3a13c950dd60d6e2bcd54230ffeca298d03b40d0525"
>  
>  inherit autotools pkgconfig
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#119663): https://lists.openembedded.org/g/openembedded-devel/message/119663
> Mute This Topic: https://lists.openembedded.org/mt/115391501/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch b/meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch
new file mode 100644
index 0000000000..9e06abb9a4
--- /dev/null
+++ b/meta/recipes-extended/libmnl/files/0001-examples-genl-fix-wrong-attribute-size.patch
@@ -0,0 +1,44 @@ 
+From 67ad7abf1fe888c650f9e8ed326a499e1456285c Mon Sep 17 00:00:00 2001
+From: Florian Westphal <fw@strlen.de>
+Date: Mon, 15 Sep 2025 14:40:30 +0200
+Subject: [PATCH] examples: genl: fix wrong attribute size
+
+This example no longer works on more recent kernels:
+
+genl-family-get
+error: Invalid argument
+
+dmesg says:
+netlink: 'genl-family-get': attribute type 1 has an invalid length.
+
+Fix this and also zero out the reserved field in the genl header,
+while not validated yet for dumps this could change.
+
+Upstream-Status: Backport [https://git.netfilter.org/libmnl/patch/?id=54dea548d796653534645c6e3c8577eaf7d77411]
+
+Reported-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+(cherry picked from commit 54dea548d796653534645c6e3c8577eaf7d77411)
+Signed-off-by: Divyanshu Rathore <divyanshu.rathore@bmwtechworks.in>
+---
+ examples/genl/genl-family-get.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/examples/genl/genl-family-get.c b/examples/genl/genl-family-get.c
+index ba8de12..0c20067 100644
+--- a/examples/genl/genl-family-get.c
++++ b/examples/genl/genl-family-get.c
+@@ -199,8 +199,9 @@ int main(int argc, char *argv[])
+ 	genl = mnl_nlmsg_put_extra_header(nlh, sizeof(struct genlmsghdr));
+ 	genl->cmd = CTRL_CMD_GETFAMILY;
+ 	genl->version = 1;
++	genl->reserved = 0;
+ 
+-	mnl_attr_put_u32(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
++	mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
+ 	if (argc >= 2)
+ 		mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, argv[1]);
+ 	else
+-- 
+2.34.1
+
diff --git a/meta/recipes-extended/libmnl/libmnl_1.0.5.bb b/meta/recipes-extended/libmnl/libmnl_1.0.5.bb
index 66b30d7f60..d0bf658eef 100644
--- a/meta/recipes-extended/libmnl/libmnl_1.0.5.bb
+++ b/meta/recipes-extended/libmnl/libmnl_1.0.5.bb
@@ -6,7 +6,10 @@  SECTION = "libs"
 LICENSE = "LGPL-2.1-or-later"
 LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
 
-SRC_URI = "https://netfilter.org/projects/libmnl/files/libmnl-${PV}.tar.bz2"
+SRC_URI = "https://netfilter.org/projects/libmnl/files/libmnl-${PV}.tar.bz2 \
+           file://0001-examples-genl-fix-wrong-attribute-size.patch \
+"
+
 SRC_URI[sha256sum] = "274b9b919ef3152bfb3da3a13c950dd60d6e2bcd54230ffeca298d03b40d0525"
 
 inherit autotools pkgconfig