netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v1] rtnetlink: Return error when message too short
@ 2023-03-20 23:18 Donald Hunter
  2023-03-21  3:18 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Donald Hunter @ 2023-03-20 23:18 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, David S. Miller, Eric Dumazet,
	Paolo Abeni
  Cc: donald.hunter, Donald Hunter

rtnetlink_rcv_msg currently returns 0 when the message length is too
short. This leads to either no response at all, or an ack response
if NLM_F_ACK was set in the request.

Change rtnetlink_rcv_msg to return -EINVAL which tells af_netlink to
generate a proper error response.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
 net/core/rtnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 5d8eb57867a9..04b7f184f32e 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -6086,7 +6086,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	/* All the messages must have at least 1 byte length */
 	if (nlmsg_len(nlh) < sizeof(struct rtgenmsg))
-		return 0;
+		return -EINVAL;
 
 	family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
 	kind = rtnl_msgtype_kind(type);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-21 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-20 23:18 [PATCH net-next v1] rtnetlink: Return error when message too short Donald Hunter
2023-03-21  3:18 ` Jakub Kicinski
2023-03-21 10:04   ` Donald Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).