idx int64 | func_before string | Vulnerability Classification string | vul int64 | func_after string | patch string | CWE ID string | lines_before string | lines_after string |
|---|---|---|---|---|---|---|---|---|
35,600 | static void pid_to_ns_wrapper(int sock, pid_t tpid)
{
int newnsfd = -1, ret, cpipe[2];
char fnam[100];
pid_t cpid;
struct timeval tv;
fd_set s;
char v;
ret = snprintf(fnam, sizeof(fnam), "/proc/%d/ns/pid", tpid);
if (ret < 0 || ret >= sizeof(fnam))
_exit(1);
newnsfd = open(fnam, O_RDONLY);
if (newnsfd < 0)... | +Priv | 0 | static void pid_to_ns_wrapper(int sock, pid_t tpid)
{
int newnsfd = -1, ret, cpipe[2];
char fnam[100];
pid_t cpid;
struct timeval tv;
fd_set s;
char v;
ret = snprintf(fnam, sizeof(fnam), "/proc/%d/ns/pid", tpid);
if (ret < 0 || ret >= sizeof(fnam))
_exit(1);
newnsfd = open(fnam, O_RDONLY);
if (newnsfd < 0)... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,601 | static int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *cpuset = NULL;
char *line = NULL;
size_t linelen = 0, total_len = 0, rv = 0;
bool am_printing = false;
... | +Priv | 0 | static int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *cpuset = NULL;
char *line = NULL;
size_t linelen = 0, total_len = 0, rv = 0;
bool am_printing = false;
... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,602 | static int proc_diskstats_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
char dev_name[72];
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *io_serviced_str = NULL, *io_merged_str = NULL, *io_service_bytes_str = NULL,
*io_... | +Priv | 0 | static int proc_diskstats_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
char dev_name[72];
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *io_serviced_str = NULL, *io_merged_str = NULL, *io_service_bytes_str = NULL,
*io_... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,603 | static int proc_getattr(const char *path, struct stat *sb)
{
struct timespec now;
memset(sb, 0, sizeof(struct stat));
if (clock_gettime(CLOCK_REALTIME, &now) < 0)
return -EINVAL;
sb->st_uid = sb->st_gid = 0;
sb->st_atim = sb->st_mtim = sb->st_ctim = now;
if (strcmp(path, "/proc") == 0) {
sb->st_mode = S_IFDI... | +Priv | 0 | static int proc_getattr(const char *path, struct stat *sb)
{
struct timespec now;
memset(sb, 0, sizeof(struct stat));
if (clock_gettime(CLOCK_REALTIME, &now) < 0)
return -EINVAL;
sb->st_uid = sb->st_gid = 0;
sb->st_atim = sb->st_mtim = sb->st_ctim = now;
if (strcmp(path, "/proc") == 0) {
sb->st_mode = S_IFDI... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,604 | static int proc_meminfo_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *memusage_str = NULL, *memstat_str = NULL,
*memswlimit_str = NULL, *memswusage_str = NULL;
unsigned long... | +Priv | 0 | static int proc_meminfo_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *memusage_str = NULL, *memstat_str = NULL,
*memswlimit_str = NULL, *memswusage_str = NULL;
unsigned long... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,605 | static int proc_open(const char *path, struct fuse_file_info *fi)
{
int type = -1;
struct file_info *info;
if (strcmp(path, "/proc/meminfo") == 0)
type = LXC_TYPE_PROC_MEMINFO;
else if (strcmp(path, "/proc/cpuinfo") == 0)
type = LXC_TYPE_PROC_CPUINFO;
else if (strcmp(path, "/proc/uptime") == 0)
type = LXC_T... | +Priv | 0 | static int proc_open(const char *path, struct fuse_file_info *fi)
{
int type = -1;
struct file_info *info;
if (strcmp(path, "/proc/meminfo") == 0)
type = LXC_TYPE_PROC_MEMINFO;
else if (strcmp(path, "/proc/cpuinfo") == 0)
type = LXC_TYPE_PROC_CPUINFO;
else if (strcmp(path, "/proc/uptime") == 0)
type = LXC_T... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,606 | static int proc_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct file_info *f = (struct file_info *) fi->fh;
switch (f->type) {
case LXC_TYPE_PROC_MEMINFO:
return proc_meminfo_read(buf, size, offset, fi);
case LXC_TYPE_PROC_CPUINFO:
return proc_cpuinfo_read(buf... | +Priv | 0 | static int proc_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct file_info *f = (struct file_info *) fi->fh;
switch (f->type) {
case LXC_TYPE_PROC_MEMINFO:
return proc_meminfo_read(buf, size, offset, fi);
case LXC_TYPE_PROC_CPUINFO:
return proc_cpuinfo_read(buf... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,607 | static int proc_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset,
struct fuse_file_info *fi)
{
if (filler(buf, "cpuinfo", NULL, 0) != 0 ||
filler(buf, "meminfo", NULL, 0) != 0 ||
filler(buf, "stat", NULL, 0) != 0 ||
filler(buf, "uptime", NULL, 0) != 0 ||
filler(buf, "diskstat... | +Priv | 0 | static int proc_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset,
struct fuse_file_info *fi)
{
if (filler(buf, "cpuinfo", NULL, 0) != 0 ||
filler(buf, "meminfo", NULL, 0) != 0 ||
filler(buf, "stat", NULL, 0) != 0 ||
filler(buf, "uptime", NULL, 0) != 0 ||
filler(buf, "diskstat... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,608 | static int proc_stat_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *cpuset = NULL;
char *line = NULL;
size_t linelen = 0, total_len = 0, rv = 0;
int curcpu = -1; /* cpu numbe... | +Priv | 0 | static int proc_stat_read(char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
struct file_info *d = (struct file_info *)fi->fh;
char *cg;
char *cpuset = NULL;
char *line = NULL;
size_t linelen = 0, total_len = 0, rv = 0;
int curcpu = -1; /* cpu numbe... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,609 | static int read_file(const char *path, char *buf, size_t size,
struct file_info *d)
{
size_t linelen = 0, total_len = 0, rv = 0;
char *line = NULL;
char *cache = d->buf;
size_t cache_size = d->buflen;
FILE *f = fopen(path, "r");
if (!f)
return 0;
while (getline(&line, &linelen, f) != -1) {
size_t l =... | +Priv | 0 | static int read_file(const char *path, char *buf, size_t size,
struct file_info *d)
{
size_t linelen = 0, total_len = 0, rv = 0;
char *line = NULL;
char *cache = d->buf;
size_t cache_size = d->buflen;
FILE *f = fopen(path, "r");
if (!f)
return 0;
while (getline(&line, &linelen, f) != -1) {
size_t l =... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,610 | static bool recv_creds(int sock, struct ucred *cred, char *v)
{
struct msghdr msg = { 0 };
struct iovec iov;
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(*cred))];
char buf[1];
int ret;
int optval = 1;
struct timeval tv;
fd_set rfds;
*v = '1';
cred->pid = -1;
cred->uid = -1;
cred->gid = -1;
if ... | +Priv | 0 | static bool recv_creds(int sock, struct ucred *cred, char *v)
{
struct msghdr msg = { 0 };
struct iovec iov;
struct cmsghdr *cmsg;
char cmsgbuf[CMSG_SPACE(sizeof(*cred))];
char buf[1];
int ret;
int optval = 1;
struct timeval tv;
fd_set rfds;
*v = '1';
cred->pid = -1;
cred->uid = -1;
cred->gid = -1;
if ... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,611 | static bool startswith(const char *line, const char *pref)
{
if (strncmp(line, pref, strlen(pref)) == 0)
return true;
return false;
}
| +Priv | 0 | static bool startswith(const char *line, const char *pref)
{
if (strncmp(line, pref, strlen(pref)) == 0)
return true;
return false;
}
| @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,612 | static void stripnewline(char *x)
{
size_t l = strlen(x);
if (l && x[l-1] == '\n')
x[l-1] = '\0';
}
| +Priv | 0 | static void stripnewline(char *x)
{
size_t l = strlen(x);
if (l && x[l-1] == '\n')
x[l-1] = '\0';
}
| @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,613 | void swallow_option(int *argcp, char *argv[], char *opt, char *v)
{
int i;
for (i = 1; argv[i]; i++) {
if (!argv[i+1])
continue;
if (strcmp(argv[i], opt) != 0)
continue;
if (strcmp(argv[i+1], v) != 0) {
fprintf(stderr, "Warning: unexpected fuse option %s\n", v);
exit(1);
}
for (; argv[i+1]; i++... | +Priv | 0 | void swallow_option(int *argcp, char *argv[], char *opt, char *v)
{
int i;
for (i = 1; argv[i]; i++) {
if (!argv[i+1])
continue;
if (strcmp(argv[i], opt) != 0)
continue;
if (strcmp(argv[i+1], v) != 0) {
fprintf(stderr, "Warning: unexpected fuse option %s\n", v);
exit(1);
}
for (; argv[i+1]; i++... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,614 | static void usage(const char *me)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\n");
fprintf(stderr, "%s mountpoint\n", me);
fprintf(stderr, "%s -h\n", me);
exit(1);
}
| +Priv | 0 | static void usage(const char *me)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\n");
fprintf(stderr, "%s mountpoint\n", me);
fprintf(stderr, "%s -h\n", me);
exit(1);
}
| @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,615 | static int wait_for_pid(pid_t pid)
{
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
return -1;
}
if (ret != pid)
goto again;
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
return -1;
return 0;
}
| +Priv | 0 | static int wait_for_pid(pid_t pid)
{
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
return -1;
}
if (ret != pid)
goto again;
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
return -1;
return 0;
}
| @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,616 | void write_task_init_pid_exit(int sock, pid_t target)
{
struct ucred cred;
char fnam[100];
pid_t pid;
char v;
int fd, ret;
ret = snprintf(fnam, sizeof(fnam), "/proc/%d/ns/pid", (int)target);
if (ret < 0 || ret >= sizeof(fnam))
exit(1);
fd = open(fnam, O_RDONLY);
if (fd < 0) {
perror("get_pid1_time open o... | +Priv | 0 | void write_task_init_pid_exit(int sock, pid_t target)
{
struct ucred cred;
char fnam[100];
pid_t pid;
char v;
int fd, ret;
ret = snprintf(fnam, sizeof(fnam), "/proc/%d/ns/pid", (int)target);
if (ret < 0 || ret >= sizeof(fnam))
exit(1);
fd = open(fnam, O_RDONLY);
if (fd < 0) {
perror("get_pid1_time open o... | @@ -1336,7 +1336,95 @@ static void pid_from_ns_wrapper(int sock, pid_t tpid)
goto loop;
}
-static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)
+/*
+ * Given host @uid, return the uid to which it maps in
+ * @pid's user namespace, or -1 if none.
+ */
+bool ho... | CWE-264 | null | null |
35,617 | int cg_write(const char *path, const char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
char *localbuf = NULL;
struct cgfs_files *k = NULL;
struct file_info *f = (struct file_info *)fi->fh;
bool r;
if (f->type != LXC_TYPE_CGFILE) {
fprintf(std... | +Priv | 0 | int cg_write(const char *path, const char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
struct fuse_context *fc = fuse_get_context();
char *localbuf = NULL;
struct cgfs_files *k = NULL;
struct file_info *f = (struct file_info *)fi->fh;
bool r;
if (f->type != LXC_TYPE_CGFILE) {
fprintf(std... | @@ -235,6 +235,12 @@ static bool perms_include(int fmode, mode_t req_mode)
return ((fmode & r) == r);
}
+
+/*
+ * taskcg is a/b/c
+ * querycg is /a/b/c/d/e
+ * we return 'd'
+ */
static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
{
char *start, *end;
@@ -378,53 +384,71 @@ static void pr... | CWE-264 | null | null |
35,618 | static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
{
char *start, *end;
if (strlen(taskcg) <= strlen(querycg)) {
fprintf(stderr, "%s: I was fed bad input\n", __func__);
return NULL;
}
if (strcmp(querycg, "/") == 0)
start = strdup(taskcg + 1);
else
start = strdup(taskcg + strlen... | +Priv | 0 | static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
{
char *start, *end;
if (strlen(taskcg) <= strlen(querycg)) {
fprintf(stderr, "%s: I was fed bad input\n", __func__);
return NULL;
}
if (strcmp(querycg, "/") == 0)
start = strdup(taskcg + 1);
else
start = strdup(taskcg + strlen... | @@ -235,6 +235,12 @@ static bool perms_include(int fmode, mode_t req_mode)
return ((fmode & r) == r);
}
+
+/*
+ * taskcg is a/b/c
+ * querycg is /a/b/c/d/e
+ * we return 'd'
+ */
static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
{
char *start, *end;
@@ -378,53 +384,71 @@ static void pr... | CWE-264 | null | null |
35,619 | static bool perms_include(int fmode, mode_t req_mode)
{
mode_t r;
switch (req_mode & O_ACCMODE) {
case O_RDONLY:
r = S_IROTH;
break;
case O_WRONLY:
r = S_IWOTH;
break;
case O_RDWR:
r = S_IROTH | S_IWOTH;
break;
default:
return false;
}
return ((fmode & r) == r);
}
| +Priv | 0 | static bool perms_include(int fmode, mode_t req_mode)
{
mode_t r;
switch (req_mode & O_ACCMODE) {
case O_RDONLY:
r = S_IROTH;
break;
case O_WRONLY:
r = S_IWOTH;
break;
case O_RDWR:
r = S_IROTH | S_IWOTH;
break;
default:
return false;
}
return ((fmode & r) == r);
}
| @@ -235,6 +235,12 @@ static bool perms_include(int fmode, mode_t req_mode)
return ((fmode & r) == r);
}
+
+/*
+ * taskcg is a/b/c
+ * querycg is /a/b/c/d/e
+ * we return 'd'
+ */
static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
{
char *start, *end;
@@ -378,53 +384,71 @@ static void pr... | CWE-264 | null | null |
35,620 | static void pid_from_ns_wrapper(int sock, pid_t tpid)
{
int newnsfd = -1, ret, cpipe[2];
char fnam[100];
pid_t cpid;
fd_set s;
struct timeval tv;
char v;
ret = snprintf(fnam, sizeof(fnam), "/proc/%d/ns/pid", tpid);
if (ret < 0 || ret >= sizeof(fnam))
_exit(1);
newnsfd = open(fnam, O_RDONLY);
if (newnsfd < ... | +Priv | 0 | static void pid_from_ns_wrapper(int sock, pid_t tpid)
{
int newnsfd = -1, ret, cpipe[2];
char fnam[100];
pid_t cpid;
fd_set s;
struct timeval tv;
char v;
ret = snprintf(fnam, sizeof(fnam), "/proc/%d/ns/pid", tpid);
if (ret < 0 || ret >= sizeof(fnam))
_exit(1);
newnsfd = open(fnam, O_RDONLY);
if (newnsfd < ... | @@ -235,6 +235,12 @@ static bool perms_include(int fmode, mode_t req_mode)
return ((fmode & r) == r);
}
+
+/*
+ * taskcg is a/b/c
+ * querycg is /a/b/c/d/e
+ * we return 'd'
+ */
static char *get_next_cgroup_dir(const char *taskcg, const char *querycg)
{
char *start, *end;
@@ -378,53 +384,71 @@ static void pr... | CWE-264 | null | null |
35,621 | static const char *cgfs_canonical_path(void *hdata)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *info_ptr;
char *path = NULL;
if (!d)
return NULL;
for (info_ptr = d->info; info_ptr; info_ptr = info_ptr->next) {
if (!path)
path = info_ptr->cgroup_path;
else if (strcmp(path, info_ptr->cgroup... | null | 0 | static const char *cgfs_canonical_path(void *hdata)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *info_ptr;
char *path = NULL;
if (!d)
return NULL;
for (info_ptr = d->info; info_ptr; info_ptr = info_ptr->next) {
if (!path)
path = info_ptr->cgroup_path;
else if (strcmp(path, info_ptr->cgroup... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,622 | static inline bool cgfs_create(void *hdata)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *i;
struct cgroup_meta_data *md;
if (!d)
return false;
md = d->meta;
i = lxc_cgroupfs_create(d->name, d->cgroup_pattern, md, NULL);
if (!i)
return false;
d->info = i;
return true;
}
| null | 0 | static inline bool cgfs_create(void *hdata)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *i;
struct cgroup_meta_data *md;
if (!d)
return false;
md = d->meta;
i = lxc_cgroupfs_create(d->name, d->cgroup_pattern, md, NULL);
if (!i)
return false;
d->info = i;
return true;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,623 | static inline bool cgfs_create_legacy(void *hdata, pid_t pid)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *i;
if (!d)
return false;
i = d->info;
if (lxc_cgroup_create_legacy(i, d->name, pid) < 0) {
ERROR("failed to create legacy ns cgroups for '%s'", d->name);
return false;
}
return true;
}
| null | 0 | static inline bool cgfs_create_legacy(void *hdata, pid_t pid)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *i;
if (!d)
return false;
i = d->info;
if (lxc_cgroup_create_legacy(i, d->name, pid) < 0) {
ERROR("failed to create legacy ns cgroups for '%s'", d->name);
return false;
}
return true;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,624 | static inline bool cgfs_enter(void *hdata, pid_t pid)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *i;
int ret;
if (!d)
return false;
i = d->info;
ret = lxc_cgroupfs_enter(i, pid, false);
return ret == 0;
}
| null | 0 | static inline bool cgfs_enter(void *hdata, pid_t pid)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *i;
int ret;
if (!d)
return false;
i = d->info;
ret = lxc_cgroupfs_enter(i, pid, false);
return ret == 0;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,625 | static int cgfs_nrtasks(void *hdata)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *info;
struct cgroup_mount_point *mp = NULL;
char *abs_path = NULL;
int ret;
if (!d) {
errno = ENOENT;
return -1;
}
info = d->info;
if (!info) {
errno = ENOENT;
return -1;
}
if (info->designated_mount_po... | null | 0 | static int cgfs_nrtasks(void *hdata)
{
struct cgfs_data *d = hdata;
struct cgroup_process_info *info;
struct cgroup_mount_point *mp = NULL;
char *abs_path = NULL;
int ret;
if (!d) {
errno = ENOENT;
return -1;
}
info = d->info;
if (!info) {
errno = ENOENT;
return -1;
}
if (info->designated_mount_po... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,626 | static bool cgfs_unfreeze(void *hdata)
{
struct cgfs_data *d = hdata;
char *cgabspath, *cgrelpath;
int ret;
if (!d)
return false;
cgrelpath = lxc_cgroup_get_hierarchy_path_data("freezer", d);
cgabspath = lxc_cgroup_find_abs_path("freezer", cgrelpath, true, NULL);
if (!cgabspath)
return false;
ret = do_cg... | null | 0 | static bool cgfs_unfreeze(void *hdata)
{
struct cgfs_data *d = hdata;
char *cgabspath, *cgrelpath;
int ret;
if (!d)
return false;
cgrelpath = lxc_cgroup_get_hierarchy_path_data("freezer", d);
cgabspath = lxc_cgroup_find_abs_path("freezer", cgrelpath, true, NULL);
if (!cgabspath)
return false;
ret = do_cg... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,627 | static bool cgroup_devices_has_allow_or_deny(struct cgfs_data *d,
char *v, bool for_allow)
{
char *path;
FILE *devices_list;
char *line = NULL;
size_t sz = 0;
bool ret = !for_allow;
const char *parts[3] = {
NULL,
"devices.list",
NULL
};
if (!for_allow && strcmp(v, "a") != 0 && strcmp(v, "a *:* ... | null | 0 | static bool cgroup_devices_has_allow_or_deny(struct cgfs_data *d,
char *v, bool for_allow)
{
char *path;
FILE *devices_list;
char *line = NULL;
size_t sz = 0;
bool ret = !for_allow;
const char *parts[3] = {
NULL,
"devices.list",
NULL
};
if (!for_allow && strcmp(v, "a") != 0 && strcmp(v, "a *:* ... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,628 | static int cgroup_read_from_file(const char *fn, char buf[], size_t bufsize)
{
int ret = lxc_read_from_file(fn, buf, bufsize);
if (ret < 0) {
SYSERROR("failed to read %s", fn);
return ret;
}
if (ret == bufsize) {
if (bufsize > 0) {
/* obviously this wasn't empty */
buf[bufsize-1] = '\0';
return ret;
... | null | 0 | static int cgroup_read_from_file(const char *fn, char buf[], size_t bufsize)
{
int ret = lxc_read_from_file(fn, buf, bufsize);
if (ret < 0) {
SYSERROR("failed to read %s", fn);
return ret;
}
if (ret == bufsize) {
if (bufsize > 0) {
/* obviously this wasn't empty */
buf[bufsize-1] = '\0';
return ret;
... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,629 | static int cgroup_recursive_task_count(const char *cgroup_path)
{
DIR *d;
struct dirent *dent_buf;
struct dirent *dent;
ssize_t name_max;
int n = 0, r;
/* see man readdir_r(3) */
name_max = pathconf(cgroup_path, _PC_NAME_MAX);
if (name_max <= 0)
name_max = 255;
dent_buf = malloc(offsetof(struct dirent, d_na... | null | 0 | static int cgroup_recursive_task_count(const char *cgroup_path)
{
DIR *d;
struct dirent *dent_buf;
struct dirent *dent;
ssize_t name_max;
int n = 0, r;
/* see man readdir_r(3) */
name_max = pathconf(cgroup_path, _PC_NAME_MAX);
if (name_max <= 0)
name_max = 255;
dent_buf = malloc(offsetof(struct dirent, d_na... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,630 | static char *cgroup_rename_nsgroup(const char *mountpath, const char *oldname, pid_t pid, const char *name)
{
char *dir, *fulloldpath;
char *newname, *fullnewpath;
int len, newlen, ret;
/*
* if cgroup is mounted at /cgroup and task is in cgroup /ab/, pid 2375 and
* name is c1,
* dir: /ab
* fulloldpath = /c... | null | 0 | static char *cgroup_rename_nsgroup(const char *mountpath, const char *oldname, pid_t pid, const char *name)
{
char *dir, *fulloldpath;
char *newname, *fullnewpath;
int len, newlen, ret;
/*
* if cgroup is mounted at /cgroup and task is in cgroup /ab/, pid 2375 and
* name is c1,
* dir: /ab
* fulloldpath = /c... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,631 | static int cgroup_rmdir(char *dirname)
{
struct dirent dirent, *direntp;
int saved_errno = 0;
DIR *dir;
int ret, failed=0;
char pathname[MAXPATHLEN];
dir = opendir(dirname);
if (!dir) {
ERROR("%s: failed to open %s", __func__, dirname);
return -1;
}
while (!readdir_r(dir, &dirent, &direntp)) {
struct s... | null | 0 | static int cgroup_rmdir(char *dirname)
{
struct dirent dirent, *direntp;
int saved_errno = 0;
DIR *dir;
int ret, failed=0;
char pathname[MAXPATHLEN];
dir = opendir(dirname);
if (!dir) {
ERROR("%s: failed to open %s", __func__, dirname);
return -1;
}
while (!readdir_r(dir, &dirent, &direntp)) {
struct s... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,632 | static char *cgroup_to_absolute_path(struct cgroup_mount_point *mp,
const char *path, const char *suffix)
{
/* first we have to make sure we subtract the mount point's prefix */
char *prefix = mp->mount_prefix;
char *buf;
ssize_t len, rv;
/* we want to make sure only absolute paths to cgroups are passed ... | null | 0 | static char *cgroup_to_absolute_path(struct cgroup_mount_point *mp,
const char *path, const char *suffix)
{
/* first we have to make sure we subtract the mount point's prefix */
char *prefix = mp->mount_prefix;
char *buf;
ssize_t len, rv;
/* we want to make sure only absolute paths to cgroups are passed ... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,633 | static bool cgroupfs_setup_limits(void *hdata, struct lxc_list *cgroup_conf,
bool with_devices)
{
struct cgfs_data *d = hdata;
if (!d)
return false;
return do_setup_cgroup_limits(d, cgroup_conf, with_devices) == 0;
}
| null | 0 | static bool cgroupfs_setup_limits(void *hdata, struct lxc_list *cgroup_conf,
bool with_devices)
{
struct cgfs_data *d = hdata;
if (!d)
return false;
return do_setup_cgroup_limits(d, cgroup_conf, with_devices) == 0;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,634 | static int count_lines(const char *fn)
{
FILE *f;
char *line = NULL;
size_t sz = 0;
int n = 0;
f = fopen_cloexec(fn, "r");
if (!f)
return -1;
while (getline(&line, &sz, f) != -1) {
n++;
}
free(line);
fclose(f);
return n;
}
| null | 0 | static int count_lines(const char *fn)
{
FILE *f;
char *line = NULL;
size_t sz = 0;
int n = 0;
f = fopen_cloexec(fn, "r");
if (!f)
return -1;
while (getline(&line, &sz, f) != -1) {
n++;
}
free(line);
fclose(f);
return n;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,635 | static int create_cgroup(struct cgroup_mount_point *mp, const char *path)
{
return create_or_remove_cgroup(false, mp, path, false);
}
| null | 0 | static int create_cgroup(struct cgroup_mount_point *mp, const char *path)
{
return create_or_remove_cgroup(false, mp, path, false);
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,636 | static int create_or_remove_cgroup(bool do_remove,
struct cgroup_mount_point *mp, const char *path, int recurse)
{
int r, saved_errno = 0;
char *buf = cgroup_to_absolute_path(mp, path, NULL);
if (!buf)
return -1;
/* create or remove directory */
if (do_remove) {
if (recurse)
r = cgroup_rmdir(buf);
else... | null | 0 | static int create_or_remove_cgroup(bool do_remove,
struct cgroup_mount_point *mp, const char *path, int recurse)
{
int r, saved_errno = 0;
char *buf = cgroup_to_absolute_path(mp, path, NULL);
if (!buf)
return -1;
/* create or remove directory */
if (do_remove) {
if (recurse)
r = cgroup_rmdir(buf);
else... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,637 | static int do_cgroup_get(const char *cgroup_path, const char *sub_filename,
char *value, size_t len)
{
const char *parts[3] = {
cgroup_path,
sub_filename,
NULL
};
char *filename;
int ret, saved_errno;
filename = lxc_string_join("/", parts, false);
if (!filename)
return -1;
ret = lxc_read_from_file(... | null | 0 | static int do_cgroup_get(const char *cgroup_path, const char *sub_filename,
char *value, size_t len)
{
const char *parts[3] = {
cgroup_path,
sub_filename,
NULL
};
char *filename;
int ret, saved_errno;
filename = lxc_string_join("/", parts, false);
if (!filename)
return -1;
ret = lxc_read_from_file(... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,638 | static int do_cgroup_set(const char *cgroup_path, const char *sub_filename,
const char *value)
{
const char *parts[3] = {
cgroup_path,
sub_filename,
NULL
};
char *filename;
int ret, saved_errno;
filename = lxc_string_join("/", parts, false);
if (!filename)
return -1;
ret = lxc_write_to_file(filenam... | null | 0 | static int do_cgroup_set(const char *cgroup_path, const char *sub_filename,
const char *value)
{
const char *parts[3] = {
cgroup_path,
sub_filename,
NULL
};
char *filename;
int ret, saved_errno;
filename = lxc_string_join("/", parts, false);
if (!filename)
return -1;
ret = lxc_write_to_file(filenam... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,639 | static bool do_init_cpuset_file(struct cgroup_mount_point *mp,
const char *path, const char *name)
{
char value[1024];
char *childfile, *parentfile = NULL, *tmp;
int ret;
bool ok = false;
childfile = cgroup_to_absolute_path(mp, path, name);
if (!childfile)
return false;
/* don't overwrite a non-empty val... | null | 0 | static bool do_init_cpuset_file(struct cgroup_mount_point *mp,
const char *path, const char *name)
{
char value[1024];
char *childfile, *parentfile = NULL, *tmp;
int ret;
bool ok = false;
childfile = cgroup_to_absolute_path(mp, path, name);
if (!childfile)
return false;
/* don't overwrite a non-empty val... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,640 | static int do_setup_cgroup_limits(struct cgfs_data *d,
struct lxc_list *cgroup_settings, bool do_devices)
{
struct lxc_list *iterator, *sorted_cgroup_settings, *next;
struct lxc_cgroup *cg;
int ret = -1;
if (lxc_list_empty(cgroup_settings))
return 0;
sorted_cgroup_settings = sort_cgroup_settings(cgroup_s... | null | 0 | static int do_setup_cgroup_limits(struct cgfs_data *d,
struct lxc_list *cgroup_settings, bool do_devices)
{
struct lxc_list *iterator, *sorted_cgroup_settings, *next;
struct lxc_cgroup *cg;
int ret = -1;
if (lxc_list_empty(cgroup_settings))
return 0;
sorted_cgroup_settings = sort_cgroup_settings(cgroup_s... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,641 | static bool find_cgroup_hierarchies(struct cgroup_meta_data *meta_data,
bool all_kernel_subsystems, bool all_named_subsystems,
const char **subsystem_whitelist)
{
FILE *proc_self_cgroup;
char *line = NULL;
size_t sz = 0;
int r;
bool bret = false;
size_t hierarchy_capacity = 0;
proc_self_cgroup = fopen_cloexec... | null | 0 | static bool find_cgroup_hierarchies(struct cgroup_meta_data *meta_data,
bool all_kernel_subsystems, bool all_named_subsystems,
const char **subsystem_whitelist)
{
FILE *proc_self_cgroup;
char *line = NULL;
size_t sz = 0;
int r;
bool bret = false;
size_t hierarchy_capacity = 0;
proc_self_cgroup = fopen_cloexec... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,642 | static bool find_cgroup_subsystems(char ***kernel_subsystems)
{
FILE *proc_cgroups;
bool bret = false;
char *line = NULL;
size_t sz = 0;
size_t kernel_subsystems_count = 0;
size_t kernel_subsystems_capacity = 0;
int r;
proc_cgroups = fopen_cloexec("/proc/cgroups", "r");
if (!proc_cgroups)
return false;
wh... | null | 0 | static bool find_cgroup_subsystems(char ***kernel_subsystems)
{
FILE *proc_cgroups;
bool bret = false;
char *line = NULL;
size_t sz = 0;
size_t kernel_subsystems_count = 0;
size_t kernel_subsystems_capacity = 0;
int r;
proc_cgroups = fopen_cloexec("/proc/cgroups", "r");
if (!proc_cgroups)
return false;
wh... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,643 | static bool find_hierarchy_mountpts( struct cgroup_meta_data *meta_data, char **kernel_subsystems)
{
bool bret = false;
FILE *proc_self_mountinfo;
char *line = NULL;
size_t sz = 0;
char **tokens = NULL;
size_t mount_point_count = 0;
size_t mount_point_capacity = 0;
size_t token_capacity = 0;
int r;
proc_self... | null | 0 | static bool find_hierarchy_mountpts( struct cgroup_meta_data *meta_data, char **kernel_subsystems)
{
bool bret = false;
FILE *proc_self_mountinfo;
char *line = NULL;
size_t sz = 0;
char **tokens = NULL;
size_t mount_point_count = 0;
size_t mount_point_capacity = 0;
size_t token_capacity = 0;
int r;
proc_self... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,644 | find_info_for_subsystem(struct cgroup_process_info *info, const char *subsystem)
{
struct cgroup_process_info *info_ptr;
for (info_ptr = info; info_ptr; info_ptr = info_ptr->next) {
struct cgroup_hierarchy *h = info_ptr->hierarchy;
if (lxc_string_in_array(subsystem, (const char **)h->subsystems))
return info_p... | null | 0 | find_info_for_subsystem(struct cgroup_process_info *info, const char *subsystem)
{
struct cgroup_process_info *info_ptr;
for (info_ptr = info; info_ptr; info_ptr = info_ptr->next) {
struct cgroup_hierarchy *h = info_ptr->hierarchy;
if (lxc_string_in_array(subsystem, (const char **)h->subsystems))
return info_p... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,645 | static bool init_cpuset_if_needed(struct cgroup_mount_point *mp,
const char *path)
{
/* the files we have to handle here are only in cpuset hierarchies */
if (!lxc_string_in_array("cpuset",
(const char **)mp->hierarchy->subsystems))
return true;
if (!mp->need_cpuset_init)
return true;
return (do_in... | null | 0 | static bool init_cpuset_if_needed(struct cgroup_mount_point *mp,
const char *path)
{
/* the files we have to handle here are only in cpuset hierarchies */
if (!lxc_string_in_array("cpuset",
(const char **)mp->hierarchy->subsystems))
return true;
if (!mp->need_cpuset_init)
return true;
return (do_in... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,646 | static int lxc_cgroup_create_legacy(struct cgroup_process_info *base_info, const char *name, pid_t pid)
{
struct cgroup_process_info *info_ptr;
int r;
for (info_ptr = base_info; info_ptr; info_ptr = info_ptr->next) {
if (!lxc_string_in_array("ns", (const char **)info_ptr->hierarchy->subsystems))
continue;
/*... | null | 0 | static int lxc_cgroup_create_legacy(struct cgroup_process_info *base_info, const char *name, pid_t pid)
{
struct cgroup_process_info *info_ptr;
int r;
for (info_ptr = base_info; info_ptr; info_ptr = info_ptr->next) {
if (!lxc_string_in_array("ns", (const char **)info_ptr->hierarchy->subsystems))
continue;
/*... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,647 | static char *lxc_cgroup_find_abs_path(const char *subsystem, const char *group, bool should_be_writable, const char *suffix)
{
struct cgroup_meta_data *meta_data;
struct cgroup_hierarchy *h;
struct cgroup_mount_point *mp;
char *result;
int saved_errno;
meta_data = lxc_cgroup_load_meta();
if (!meta_data)
retur... | null | 0 | static char *lxc_cgroup_find_abs_path(const char *subsystem, const char *group, bool should_be_writable, const char *suffix)
{
struct cgroup_meta_data *meta_data;
struct cgroup_hierarchy *h;
struct cgroup_mount_point *mp;
char *result;
int saved_errno;
meta_data = lxc_cgroup_load_meta();
if (!meta_data)
retur... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,648 | static struct cgroup_hierarchy *lxc_cgroup_find_hierarchy(struct cgroup_meta_data *meta_data, const char *subsystem)
{
size_t i;
for (i = 0; i <= meta_data->maximum_hierarchy; i++) {
struct cgroup_hierarchy *h = meta_data->hierarchies[i];
if (h && lxc_string_in_array(subsystem, (const char **)h->subsystems))
r... | null | 0 | static struct cgroup_hierarchy *lxc_cgroup_find_hierarchy(struct cgroup_meta_data *meta_data, const char *subsystem)
{
size_t i;
for (i = 0; i <= meta_data->maximum_hierarchy; i++) {
struct cgroup_hierarchy *h = meta_data->hierarchies[i];
if (h && lxc_string_in_array(subsystem, (const char **)h->subsystems))
r... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,649 | static struct cgroup_mount_point *lxc_cgroup_find_mount_point(struct cgroup_hierarchy *hierarchy, const char *group, bool should_be_writable)
{
struct cgroup_mount_point **mps;
struct cgroup_mount_point *current_result = NULL;
ssize_t quality = -1;
/* trivial case */
if (hierarchy->rw_absolute_mount_point)
retu... | null | 0 | static struct cgroup_mount_point *lxc_cgroup_find_mount_point(struct cgroup_hierarchy *hierarchy, const char *group, bool should_be_writable)
{
struct cgroup_mount_point **mps;
struct cgroup_mount_point *current_result = NULL;
ssize_t quality = -1;
/* trivial case */
if (hierarchy->rw_absolute_mount_point)
retu... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,650 | static char *lxc_cgroup_get_hierarchy_abs_path(const char *subsystem, const char *name, const char *lxcpath)
{
struct cgroup_meta_data *meta;
struct cgroup_process_info *base_info, *info;
struct cgroup_mount_point *mp;
char *result = NULL;
meta = lxc_cgroup_load_meta();
if (!meta)
return NULL;
base_info = lxc... | null | 0 | static char *lxc_cgroup_get_hierarchy_abs_path(const char *subsystem, const char *name, const char *lxcpath)
{
struct cgroup_meta_data *meta;
struct cgroup_process_info *base_info, *info;
struct cgroup_mount_point *mp;
char *result = NULL;
meta = lxc_cgroup_load_meta();
if (!meta)
return NULL;
base_info = lxc... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,651 | static char *lxc_cgroup_get_hierarchy_abs_path_data(const char *subsystem, struct cgfs_data *d)
{
struct cgroup_process_info *info = d->info;
struct cgroup_mount_point *mp = NULL;
info = find_info_for_subsystem(info, subsystem);
if (!info)
return NULL;
if (info->designated_mount_point) {
mp = info->designated... | null | 0 | static char *lxc_cgroup_get_hierarchy_abs_path_data(const char *subsystem, struct cgfs_data *d)
{
struct cgroup_process_info *info = d->info;
struct cgroup_mount_point *mp = NULL;
info = find_info_for_subsystem(info, subsystem);
if (!info)
return NULL;
if (info->designated_mount_point) {
mp = info->designated... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,652 | static char *lxc_cgroup_get_hierarchy_path_data(const char *subsystem, struct cgfs_data *d)
{
struct cgroup_process_info *info = d->info;
info = find_info_for_subsystem(info, subsystem);
if (!info)
return NULL;
return info->cgroup_path;
}
| null | 0 | static char *lxc_cgroup_get_hierarchy_path_data(const char *subsystem, struct cgfs_data *d)
{
struct cgroup_process_info *info = d->info;
info = find_info_for_subsystem(info, subsystem);
if (!info)
return NULL;
return info->cgroup_path;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,653 | static struct cgroup_meta_data *lxc_cgroup_get_meta(struct cgroup_meta_data *meta_data)
{
meta_data->ref++;
return meta_data;
}
| null | 0 | static struct cgroup_meta_data *lxc_cgroup_get_meta(struct cgroup_meta_data *meta_data)
{
meta_data->ref++;
return meta_data;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,654 | static void lxc_cgroup_hierarchy_free(struct cgroup_hierarchy *h)
{
if (!h)
return;
lxc_free_array((void **)h->subsystems, free);
free(h->all_mount_points);
free(h);
}
| null | 0 | static void lxc_cgroup_hierarchy_free(struct cgroup_hierarchy *h)
{
if (!h)
return;
lxc_free_array((void **)h->subsystems, free);
free(h->all_mount_points);
free(h);
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,655 | static struct cgroup_meta_data *lxc_cgroup_load_meta()
{
const char *cgroup_use = NULL;
char **cgroup_use_list = NULL;
struct cgroup_meta_data *md = NULL;
int saved_errno;
errno = 0;
cgroup_use = lxc_global_config_value("lxc.cgroup.use");
if (!cgroup_use && errno != 0)
return NULL;
if (cgroup_use) {
cgroup... | null | 0 | static struct cgroup_meta_data *lxc_cgroup_load_meta()
{
const char *cgroup_use = NULL;
char **cgroup_use_list = NULL;
struct cgroup_meta_data *md = NULL;
int saved_errno;
errno = 0;
cgroup_use = lxc_global_config_value("lxc.cgroup.use");
if (!cgroup_use && errno != 0)
return NULL;
if (cgroup_use) {
cgroup... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,656 | static struct cgroup_meta_data *lxc_cgroup_load_meta2(const char **subsystem_whitelist)
{
bool all_kernel_subsystems = true;
bool all_named_subsystems = false;
struct cgroup_meta_data *meta_data = NULL;
char **kernel_subsystems = NULL;
int saved_errno = 0;
/* if the subsystem whitelist is not specified, include ... | null | 0 | static struct cgroup_meta_data *lxc_cgroup_load_meta2(const char **subsystem_whitelist)
{
bool all_kernel_subsystems = true;
bool all_named_subsystems = false;
struct cgroup_meta_data *meta_data = NULL;
char **kernel_subsystems = NULL;
int saved_errno = 0;
/* if the subsystem whitelist is not specified, include ... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,657 | static void lxc_cgroup_mount_point_free(struct cgroup_mount_point *mp)
{
if (!mp)
return;
free(mp->mount_point);
free(mp->mount_prefix);
free(mp);
}
| null | 0 | static void lxc_cgroup_mount_point_free(struct cgroup_mount_point *mp)
{
if (!mp)
return;
free(mp->mount_point);
free(mp->mount_prefix);
free(mp);
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,658 | void lxc_cgroup_process_info_free_and_remove(struct cgroup_process_info *info)
{
struct cgroup_process_info *next;
char **pp;
if (!info)
return;
next = info->next;
{
struct cgroup_mount_point *mp = info->designated_mount_point;
if (!mp)
mp = lxc_cgroup_find_mount_point(info->hierarchy, info->cgroup_path, ... | null | 0 | void lxc_cgroup_process_info_free_and_remove(struct cgroup_process_info *info)
{
struct cgroup_process_info *next;
char **pp;
if (!info)
return;
next = info->next;
{
struct cgroup_mount_point *mp = info->designated_mount_point;
if (!mp)
mp = lxc_cgroup_find_mount_point(info->hierarchy, info->cgroup_path, ... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,659 | static struct cgroup_process_info *lxc_cgroup_process_info_get(pid_t pid, struct cgroup_meta_data *meta)
{
char pid_buf[32];
snprintf(pid_buf, 32, "/proc/%lu/cgroup", (unsigned long)pid);
return lxc_cgroup_process_info_getx(pid_buf, meta);
}
| null | 0 | static struct cgroup_process_info *lxc_cgroup_process_info_get(pid_t pid, struct cgroup_meta_data *meta)
{
char pid_buf[32];
snprintf(pid_buf, 32, "/proc/%lu/cgroup", (unsigned long)pid);
return lxc_cgroup_process_info_getx(pid_buf, meta);
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,660 | static struct cgroup_process_info *lxc_cgroup_process_info_get_init(struct cgroup_meta_data *meta)
{
return lxc_cgroup_process_info_get(1, meta);
}
| null | 0 | static struct cgroup_process_info *lxc_cgroup_process_info_get_init(struct cgroup_meta_data *meta)
{
return lxc_cgroup_process_info_get(1, meta);
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,661 | static struct cgroup_process_info *lxc_cgroup_process_info_get_self(struct cgroup_meta_data *meta)
{
struct cgroup_process_info *i;
i = lxc_cgroup_process_info_getx("/proc/self/cgroup", meta);
if (!i)
i = lxc_cgroup_process_info_get(getpid(), meta);
return i;
}
| null | 0 | static struct cgroup_process_info *lxc_cgroup_process_info_get_self(struct cgroup_meta_data *meta)
{
struct cgroup_process_info *i;
i = lxc_cgroup_process_info_getx("/proc/self/cgroup", meta);
if (!i)
i = lxc_cgroup_process_info_get(getpid(), meta);
return i;
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,662 | lxc_cgroup_process_info_getx(const char *proc_pid_cgroup_str,
struct cgroup_meta_data *meta)
{
struct cgroup_process_info *result = NULL;
FILE *proc_pid_cgroup = NULL;
char *line = NULL;
size_t sz = 0;
int saved_errno = 0;
struct cgroup_process_info **cptr = &result;
struct cgroup_process_info *entry = N... | null | 0 | lxc_cgroup_process_info_getx(const char *proc_pid_cgroup_str,
struct cgroup_meta_data *meta)
{
struct cgroup_process_info *result = NULL;
FILE *proc_pid_cgroup = NULL;
char *line = NULL;
size_t sz = 0;
int saved_errno = 0;
struct cgroup_process_info **cptr = &result;
struct cgroup_process_info *entry = N... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,663 | static struct cgroup_meta_data *lxc_cgroup_put_meta(struct cgroup_meta_data *meta_data)
{
size_t i;
if (!meta_data)
return NULL;
if (--meta_data->ref > 0)
return meta_data;
lxc_free_array((void **)meta_data->mount_points, (lxc_free_fn)lxc_cgroup_mount_point_free);
if (meta_data->hierarchies) {
for (i = 0; i ... | null | 0 | static struct cgroup_meta_data *lxc_cgroup_put_meta(struct cgroup_meta_data *meta_data)
{
size_t i;
if (!meta_data)
return NULL;
if (--meta_data->ref > 0)
return meta_data;
lxc_free_array((void **)meta_data->mount_points, (lxc_free_fn)lxc_cgroup_mount_point_free);
if (meta_data->hierarchies) {
for (i = 0; i ... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,664 | static int lxc_cgroup_set_data(const char *filename, const char *value, struct cgfs_data *d)
{
char *subsystem = NULL, *p, *path;
int ret = -1;
subsystem = alloca(strlen(filename) + 1);
strcpy(subsystem, filename);
if ((p = strchr(subsystem, '.')) != NULL)
*p = '\0';
path = lxc_cgroup_get_hierarchy_abs_path_d... | null | 0 | static int lxc_cgroup_set_data(const char *filename, const char *value, struct cgfs_data *d)
{
char *subsystem = NULL, *p, *path;
int ret = -1;
subsystem = alloca(strlen(filename) + 1);
strcpy(subsystem, filename);
if ((p = strchr(subsystem, '.')) != NULL)
*p = '\0';
path = lxc_cgroup_get_hierarchy_abs_path_d... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,665 | static bool lxc_cgroupfs_attach(const char *name, const char *lxcpath, pid_t pid)
{
struct cgroup_meta_data *meta_data;
struct cgroup_process_info *container_info;
int ret;
meta_data = lxc_cgroup_load_meta();
if (!meta_data) {
ERROR("could not move attached process %d to cgroup of container", pid);
return fal... | null | 0 | static bool lxc_cgroupfs_attach(const char *name, const char *lxcpath, pid_t pid)
{
struct cgroup_meta_data *meta_data;
struct cgroup_process_info *container_info;
int ret;
meta_data = lxc_cgroup_load_meta();
if (!meta_data) {
ERROR("could not move attached process %d to cgroup of container", pid);
return fal... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,666 | static struct cgroup_process_info *lxc_cgroupfs_create(const char *name, const char *path_pattern, struct cgroup_meta_data *meta_data, const char *sub_pattern)
{
char **cgroup_path_components = NULL;
char **p = NULL;
char *path_so_far = NULL;
char **new_cgroup_paths = NULL;
char **new_cgroup_paths_sub = NULL;
str... | null | 0 | static struct cgroup_process_info *lxc_cgroupfs_create(const char *name, const char *path_pattern, struct cgroup_meta_data *meta_data, const char *sub_pattern)
{
char **cgroup_path_components = NULL;
char **p = NULL;
char *path_so_far = NULL;
char **new_cgroup_paths = NULL;
char **new_cgroup_paths_sub = NULL;
str... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,667 | static int lxc_cgroupfs_enter(struct cgroup_process_info *info, pid_t pid, bool enter_sub)
{
char pid_buf[32];
char *cgroup_tasks_fn;
int r;
struct cgroup_process_info *info_ptr;
snprintf(pid_buf, 32, "%lu", (unsigned long)pid);
for (info_ptr = info; info_ptr; info_ptr = info_ptr->next) {
char *cgroup_path = (... | null | 0 | static int lxc_cgroupfs_enter(struct cgroup_process_info *info, pid_t pid, bool enter_sub)
{
char pid_buf[32];
char *cgroup_tasks_fn;
int r;
struct cgroup_process_info *info_ptr;
snprintf(pid_buf, 32, "%lu", (unsigned long)pid);
for (info_ptr = info; info_ptr; info_ptr = info_ptr->next) {
char *cgroup_path = (... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,668 | static int lxc_cgroupfs_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath)
{
char *subsystem = NULL, *p, *path;
int ret = -1;
subsystem = alloca(strlen(filename) + 1);
strcpy(subsystem, filename);
if ((p = strchr(subsystem, '.')) != NULL)
*p = '\0';
path = lxc_cgroup_get... | null | 0 | static int lxc_cgroupfs_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath)
{
char *subsystem = NULL, *p, *path;
int ret = -1;
subsystem = alloca(strlen(filename) + 1);
strcpy(subsystem, filename);
if ((p = strchr(subsystem, '.')) != NULL)
*p = '\0';
path = lxc_cgroup_get... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,669 | static int lxc_cgroupfs_set(const char *filename, const char *value, const char *name, const char *lxcpath)
{
char *subsystem = NULL, *p, *path;
int ret = -1;
subsystem = alloca(strlen(filename) + 1);
strcpy(subsystem, filename);
if ((p = strchr(subsystem, '.')) != NULL)
*p = '\0';
path = lxc_cgroup_get_hiera... | null | 0 | static int lxc_cgroupfs_set(const char *filename, const char *value, const char *name, const char *lxcpath)
{
char *subsystem = NULL, *p, *path;
int ret = -1;
subsystem = alloca(strlen(filename) + 1);
strcpy(subsystem, filename);
if ((p = strchr(subsystem, '.')) != NULL)
*p = '\0';
path = lxc_cgroup_get_hiera... | @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,670 | static int remove_cgroup(struct cgroup_mount_point *mp,
const char *path, bool recurse)
{
return create_or_remove_cgroup(true, mp, path, recurse);
}
| null | 0 | static int remove_cgroup(struct cgroup_mount_point *mp,
const char *path, bool recurse)
{
return create_or_remove_cgroup(true, mp, path, recurse);
}
| @@ -1363,7 +1363,10 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type)
if (!path)
return false;
snprintf(path, bufsz, "%s/sys/fs/cgroup", root);
- r = mount("cgroup_root", path, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_RELATIME, "size=10240k,mode=755");
+ r = safe_mount("cgroup_root", ... | CWE-59 | null | null |
35,671 | static inline bool abs_cgroup_supported(void) {
return api_version >= CGM_SUPPORTS_GET_ABS;
}
| null | 0 | static inline bool abs_cgroup_supported(void) {
return api_version >= CGM_SUPPORTS_GET_ABS;
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,672 | static inline bool abs_cgroup_supported(void) {
return false;
}
| null | 0 | static inline bool abs_cgroup_supported(void) {
return false;
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,673 | static bool cgm_attach(const char *name, const char *lxcpath, pid_t pid)
{
bool pass = true;
char *cgroup = NULL;
char **slist = subsystems;
int i;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
for (i = 0; slist[i]; i++) {
cgroup = try_get_abs_cgroup(name, lxcpat... | null | 0 | static bool cgm_attach(const char *name, const char *lxcpath, pid_t pid)
{
bool pass = true;
char *cgroup = NULL;
char **slist = subsystems;
int i;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
for (i = 0; slist[i]; i++) {
cgroup = try_get_abs_cgroup(name, lxcpat... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,674 | static bool cgm_chown(void *hdata, struct lxc_conf *conf)
{
struct cgm_data *d = hdata;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (!chown_cgroup(d->cgroup_path, conf))
WARN("Failed to chown %s to container root", d->... | null | 0 | static bool cgm_chown(void *hdata, struct lxc_conf *conf)
{
struct cgm_data *d = hdata;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (!chown_cgroup(d->cgroup_path, conf))
WARN("Failed to chown %s to container root", d->... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,675 | static bool cgm_dbus_connect(void)
{
DBusError dbus_error;
static DBusConnection *connection;
cgm_lock();
if (!dbus_threads_initialized) {
dbus_threads_init_default();
dbus_threads_initialized = true;
}
dbus_error_init(&dbus_error);
connection = dbus_connection_open_private(CGMANAGER_DBUS_SOCK, &dbus_erro... | null | 0 | static bool cgm_dbus_connect(void)
{
DBusError dbus_error;
static DBusConnection *connection;
cgm_lock();
if (!dbus_threads_initialized) {
dbus_threads_init_default();
dbus_threads_initialized = true;
}
dbus_error_init(&dbus_error);
connection = dbus_connection_open_private(CGMANAGER_DBUS_SOCK, &dbus_erro... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,676 | static void cgm_dbus_disconnect(void)
{
if (cgroup_manager) {
dbus_connection_flush(cgroup_manager->connection);
dbus_connection_close(cgroup_manager->connection);
nih_free(cgroup_manager);
}
cgroup_manager = NULL;
cgm_unlock();
}
| null | 0 | static void cgm_dbus_disconnect(void)
{
if (cgroup_manager) {
dbus_connection_flush(cgroup_manager->connection);
dbus_connection_close(cgroup_manager->connection);
nih_free(cgroup_manager);
}
cgroup_manager = NULL;
cgm_unlock();
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,677 | static void cgm_destroy(void *hdata)
{
struct cgm_data *d = hdata;
char **slist = subsystems;
int i;
if (!d || !d->cgroup_path)
return;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return;
}
if (cgm_supports_multiple_controllers)
slist = subsystems_inone;
for (i = 0; slist[i... | null | 0 | static void cgm_destroy(void *hdata)
{
struct cgm_data *d = hdata;
char **slist = subsystems;
int i;
if (!d || !d->cgroup_path)
return;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return;
}
if (cgm_supports_multiple_controllers)
slist = subsystems_inone;
for (i = 0; slist[i... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,678 | static inline bool cgm_enter(void *hdata, pid_t pid)
{
struct cgm_data *d = hdata;
char **slist = subsystems;
bool ret = false;
int i;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (cgm_all_controllers_same)
slist =... | null | 0 | static inline bool cgm_enter(void *hdata, pid_t pid)
{
struct cgm_data *d = hdata;
char **slist = subsystems;
bool ret = false;
int i;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (cgm_all_controllers_same)
slist =... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,679 | static int cgm_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath)
{
pid_t pid;
int p[2], ret, newlen, readlen;
if (pipe(p) < 0)
return -1;
if ((pid = fork()) < 0) {
close(p[0]);
close(p[1]);
return -1;
}
if (!pid) // do_cgm_get exits
do_cgm_get(name, lxcpath, file... | null | 0 | static int cgm_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath)
{
pid_t pid;
int p[2], ret, newlen, readlen;
if (pipe(p) < 0)
return -1;
if ((pid = fork()) < 0) {
close(p[0]);
close(p[1]);
return -1;
}
if (!pid) // do_cgm_get exits
do_cgm_get(name, lxcpath, file... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,680 | static const char *cgm_get_cgroup(void *hdata, const char *subsystem)
{
struct cgm_data *d = hdata;
if (!d || !d->cgroup_path)
return NULL;
return d->cgroup_path;
}
| null | 0 | static const char *cgm_get_cgroup(void *hdata, const char *subsystem)
{
struct cgm_data *d = hdata;
if (!d || !d->cgroup_path)
return NULL;
return d->cgroup_path;
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,681 | static int cgm_get_nrtasks(void *hdata)
{
struct cgm_data *d = hdata;
int32_t *pids;
size_t pids_len;
if (!d || !d->cgroup_path)
return -1;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return -1;
}
if (cgmanager_get_tasks_sync(NULL, cgroup_manager, subsystems[0],
d->cg... | null | 0 | static int cgm_get_nrtasks(void *hdata)
{
struct cgm_data *d = hdata;
int32_t *pids;
size_t pids_len;
if (!d || !d->cgroup_path)
return -1;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return -1;
}
if (cgmanager_get_tasks_sync(NULL, cgroup_manager, subsystems[0],
d->cg... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,682 | void cgm_lock(void)
{
lock_mutex(&cgm_mutex);
}
| null | 0 | void cgm_lock(void)
{
lock_mutex(&cgm_mutex);
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,683 | static bool cgm_mount_cgroup(void *hdata, const char *root, int type)
{
if (dir_exists(CGMANAGER_LOWER_SOCK))
return cgm_bind_dir(root, CGMANAGER_LOWER_SOCK);
if (dir_exists(CGMANAGER_UPPER_SOCK))
return cgm_bind_dir(root, CGMANAGER_UPPER_SOCK);
return false;
}
| null | 0 | static bool cgm_mount_cgroup(void *hdata, const char *root, int type)
{
if (dir_exists(CGMANAGER_LOWER_SOCK))
return cgm_bind_dir(root, CGMANAGER_LOWER_SOCK);
if (dir_exists(CGMANAGER_UPPER_SOCK))
return cgm_bind_dir(root, CGMANAGER_UPPER_SOCK);
return false;
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,684 | struct cgroup_ops *cgm_ops_init(void)
{
if (!collect_subsytems())
return NULL;
if (!cgm_dbus_connect())
goto err1;
if (geteuid() == 0 && !lxc_cgmanager_escape())
goto err2;
cgm_dbus_disconnect();
return &cgmanager_ops;
err2:
cgm_dbus_disconnect();
err1:
free_subsystems();
return NULL;
}
| null | 0 | struct cgroup_ops *cgm_ops_init(void)
{
if (!collect_subsytems())
return NULL;
if (!cgm_dbus_connect())
goto err1;
if (geteuid() == 0 && !lxc_cgmanager_escape())
goto err2;
cgm_dbus_disconnect();
return &cgmanager_ops;
err2:
cgm_dbus_disconnect();
err1:
free_subsystems();
return NULL;
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,685 | static void cgm_remove_cgroup(const char *controller, const char *path)
{
int existed;
if ( cgmanager_remove_sync(NULL, cgroup_manager, controller,
path, CG_REMOVE_RECURSIVE, &existed) != 0) {
NihError *nerr;
nerr = nih_error_get();
ERROR("call to cgmanager_remove_sync failed: %s", nerr->message);
nih_... | null | 0 | static void cgm_remove_cgroup(const char *controller, const char *path)
{
int existed;
if ( cgmanager_remove_sync(NULL, cgroup_manager, controller,
path, CG_REMOVE_RECURSIVE, &existed) != 0) {
NihError *nerr;
nerr = nih_error_get();
ERROR("call to cgmanager_remove_sync failed: %s", nerr->message);
nih_... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,686 | static int cgm_set(const char *filename, const char *value, const char *name, const char *lxcpath)
{
pid_t pid;
int p[2], ret, v;
if (pipe(p) < 0)
return -1;
if ((pid = fork()) < 0) {
close(p[1]);
close(p[0]);
return -1;
}
if (!pid) // do_cgm_set exits
do_cgm_set(name, lxcpath, filename, value, p[1]);
... | null | 0 | static int cgm_set(const char *filename, const char *value, const char *name, const char *lxcpath)
{
pid_t pid;
int p[2], ret, v;
if (pipe(p) < 0)
return -1;
if ((pid = fork()) < 0) {
close(p[1]);
close(p[0]);
return -1;
}
if (!pid) // do_cgm_set exits
do_cgm_set(name, lxcpath, filename, value, p[1]);
... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,687 | static bool cgm_setup_limits(void *hdata, struct lxc_list *cgroup_settings, bool do_devices)
{
struct cgm_data *d = hdata;
struct lxc_list *iterator, *sorted_cgroup_settings, *next;
struct lxc_cgroup *cg;
bool ret = false;
if (lxc_list_empty(cgroup_settings))
return true;
if (!d || !d->cgroup_path)
return f... | null | 0 | static bool cgm_setup_limits(void *hdata, struct lxc_list *cgroup_settings, bool do_devices)
{
struct cgm_data *d = hdata;
struct lxc_list *iterator, *sorted_cgroup_settings, *next;
struct lxc_cgroup *cg;
bool ret = false;
if (lxc_list_empty(cgroup_settings))
return true;
if (!d || !d->cgroup_path)
return f... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,688 | static bool cgm_unfreeze(void *hdata)
{
struct cgm_data *d = hdata;
bool ret = true;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (cgmanager_set_value_sync(NULL, cgroup_manager, "freezer", d->cgroup_path,
"freezer.st... | null | 0 | static bool cgm_unfreeze(void *hdata)
{
struct cgm_data *d = hdata;
bool ret = true;
if (!d || !d->cgroup_path)
return false;
if (!cgm_dbus_connect()) {
ERROR("Error connecting to cgroup manager");
return false;
}
if (cgmanager_set_value_sync(NULL, cgroup_manager, "freezer", d->cgroup_path,
"freezer.st... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,689 | void cgm_unlock(void)
{
unlock_mutex(&cgm_mutex);
}
| null | 0 | void cgm_unlock(void)
{
unlock_mutex(&cgm_mutex);
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,690 | static void check_supports_multiple_controllers(pid_t pid)
{
FILE *f;
char *line = NULL, *prevpath = NULL;
size_t sz = 0;
char path[100];
cgm_supports_multiple_controllers = false;
cgm_all_controllers_same = false;
if (api_version < CGM_SUPPORTS_MULT_CONTROLLERS) {
cgm_supports_multiple_controllers = false;
... | null | 0 | static void check_supports_multiple_controllers(pid_t pid)
{
FILE *f;
char *line = NULL, *prevpath = NULL;
size_t sz = 0;
char path[100];
cgm_supports_multiple_controllers = false;
cgm_all_controllers_same = false;
if (api_version < CGM_SUPPORTS_MULT_CONTROLLERS) {
cgm_supports_multiple_controllers = false;
... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,691 | static bool chown_cgroup(const char *cgroup_path, struct lxc_conf *conf)
{
struct chown_data data;
char **slist = subsystems;
int i;
if (lxc_list_empty(&conf->id_map))
/* If there's no mapping then we don't need to chown */
return true;
data.cgroup_path = cgroup_path;
data.origuid = geteuid();
/* Unpriv u... | null | 0 | static bool chown_cgroup(const char *cgroup_path, struct lxc_conf *conf)
{
struct chown_data data;
char **slist = subsystems;
int i;
if (lxc_list_empty(&conf->id_map))
/* If there's no mapping then we don't need to chown */
return true;
data.cgroup_path = cgroup_path;
data.origuid = geteuid();
/* Unpriv u... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,692 | static int chown_cgroup_wrapper(void *data)
{
struct chown_data *arg = data;
char **slist = subsystems;
int i, ret = -1;
uid_t destuid;
if (setresgid(0,0,0) < 0)
SYSERROR("Failed to setgid to 0");
if (setresuid(0,0,0) < 0)
SYSERROR("Failed to setuid to 0");
if (setgroups(0, NULL) < 0)
SYSERROR("Failed to ... | null | 0 | static int chown_cgroup_wrapper(void *data)
{
struct chown_data *arg = data;
char **slist = subsystems;
int i, ret = -1;
uid_t destuid;
if (setresgid(0,0,0) < 0)
SYSERROR("Failed to setgid to 0");
if (setresuid(0,0,0) < 0)
SYSERROR("Failed to setuid to 0");
if (setgroups(0, NULL) < 0)
SYSERROR("Failed to ... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,693 | static inline void cleanup_cgroups(char *path)
{
int i;
char **slist = subsystems;
if (cgm_supports_multiple_controllers)
slist = subsystems_inone;
for (i = 0; slist[i]; i++)
cgm_remove_cgroup(slist[i], path);
}
| null | 0 | static inline void cleanup_cgroups(char *path)
{
int i;
char **slist = subsystems;
if (cgm_supports_multiple_controllers)
slist = subsystems_inone;
for (i = 0; slist[i]; i++)
cgm_remove_cgroup(slist[i], path);
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,694 | static bool collect_subsytems(void)
{
char *line = NULL;
nih_local char **cgm_subsys_list = NULL;
size_t sz = 0;
FILE *f = NULL;
if (subsystems) // already initialized
return true;
subsystems_inone = malloc(2 * sizeof(char *));
if (!subsystems_inone)
return false;
subsystems_inone[0] = "all";
subsystems_... | null | 0 | static bool collect_subsytems(void)
{
char *line = NULL;
nih_local char **cgm_subsys_list = NULL;
size_t sz = 0;
FILE *f = NULL;
if (subsystems) // already initialized
return true;
subsystems_inone = malloc(2 * sizeof(char *));
if (!subsystems_inone)
return false;
subsystems_inone[0] = "all";
subsystems_... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,695 | static void cull_user_controllers(void)
{
int i, j;
for (i = 0; i < nr_subsystems; i++) {
if (strncmp(subsystems[i], "name=", 5) != 0)
continue;
for (j = i; j < nr_subsystems-1; j++)
subsystems[j] = subsystems[j+1];
nr_subsystems--;
}
}
| null | 0 | static void cull_user_controllers(void)
{
int i, j;
for (i = 0; i < nr_subsystems; i++) {
if (strncmp(subsystems[i], "name=", 5) != 0)
continue;
for (j = i; j < nr_subsystems-1; j++)
subsystems[j] = subsystems[j+1];
nr_subsystems--;
}
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,696 | static void do_cgm_get(const char *name, const char *lxcpath, const char *filename, int outp, bool sendvalue)
{
char *controller, *key, *cgroup = NULL, *cglast;
int len = -1;
int ret;
nih_local char *result = NULL;
controller = alloca(strlen(filename)+1);
strcpy(controller, filename);
key = strchr(controller, '... | null | 0 | static void do_cgm_get(const char *name, const char *lxcpath, const char *filename, int outp, bool sendvalue)
{
char *controller, *key, *cgroup = NULL, *cglast;
int len = -1;
int ret;
nih_local char *result = NULL;
controller = alloca(strlen(filename)+1);
strcpy(controller, filename);
key = strchr(controller, '... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,697 | static void do_cgm_set(const char *name, const char *lxcpath, const char *filename, const char *value, int outp)
{
char *controller, *key, *cgroup = NULL;
int retval = 0; // value we are sending to the parent over outp
int ret;
char *cglast;
controller = alloca(strlen(filename)+1);
strcpy(controller, filename);... | null | 0 | static void do_cgm_set(const char *name, const char *lxcpath, const char *filename, const char *value, int outp)
{
char *controller, *key, *cgroup = NULL;
int retval = 0; // value we are sending to the parent over outp
int ret;
char *cglast;
controller = alloca(strlen(filename)+1);
strcpy(controller, filename);... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,698 | static int do_chown_cgroup(const char *controller, const char *cgroup_path,
uid_t newuid)
{
int sv[2] = {-1, -1}, optval = 1, ret = -1;
char buf[1];
struct pollfd fds;
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) < 0) {
SYSERROR("Error creating socketpair");
goto out;
}
if (setsockopt(sv[1], SOL_SOCKET, SO_P... | null | 0 | static int do_chown_cgroup(const char *controller, const char *cgroup_path,
uid_t newuid)
{
int sv[2] = {-1, -1}, optval = 1, ret = -1;
char buf[1];
struct pollfd fds;
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) < 0) {
SYSERROR("Error creating socketpair");
goto out;
}
if (setsockopt(sv[1], SOL_SOCKET, SO_P... | @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
35,699 | static inline void free_abs_cgroup(char *cgroup)
{
if (!cgroup)
return;
if (abs_cgroup_supported())
nih_free(cgroup);
else
free(cgroup);
}
| null | 0 | static inline void free_abs_cgroup(char *cgroup)
{
if (!cgroup)
return;
if (abs_cgroup_supported())
nih_free(cgroup);
else
free(cgroup);
}
| @@ -1477,7 +1477,7 @@ static bool cgm_bind_dir(const char *root, const char *dirname)
}
/* mount a tmpfs there so we can create subdirs */
- if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
+ if (safe_mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755", root)) {
SYSERROR("Failed to mount... | CWE-59 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.