Skip to contentSkip to conversation

Open the lockfile with O_CLOEXEC

PATCH Applied Ondrej Mosnacek 2 participants 2 messages Feb 17, 2021 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Open the lockfile with O_CLOEXEC

Otherwise the fd will leak to subprocesses (e.g. modprobe). That's mostly benign, but it may trigger an SELinux denial when the modprobe process transitions to another domain.

Fixes 8b5594d7c21f ("add logic to support the --concurrent option: use a file lock to support concurrent scripts running ebtables")
---
 libebtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libebtc.c +1 -1
index 2a9ab87..1b058ef 100644
@@ -144,7 +144,7 @@ static int lock_file()
 	int fd, try = 0;
 
 retry:
-	fd = open(LOCKFILE, O_CREAT, 00600);
+	fd = open(LOCKFILE, O_CREAT|O_CLOEXEC, 00600);
 	if (fd < 0) {
 		if (try == 1 || mkdir(dirname(pathbuf), 00700))
 			return -2;
Signature · 1 line
2.29.2
maintainer Applied
#1 lore raw
Quoted 3 lines · Ondrej Mosnacek

Otherwise the fd will leak to subprocesses (e.g. modprobe). That's mostly benign, but it may trigger an SELinux denial when the modprobe process transitions to another domain.

Applied, thanks.