Author: delphij Date: Fri Sep 4 00:41:29 2015 New Revision: 287446 URL: https://svnweb.freebsd.org/changeset/base/287446
Log: MFC r287345: Drop group privileges after opening the kvm descriptor, otherwise, the code would not drop privileges as expected. While there also add checks for the drop and bail out immediately if we failed. Modified: stable/10/usr.bin/bluetooth/btsockstat/btsockstat.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/bluetooth/btsockstat/btsockstat.c ============================================================================== --- stable/10/usr.bin/bluetooth/btsockstat/btsockstat.c Fri Sep 4 00:14:20 2015 (r287445) +++ stable/10/usr.bin/bluetooth/btsockstat/btsockstat.c Fri Sep 4 00:41:29 2015 (r287446) @@ -154,9 +154,9 @@ main(int argc, char *argv[]) * Discard setgid privileges if not the running kernel so that * bad guys can't print interesting stuff from kernel memory. */ - if (memf != NULL) - setgid(getgid()); + if (setgid(getgid()) != 0) + err(1, "setgid"); kvmd = kopen(memf); if (kvmd == NULL) @@ -583,15 +583,9 @@ kopen(char const *memf) kvm_t *kvmd = NULL; char errbuf[_POSIX2_LINE_MAX]; - /* - * Discard setgid privileges if not the running kernel so that - * bad guys can't print interesting stuff from kernel memory. - */ - - if (memf != NULL) - setgid(getgid()); - kvmd = kvm_openfiles(NULL, memf, NULL, O_RDONLY, errbuf); + if (setgid(getgid()) != 0) + err(1, "setgid"); if (kvmd == NULL) { warnx("kvm_openfiles: %s", errbuf); return (NULL); _______________________________________________ svn-src-stable-10@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"