summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2020-01-30 07:55:09 +1000
committerteor <teor@torproject.org>2020-01-30 07:55:09 +1000
commitd211b20fbf80c03818d99e99d68e5ae8a3884295 (patch)
tree417d2545015dfc9a82b11487648d67f2ac666ba0
parent2be3b8275062e34ef6a2c8d753a01b3137de739e (diff)
parent6b392c333a854bb4d18ae6ea1686627451bb03f8 (diff)
downloadtor-d211b20fbf80c03818d99e99d68e5ae8a3884295.tar.gz
tor-d211b20fbf80c03818d99e99d68e5ae8a3884295.zip
Merge branch 'maint-0.4.1' into release-0.4.1
-rw-r--r--changes/bug298198
-rw-r--r--changes/bug327783
-rw-r--r--src/app/main/main.c4
-rw-r--r--src/app/main/main.h3
-rw-r--r--src/app/main/ntmain.c7
-rw-r--r--src/lib/sandbox/sandbox.c40
6 files changed, 25 insertions, 40 deletions
diff --git a/changes/bug29819 b/changes/bug29819
new file mode 100644
index 0000000000..d37ac83d66
--- /dev/null
+++ b/changes/bug29819
@@ -0,0 +1,8 @@
+ o Minor bugfixes (linux seccomp sandbox):
+ - Correct how we use libseccomp. Particularly, stop assuming that
+ rules are applied in a particular order or that more rules are
+ processed after the first match. Neither is the case! In libseccomp
+ <2.4.0 this lead to some rules having no effect. Libseccomp 2.4.0
+ changed how rules are generated leading to a different ordering
+ which in turn lead to a fatal crash during startup. Fixes bug
+ 29819; bugfix on 0.2.5.1-alpha. Patch by Peter Gerber.
diff --git a/changes/bug32778 b/changes/bug32778
new file mode 100644
index 0000000000..ccb6104692
--- /dev/null
+++ b/changes/bug32778
@@ -0,0 +1,3 @@
+ o Minor bugfixes (windows service):
+ - Initialize publish/subscribe system when running as a windows service.
+ Fixes bug 32778; bugfix on 0.4.1.1-alpha.
diff --git a/src/app/main/main.c b/src/app/main/main.c
index 6e325f0b10..f3772f86e4 100644
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@ -1236,7 +1236,7 @@ run_tor_main_loop(void)
}
/** Install the publish/subscribe relationships for all the subsystems. */
-static void
+void
pubsub_install(void)
{
pubsub_builder_t *builder = pubsub_builder_new();
@@ -1248,7 +1248,7 @@ pubsub_install(void)
/** Connect the mainloop to its publish/subscribe message delivery events if
* appropriate, and configure the global channels appropriately. */
-static void
+void
pubsub_connect(void)
{
if (get_options()->command == CMD_RUN_TOR) {
diff --git a/src/app/main/main.h b/src/app/main/main.h
index 9dfaf4b8ef..76574a9071 100644
--- a/src/app/main/main.h
+++ b/src/app/main/main.h
@@ -25,4 +25,7 @@ int tor_init(int argc, char **argv);
int run_tor_main_loop(void);
+void pubsub_install(void);
+void pubsub_connect(void);
+
#endif /* !defined(TOR_MAIN_H) */
diff --git a/src/app/main/ntmain.c b/src/app/main/ntmain.c
index f00b712702..c5a8122030 100644
--- a/src/app/main/ntmain.c
+++ b/src/app/main/ntmain.c
@@ -283,7 +283,9 @@ nt_service_body(int argc, char **argv)
return;
}
+ pubsub_install();
r = tor_init(backup_argc, backup_argv);
+
if (r) {
/* Failed to start the Tor service */
r = NT_SERVICE_ERROR_TORINIT_FAILED;
@@ -294,6 +296,8 @@ nt_service_body(int argc, char **argv)
return;
}
+ pubsub_connect();
+
/* Set the service's status to SERVICE_RUNNING and start the main
* event loop */
service_status.dwCurrentState = SERVICE_RUNNING;
@@ -322,9 +326,12 @@ nt_service_main(void)
errmsg = format_win32_error(result);
printf("Service error %d : %s\n", (int) result, errmsg);
tor_free(errmsg);
+
+ pubsub_install();
if (result == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
if (tor_init(backup_argc, backup_argv))
return;
+ pubsub_connect();
switch (get_options()->command) {
case CMD_RUN_TOR:
run_tor_main_loop();
diff --git a/src/lib/sandbox/sandbox.c b/src/lib/sandbox/sandbox.c
index 7e6354d880..de37989fad 100644
--- a/src/lib/sandbox/sandbox.c
+++ b/src/lib/sandbox/sandbox.c
@@ -492,24 +492,6 @@ sb_open(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
}
}
- rc = seccomp_rule_add_1(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(open),
- SCMP_CMP_MASKED(1, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|O_NOFOLLOW,
- O_RDONLY));
- if (rc != 0) {
- log_err(LD_BUG,"(Sandbox) failed to add open syscall, received libseccomp "
- "error %d", rc);
- return rc;
- }
-
- rc = seccomp_rule_add_1(ctx, SCMP_ACT_ERRNO(EACCES), SCMP_SYS(openat),
- SCMP_CMP_MASKED(2, O_CLOEXEC|O_NONBLOCK|O_NOCTTY|O_NOFOLLOW,
- O_RDONLY));
- if (rc != 0) {
- log_err(LD_BUG,"(Sandbox) failed to add openat syscall, received "
- "libseccomp error %d", rc);
- return rc;
- }
-
return 0;
}
@@ -563,23 +545,6 @@ sb_chown(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
return 0;
}
-static int
-sb__sysctl(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
-{
- int rc;
- (void) filter;
- (void) ctx;
-
- rc = seccomp_rule_add_0(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(_sysctl));
- if (rc != 0) {
- log_err(LD_BUG,"(Sandbox) failed to add _sysctl syscall, "
- "received libseccomp error %d", rc);
- return rc;
- }
-
- return 0;
-}
-
/**
* Function responsible for setting up the rename syscall for
* the seccomp filter sandbox.
@@ -1148,7 +1113,6 @@ static sandbox_filter_func_t filter_func[] = {
sb_chmod,
sb_open,
sb_openat,
- sb__sysctl,
sb_rename,
#ifdef __NR_fcntl64
sb_fcntl64,
@@ -1525,14 +1489,14 @@ install_syscall_filter(sandbox_cfg_t* cfg)
int rc = 0;
scmp_filter_ctx ctx;
- ctx = seccomp_init(SCMP_ACT_TRAP);
+ ctx = seccomp_init(SCMP_ACT_ERRNO(EPERM));
if (ctx == NULL) {
log_err(LD_BUG,"(Sandbox) failed to initialise libseccomp context");
rc = -1;
goto end;
}
- // protectign sandbox parameter strings
+ // protecting sandbox parameter strings
if ((rc = prot_strings(ctx, cfg))) {
goto end;
}