From owner-svn-src-head@freebsd.org Tue Oct 24 10:48:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22AF3E48D05; Tue, 24 Oct 2017 10:48:28 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E11767E6E9; Tue, 24 Oct 2017 10:48:27 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9OAmRig098245; Tue, 24 Oct 2017 10:48:27 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9OAmR0d098244; Tue, 24 Oct 2017 10:48:27 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201710241048.v9OAmR0d098244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 24 Oct 2017 10:48:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324949 - head/libexec/rtld-elf X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/libexec/rtld-elf X-SVN-Commit-Revision: 324949 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 10:48:28 -0000 Author: trasz Date: Tue Oct 24 10:48:26 2017 New Revision: 324949 URL: https://svnweb.freebsd.org/changeset/base/324949 Log: Use xmalloc and read(2) instead of mmap(2) to read in libmap.conf(5). This removes the need to call munmap(2) afterwards. MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12767 Modified: head/libexec/rtld-elf/libmap.c Modified: head/libexec/rtld-elf/libmap.c ============================================================================== --- head/libexec/rtld-elf/libmap.c Tue Oct 24 08:56:11 2017 (r324948) +++ head/libexec/rtld-elf/libmap.c Tue Oct 24 10:48:26 2017 (r324949) @@ -100,6 +100,7 @@ lmc_parse_file(char *path) { struct lmc *p; struct stat st; + ssize_t retval; int fd; char *lm_map; @@ -128,10 +129,11 @@ lmc_parse_file(char *path) } } - lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (lm_map == (const char *)MAP_FAILED) { + lm_map = xmalloc(st.st_size); + retval = read(fd, lm_map, st.st_size); + if (retval != st.st_size) { close(fd); - dbg("lm_parse_file: mmap(\"%s\") failed, %s", path, + dbg("lm_parse_file: read(\"%s\") failed, %s", path, rtld_strerror(errno)); return; } @@ -142,7 +144,7 @@ lmc_parse_file(char *path) p->ino = st.st_ino; TAILQ_INSERT_HEAD(&lmc_head, p, next); lmc_parse(lm_map, st.st_size); - munmap(lm_map, st.st_size); + free(lm_map); } static void