Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Apr 2018 17:18:51 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r332294 - stable/11/sys/net
Message-ID:  <201804081718.w38HIpL5019630@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Sun Apr  8 17:18:51 2018
New Revision: 332294
URL: https://svnweb.freebsd.org/changeset/base/332294

Log:
  MFC r332087:
  
  ifconf(): Always zero the whole struct ifreq.
  
  The previous split of zeroing ifr_name and ifr_addr seperately is safe
  on current architectures, but would be unsafe if pointers were larger
  than 8 bytes. Combining the zeroing adds no real cost (a few
  instructions) and makes the security property easier to verify.
  
  Reviewed by:	kib, emaste
  Obtained from:	CheriBSD
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D14912

Modified:
  stable/11/sys/net/if.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/net/if.c
==============================================================================
--- stable/11/sys/net/if.c	Sun Apr  8 17:10:32 2018	(r332293)
+++ stable/11/sys/net/if.c	Sun Apr  8 17:18:51 2018	(r332294)
@@ -3123,10 +3123,10 @@ again:
 		int addrs;
 
 		/*
-		 * Zero the ifr_name buffer to make sure we don't
-		 * disclose the contents of the stack.
+		 * Zero the ifr to make sure we don't disclose the contents
+		 * of the stack.
 		 */
-		memset(ifr.ifr_name, 0, sizeof(ifr.ifr_name));
+		memset(&ifr, 0, sizeof(ifr));
 
 		if (strlcpy(ifr.ifr_name, ifp->if_xname, sizeof(ifr.ifr_name))
 		    >= sizeof(ifr.ifr_name)) {
@@ -3169,7 +3169,6 @@ again:
 		}
 		IF_ADDR_RUNLOCK(ifp);
 		if (addrs == 0) {
-			bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
 			sbuf_bcat(sb, &ifr, sizeof(ifr));
 			max_len += sizeof(ifr);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804081718.w38HIpL5019630>