From 6f8f4acfbed863541134aa362e78676a03b27f0b Mon Sep 17 00:00:00 2001 From: John Johansen Date: Tue, 16 Apr 2024 08:07:14 -0700 Subject: [PATCH] UBUNTU: SAUCE: apparmor4.0.0 [92/90]: fix address mapping for recvfrom BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2061851 Receive message cases are failing with an EINVAL error this is due to the address may not be available for the receive case, but being indicated with an addrlen of 0 not a null addr. From a mediation pov this is fine, the address just can not be used as part of an acceptance criteria. However the address lookup is being done during the setup and the consistency check is failing. Since it isn't required don't do the address verification check at all, and leave that to other parts of the kernel. Treat any bad address as unavailable. Signed-off-by: John Johansen (cherry picked from commit 3ba61903d684a84a4a028dc9a9e2b18cdc2a3e4e https://git.launchpad.net/~apparmor-dev/ubuntu-kernel-next) Signed-off-by: Paolo Pisati --- security/apparmor/af_inet.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/security/apparmor/af_inet.c b/security/apparmor/af_inet.c index fb5cd985630d..57b710054a76 100644 --- a/security/apparmor/af_inet.c +++ b/security/apparmor/af_inet.c @@ -103,14 +103,12 @@ static int map_addr(struct sockaddr *addr, int addrlen, u16 raw_port, AA_BUG(!maddr); maddr->addrtype = addrtype; - if (!addr) { + if (!addr || addrlen < offsetofend(struct sockaddr, sa_family)) { maddr->addrp = NULL; maddr->port = 0; maddr->len = 0; return 0; } - if (addrlen < offsetofend(struct sockaddr, sa_family)) - return -EINVAL; /* * its possibly to have sk->sk_family == PF_INET6 and