svn commit: r365278 - head/lib/libc/gen

John Baldwin jhb at FreeBSD.org
Wed Sep 2 20:43:09 UTC 2020


Author: jhb
Date: Wed Sep  2 20:43:08 2020
New Revision: 365278
URL: https://svnweb.freebsd.org/changeset/base/365278

Log:
  Don't assume objects in program sections have a size of a pointer.
  
  The size of the object at 'addr' is unknown and might be smaller than
  the size of a pointer (e.g. some x86 instructions are smaller than a
  pointer).  Instead, just check that the address is in the bounds of
  the program header.
  
  Reported by:	CHERI (indirectly)
  Reviewed by:	kib, brooks
  Obtained from:	CheriBSD
  MFC after:	1 week
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D26279

Modified:
  head/lib/libc/gen/elf_utils.c

Modified: head/lib/libc/gen/elf_utils.c
==============================================================================
--- head/lib/libc/gen/elf_utils.c	Wed Sep  2 20:36:33 2020	(r365277)
+++ head/lib/libc/gen/elf_utils.c	Wed Sep  2 20:43:08 2020	(r365278)
@@ -65,7 +65,7 @@ __elf_phdr_match_addr(struct dl_phdr_info *phdr_info, 
 #endif
 
 		if (phdr_info->dlpi_addr + ph->p_vaddr <= (uintptr_t)addr &&
-		    (uintptr_t)addr + sizeof(addr) < phdr_info->dlpi_addr +
+		    (uintptr_t)addr < phdr_info->dlpi_addr +
 		    ph->p_vaddr + ph->p_memsz)
 			break;
 	}


More information about the svn-src-all mailing list