git: 453c7d6803aa - main - netlink: do not crash when linux message translation fails.

From: Alexander V. Chernikov <melifaro_at_FreeBSD.org>
Date: Sat, 18 Feb 2023 17:55:05 UTC
The branch main has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=453c7d6803aa9cbbaec74c7706276736de22f7b4

commit 453c7d6803aa9cbbaec74c7706276736de22f7b4
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2023-02-18 17:41:48 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-02-18 17:53:06 +0000

    netlink: do not crash when linux message translation fails.
    
    CID:            1498889
    MFC after:      2 weeks
---
 sys/netlink/netlink_io.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/netlink/netlink_io.c b/sys/netlink/netlink_io.c
index fb8006f689e4..509065d04818 100644
--- a/sys/netlink/netlink_io.c
+++ b/sys/netlink/netlink_io.c
@@ -430,9 +430,11 @@ nl_receive_message(struct nlmsghdr *hdr, int remaining_length,
 			struct nlmsghdr *hdr_orig = hdr;
 			hdr = linux_netlink_p->msg_from_linux(nlp->nl_proto, hdr, npt);
 			if (hdr == NULL) {
-				npt->hdr = hdr_orig;
+				 /* Failed to translate to kernel format. Report an error back */
+				hdr = hdr_orig;
+				npt->hdr = hdr;
 				if (hdr->nlmsg_flags & NLM_F_ACK)
-					nlmsg_ack(nlp, EAGAIN, hdr, npt);
+					nlmsg_ack(nlp, EOPNOTSUPP, hdr, npt);
 				return (0);
 			}
 		}