From owner-svn-src-all@freebsd.org Wed Nov 30 01:22:13 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5819CC5BC02; Wed, 30 Nov 2016 01:22:13 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 275BB19D8; Wed, 30 Nov 2016 01:22:13 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAU1MCc3056869; Wed, 30 Nov 2016 01:22:12 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAU1MCxu056868; Wed, 30 Nov 2016 01:22:12 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201611300122.uAU1MCxu056868@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 30 Nov 2016 01:22:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r309304 - stable/10/sbin/dhclient X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Nov 2016 01:22:13 -0000 Author: brooks Date: Wed Nov 30 01:22:12 2016 New Revision: 309304 URL: https://svnweb.freebsd.org/changeset/base/309304 Log: MFC r309027: Allocate a struct ifreq rather than using a (wrong) computed size for the BIOCSETIF ioctl. The kernel always copies an entire struct ifreq and IPv4 addresses will always fit in an ifreq. On systems with pointers larger than 64-bits, the computed size will be less than the size of struct ifreq, potentially resulting in the kernel attempting to copyin memory from outside the allocation. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8445 Modified: stable/10/sbin/dhclient/dispatch.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dhclient/dispatch.c ============================================================================== --- stable/10/sbin/dhclient/dispatch.c Wed Nov 30 01:17:02 2016 (r309303) +++ stable/10/sbin/dhclient/dispatch.c Wed Nov 30 01:22:12 2016 (r309304) @@ -105,8 +105,8 @@ discover_interfaces(struct interface_inf if (foo.sin_addr.s_addr == htonl(INADDR_LOOPBACK)) continue; if (!iface->ifp) { - int len = IFNAMSIZ + ifa->ifa_addr->sa_len; - if ((tif = malloc(len)) == NULL) + if ((tif = calloc(1, sizeof(struct ifreq))) + == NULL) error("no space to remember ifp"); strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ); memcpy(&tif->ifr_addr, ifa->ifa_addr,