diff mbox series

[6/7] netlink: Add sealed flag to l_netlink_message

Message ID 20240726161232.146982-6-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/7] netlink: Remove pointless checks | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success

Commit Message

Denis Kenzior July 26, 2024, 4:12 p.m. UTC
If the sealed flag is set, the message can no longer be modified.  This
is useful when netlink message ownership is taken over by l_netlink_send
to prevent the message from being modified once it has been queued.
---
 ell/netlink-private.h | 1 +
 ell/netlink.c         | 3 +++
 2 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/ell/netlink-private.h b/ell/netlink-private.h
index b114f62f6bf3..f7119f6218e9 100644
--- a/ell/netlink-private.h
+++ b/ell/netlink-private.h
@@ -40,6 +40,7 @@  struct l_netlink_message {
 	};
 	uint32_t nest_offset[4];
 	uint8_t nest_level;
+	bool sealed : 1;
 };
 
 bool netlink_parse_ext_ack_error(const struct nlmsghdr *nlmsg,
diff --git a/ell/netlink.c b/ell/netlink.c
index 58dfd9779875..b6d5fb1fd36d 100644
--- a/ell/netlink.c
+++ b/ell/netlink.c
@@ -685,6 +685,9 @@  static int message_grow(struct l_netlink_message *message, uint32_t needed)
 {
 	uint32_t grow_to;
 
+	if (message->sealed)
+		return -EPERM;
+
 	if (message->size - message->hdr->nlmsg_len >= needed)
 		return 0;