mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
Make SIOCGIFADDR and related, as well as SIOCGIFADDR_IN6 and related
jail-aware. Up to now we returned the first address of the interface for SIOCGIFADDR w/o an ifr_addr in the query. This caused problems for programs querying for an address but running inside a jail, as the address returned usually did not belong to the jail. Like for v6, if there was an ifr_addr given on v4, you could probe for more addresses on the interfaces that you were not allowed to see from inside a jail. Return an error (EADDRNOTAVAIL) in that case now unless the address is on the given interface and valid for the jail. PR: kern/114325 Reviewed by: rwatson MFC after: 4 weeks
This commit is contained in:
parent
4e883c81d0
commit
5ce0eb7f08
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186948
@ -41,7 +41,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
@ -261,13 +263,19 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
|
||||
LIST_FOREACH(iap, INADDR_HASH(dst.s_addr), ia_hash)
|
||||
if (iap->ia_ifp == ifp &&
|
||||
iap->ia_addr.sin_addr.s_addr == dst.s_addr) {
|
||||
ia = iap;
|
||||
if (td == NULL || prison_check_ip4(
|
||||
td->td_ucred, &dst))
|
||||
ia = iap;
|
||||
break;
|
||||
}
|
||||
if (ia == NULL)
|
||||
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
|
||||
iap = ifatoia(ifa);
|
||||
if (iap->ia_addr.sin_family == AF_INET) {
|
||||
if (td != NULL &&
|
||||
!prison_check_ip4(td->td_ucred,
|
||||
&iap->ia_addr.sin_addr))
|
||||
continue;
|
||||
ia = iap;
|
||||
break;
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
@ -329,6 +330,9 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
|
||||
error = in6_setscope(&sa6->sin6_addr, ifp, NULL);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (td != NULL && !prison_check_ip6(td->td_ucred,
|
||||
&sa6->sin6_addr))
|
||||
return (EADDRNOTAVAIL);
|
||||
ia = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr);
|
||||
} else
|
||||
ia = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user