svn commit: r366526 - head/sys/kern

Mitchell Horne mhorne at FreeBSD.org
Wed Oct 7 23:14:49 UTC 2020


Author: mhorne
Date: Wed Oct  7 23:14:49 2020
New Revision: 366526
URL: https://svnweb.freebsd.org/changeset/base/366526

Log:
  Handle kmod local relocation failures gracefully
  
  It is possible for elf_reloc_local() to fail in the unlikely case of
  an unsupported relocation type. If this occurs, do not continue to
  process the file.
  
  Reviewed by:	kib, markj (earlier version)
  MFC after:	1 week
  Sponsored by:	NetApp, Inc.
  Sponsored by:	Klara, Inc.
  Differential Revision:	https://reviews.freebsd.org/D26701

Modified:
  head/sys/kern/link_elf_obj.c

Modified: head/sys/kern/link_elf_obj.c
==============================================================================
--- head/sys/kern/link_elf_obj.c	Wed Oct  7 22:52:24 2020	(r366525)
+++ head/sys/kern/link_elf_obj.c	Wed Oct  7 23:14:49 2020	(r366526)
@@ -1676,9 +1676,11 @@ link_elf_reloc_local(linker_file_t lf, bool ifuncs)
 			if (ELF_ST_BIND(sym->st_info) != STB_LOCAL)
 				continue;
 			if ((ELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC ||
-			    elf_is_ifunc_reloc(rel->r_info)) == ifuncs)
-				elf_reloc_local(lf, base, rel, ELF_RELOC_REL,
-				    elf_obj_lookup);
+			    elf_is_ifunc_reloc(rel->r_info)) != ifuncs)
+				continue;
+			if (elf_reloc_local(lf, base, rel, ELF_RELOC_REL,
+			    elf_obj_lookup) != 0)
+				return (ENOEXEC);
 		}
 	}
 
@@ -1704,9 +1706,11 @@ link_elf_reloc_local(linker_file_t lf, bool ifuncs)
 			if (ELF_ST_BIND(sym->st_info) != STB_LOCAL)
 				continue;
 			if ((ELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC ||
-			    elf_is_ifunc_reloc(rela->r_info)) == ifuncs)
-				elf_reloc_local(lf, base, rela, ELF_RELOC_RELA,
-				    elf_obj_lookup);
+			    elf_is_ifunc_reloc(rela->r_info)) != ifuncs)
+				continue;
+			if (elf_reloc_local(lf, base, rela, ELF_RELOC_RELA,
+			    elf_obj_lookup) != 0)
+				return (ENOEXEC);
 		}
 	}
 	return (0);


More information about the svn-src-head mailing list