SCMP_SYS(mprotect),
SCMP_SYS(mremap),
SCMP_SYS(munmap),
- SCMP_SYS(openat),
SCMP_SYS(poll),
SCMP_SYS(prctl),
SCMP_SYS(read),
};
const char*
-sandbox_intern_string(char *param)
+sandbox_intern_string(const char *param)
{
int i, filter_size;
sandbox_cfg_t *elem;
int
sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file)
{
- sandbox_cfg_t *elem = (sandbox_cfg_t*) malloc(sizeof(sandbox_cfg_t));
+ sandbox_cfg_t *elem = NULL;
+ intptr_t prot_str = (intptr_t) prot_strdup((char*) file);
+ elem = (sandbox_cfg_t*) malloc(sizeof(sandbox_cfg_t));
elem->syscall = SCMP_SYS(open);
elem->pindex = 0;
elem->ptype = PARAM_PTR;
- elem->param = (intptr_t) prot_strdup((char*) file);
+ elem->param = prot_str;
elem->prot = 1;
+ elem->next = filter_dynamic;
+ filter_dynamic = elem;
- // fifo
+ // also allow openat
+ elem = (sandbox_cfg_t*) malloc(sizeof(sandbox_cfg_t));
+ elem->syscall = SCMP_SYS(openat);
+ elem->pindex = 1;
+ elem->ptype = PARAM_PTR;
+ elem->param = prot_str;
+ elem->prot = 1;
elem->next = filter_dynamic;
filter_dynamic = elem;
*/
#ifdef __linux__
+#ifndef __USE_GNU
#define __USE_GNU
+#endif
#include <sys/ucontext.h>
#define MAX_PARAM_LEN 64
void sandbox_set_debugging_fd(int fd);
int tor_global_sandbox(void);
-const char* sandbox_intern_string(char *param);
+const char* sandbox_intern_string(const char *param);
sandbox_cfg_t * sandbox_cfg_new();
int sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file);
#include "torint.h"
#include "container.h"
#include "address.h"
+#include "../common/sandbox.h"
#ifdef _WIN32
#include <io.h>
tor_listdir(const char *dirname)
{
smartlist_t *result;
+ const char *prot_dname = sandbox_intern_string(dirname);
#ifdef _WIN32
char *pattern=NULL;
TCHAR tpattern[MAX_PATH] = {0};
#else
DIR *d;
struct dirent *de;
- if (!(d = opendir(dirname)))
+ if (!(d = opendir(prot_dname)))
return NULL;
result = smartlist_new();
{
sandbox_cfg_t *cfg = sandbox_cfg_new();
+ sandbox_cfg_allow_open_filename(&cfg,
+ get_datadir_fname("cached-status"));
sandbox_cfg_allow_open_filename(&cfg,
get_datadir_fname("cached-certs"));
sandbox_cfg_allow_open_filename(&cfg,