summaryrefslogtreecommitdiff
blob: 0b471688cc0dee72b4fb2de5c4fe9109351585f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 9a128f32fc277dd0c07bc85c71dc25d123f8a831 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner@ubuntu.com>
Date: Wed, 4 Aug 2021 21:34:11 +0200
Subject: [PATCH] syscall_wrappers: don't conflict with glibc provided
 close_range()

Newer glibc version's provide a wrapper for close_range().

Fixes: #9084
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 lxd/include/syscall_wrappers.h | 2 +-
 lxd/main_checkfeature.go       | 2 +-
 lxd/main_forkexec.go           | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/include/syscall_wrappers.h b/lxd/include/syscall_wrappers.h
index 4405a622b801..25e56a5cefac 100644
--- a/lxd/include/syscall_wrappers.h
+++ b/lxd/include/syscall_wrappers.h
@@ -16,7 +16,7 @@
 #define CLOSE_RANGE_UNSHARE (1U << 1)
 #endif
 
-static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int flags)
+static inline int lxd_close_range(unsigned int fd, unsigned int max_fd, unsigned int flags)
 {
 	return syscall(__NR_close_range, fd, max_fd, flags);
 }
diff --git a/lxd/main_checkfeature.go b/lxd/main_checkfeature.go
index 9511b684fa5d..0cc89207158d 100644
--- a/lxd/main_checkfeature.go
+++ b/lxd/main_checkfeature.go
@@ -496,7 +496,7 @@ static void is_close_range_aware(void)
 	if (fd < 0)
 		return;
 
-	if (close_range(fd, fd, CLOSE_RANGE_UNSHARE))
+	if (lxd_close_range(fd, fd, CLOSE_RANGE_UNSHARE))
 		return;
 
 	close_range_aware = true;
diff --git a/lxd/main_forkexec.go b/lxd/main_forkexec.go
index 574f25eeb988..cfa4cd6bcda8 100644
--- a/lxd/main_forkexec.go
+++ b/lxd/main_forkexec.go
@@ -290,7 +290,7 @@ __attribute__ ((noinline)) static int __forkexec(void)
 	if (!argvp || !*argvp)
 		return log_error(EXIT_FAILURE, "No command specified");
 
-	ret = close_range(EXEC_PIPE_FD + 1, UINT_MAX, CLOSE_RANGE_UNSHARE);
+	ret = lxd_close_range(EXEC_PIPE_FD + 1, UINT_MAX, CLOSE_RANGE_UNSHARE);
 	if (ret) {
 		// Fallback to close_inherited() when the syscall is not
 		// available or when CLOSE_RANGE_UNSHARE isn't supported.
-- 
2.32.0