svn commit: r358031 - stable/12/contrib/elftoolchain/addr2line
Mark Johnston
markj at FreeBSD.org
Mon Feb 17 18:39:38 UTC 2020
Author: markj
Date: Mon Feb 17 18:39:38 2020
New Revision: 358031
URL: https://svnweb.freebsd.org/changeset/base/358031
Log:
MFC r350515:
Capsicumize addr2line(1).
Modified:
stable/12/contrib/elftoolchain/addr2line/addr2line.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/contrib/elftoolchain/addr2line/addr2line.c
==============================================================================
--- stable/12/contrib/elftoolchain/addr2line/addr2line.c Mon Feb 17 18:37:15 2020 (r358030)
+++ stable/12/contrib/elftoolchain/addr2line/addr2line.c Mon Feb 17 18:39:38 2020 (r358031)
@@ -25,6 +25,8 @@
*/
#include <sys/param.h>
+
+#include <capsicum_helpers.h>
#include <dwarf.h>
#include <err.h>
#include <fcntl.h>
@@ -649,6 +651,7 @@ find_section_base(const char *exe, Elf *e, const char
int
main(int argc, char **argv)
{
+ cap_rights_t rights;
Elf *e;
Dwarf_Debug dbg;
Dwarf_Error de;
@@ -705,6 +708,16 @@ main(int argc, char **argv)
if ((fd = open(exe, O_RDONLY)) < 0)
err(EXIT_FAILURE, "%s", exe);
+
+ if (caph_rights_limit(fd, cap_rights_init(&rights, CAP_FSTAT,
+ CAP_MMAP_R)) < 0)
+ errx(EXIT_FAILURE, "caph_rights_limit");
+
+ caph_cache_catpages();
+ if (caph_limit_stdio() < 0)
+ errx(EXIT_FAILURE, "failed to limit stdio rights");
+ if (caph_enter() < 0)
+ errx(EXIT_FAILURE, "failed to enter capability mode");
if (dwarf_init(fd, DW_DLC_READ, NULL, NULL, &dbg, &de))
errx(EXIT_FAILURE, "dwarf_init: %s", dwarf_errmsg(de));
More information about the svn-src-stable-12
mailing list