git: efd56d95cde2 - stable/13 - netlink: do not crash when linux message translation fails.

From: Alexander V. Chernikov <melifaro_at_FreeBSD.org>
Date: Sat, 08 Apr 2023 19:45:02 UTC
The branch stable/13 has been updated by melifaro:

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

commit efd56d95cde2f4f3a2df2d71e1c4eb76bbbec76b
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2023-02-18 17:41:48 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-04-08 19:14:31 +0000

    netlink: do not crash when linux message translation fails.
    
    CID:            1498889
    MFC after:      2 weeks
    
    (cherry picked from commit 453c7d6803aa9cbbaec74c7706276736de22f7b4)
---
 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);
 			}
 		}