Commit 9c2aece
fix: zero the genlmsghdr reserved field in Genlmsg
The kernel struct is defined as follows:
struct genlmsghdr {
__u8 cmd;
__u8 version;
__u16 reserved;
};
Genlmsg declared only Command and Version (2 bytes), but SizeofGenlmsg
is 4 and Serialize() unsafe-casts the struct to [4]byte. The extra two
bytes contained arbitrary contents read from adjacent memory and emitted
as the genlmsghdr reserved field.
The kernel's genl_header_check() conditionally rejects a non-zero
reserved field with EINVAL ("genlmsghdr.reserved field is not 0") which
surfaced when adding new netdev commands.
Add an explicit Reserved uint16 field so the struct is genuinely 4 bytes
and serializes the reserved word as zero.
Signed-off-by: Aaron Campbell <aaron@monkey.org>1 parent 1d39b13 commit 9c2aece
1 file changed
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
0 commit comments