summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2016-08-02 13:57:20 +0000
committerglebius <glebius@FreeBSD.org>2016-08-02 13:57:20 +0000
commite59dbf9d991a8bccc8d2fd6f12677745e9e7873e (patch)
tree2b7343a3b844eb21bfeb10ad6f8c3fcc9396d3c2 /sys/net
parent07c6b204dbd0fadea2627964d53153e605e07a51 (diff)
downloadFreeBSD-src-e59dbf9d991a8bccc8d2fd6f12677745e9e7873e.zip
FreeBSD-src-e59dbf9d991a8bccc8d2fd6f12677745e9e7873e.tar.gz
Merge r303263:
Partially revert r257696/r257713, which have an issue with writing to user controlled address. Restore the old code that emulated OSIOCGIFCONF in if.c. Approved by: re (kib)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 0fd66c9..f0b11b3 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2699,6 +2699,9 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
return (error);
}
+/* COMPAT_SVR4 */
+#define OSIOCGIFCONF _IOWR('i', 20, struct ifconf)
+
#ifdef COMPAT_FREEBSD32
struct ifconf32 {
int32_t ifc_len;
@@ -2738,6 +2741,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
switch (cmd) {
case SIOCGIFCONF:
+ case OSIOCGIFCONF: /* COMPAT_SVR4 */
error = ifconf(cmd, data);
CURVNET_RESTORE();
return (error);
@@ -3009,6 +3013,15 @@ again:
if (prison_if(curthread->td_ucred, sa) != 0)
continue;
addrs++;
+ /* COMPAT_SVR4 */
+ if (cmd == OSIOCGIFCONF) {
+ struct osockaddr *osa =
+ (struct osockaddr *)&ifr.ifr_addr;
+ ifr.ifr_addr = *sa;
+ osa->sa_family = sa->sa_family;
+ sbuf_bcat(sb, &ifr, sizeof(ifr));
+ max_len += sizeof(ifr);
+ } else
if (sa->sa_len <= sizeof(*sa)) {
ifr.ifr_addr = *sa;
sbuf_bcat(sb, &ifr, sizeof(ifr));
OpenPOWER on IntegriCloud