From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/wrapper-funcs/
Date: Sun, 24 Jun 2012 00:06:41 +0000 (UTC) [thread overview]
Message-ID: <1340496132.d035e5bb78cb8ac0672f4644854db8a75bc1e2d8.vapier@gentoo> (raw)
commit: d035e5bb78cb8ac0672f4644854db8a75bc1e2d8
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 23 23:30:10 2012 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Jun 24 00:02:12 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sandbox.git;a=commit;h=d035e5bb
libsandbox: do not leak file handles from tracing checks
Make sure we use O_CLOEXEC, and clean things up before forking off a
tracing process.
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
---
libsandbox/wrapper-funcs/__wrapper_exec.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c b/libsandbox/wrapper-funcs/__wrapper_exec.c
index bbdb103..c3536c3 100644
--- a/libsandbox/wrapper-funcs/__wrapper_exec.c
+++ b/libsandbox/wrapper-funcs/__wrapper_exec.c
@@ -26,8 +26,9 @@ static void sb_check_exec(const char *filename, char *const argv[])
int fd;
unsigned char *elf;
struct stat st;
+ bool do_trace = false;
- fd = open(filename, O_RDONLY);
+ fd = open(filename, O_RDONLY|O_CLOEXEC);
if (fd == -1)
return;
if (stat(filename, &st))
@@ -64,8 +65,8 @@ static void sb_check_exec(const char *filename, char *const argv[])
else
PARSE_ELF(64);
- /* We only support tracing of host personality atm */
- trace_main(filename, argv);
+ do_trace = true;
+ /* Now that we're done with stuff, clean up before forking */
done:
@@ -73,6 +74,9 @@ static void sb_check_exec(const char *filename, char *const argv[])
munmap(elf, st.st_size);
out_fd:
close(fd);
+
+ if (do_trace)
+ trace_main(filename, argv);
}
static char **_sb_check_envp(char **envp, bool is_environ)
next reply other threads:[~2012-06-24 0:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-24 0:06 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-12-24 8:02 [gentoo-commits] proj/sandbox:master commit in: libsandbox/wrapper-funcs/ Mike Frysinger
2013-02-25 4:03 Mike Frysinger
2016-03-30 5:16 Mike Frysinger
2016-11-16 22:19 Mike Frysinger
2019-03-09 19:21 Sergei Trofimovich
2021-10-18 5:21 Mike Frysinger
2024-12-22 3:41 Mike Gilbert
2024-12-22 3:49 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2025-02-22 19:49 Mike Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340496132.d035e5bb78cb8ac0672f4644854db8a75bc1e2d8.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox