Skip to content

Commit c73a72f

Browse files
committed
netlink: remove the flex array from struct nlmsghdr
I've added a flex array to struct nlmsghdr in commit 738136a ("netlink: split up copies in the ack construction") to allow accessing the data easily. It leads to warnings with clang, if user space wraps this structure into another struct and the flex array is not at the end of the container. Reviewed-by: Kees Cook <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/all/20221114023927.GA685@u2004-local/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ab03778 commit c73a72f

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

include/uapi/linux/netlink.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,13 @@ struct sockaddr_nl {
4848
* @nlmsg_flags: Additional flags
4949
* @nlmsg_seq: Sequence number
5050
* @nlmsg_pid: Sending process port ID
51-
* @nlmsg_data: Message payload
5251
*/
5352
struct nlmsghdr {
5453
__u32 nlmsg_len;
5554
__u16 nlmsg_type;
5655
__u16 nlmsg_flags;
5756
__u32 nlmsg_seq;
5857
__u32 nlmsg_pid;
59-
__u8 nlmsg_data[];
6058
};
6159

6260
/* Flags values */

net/netlink/af_netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
25142514
if (!nlmsg_append(skb, nlmsg_len(nlh)))
25152515
goto err_bad_put;
25162516

2517-
memcpy(errmsg->msg.nlmsg_data, nlh->nlmsg_data,
2517+
memcpy(nlmsg_data(&errmsg->msg), nlmsg_data(nlh),
25182518
nlmsg_len(nlh));
25192519
}
25202520

0 commit comments

Comments
 (0)