Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
7cf1dbfd
Commit
7cf1dbfd
authored
11 years ago
by
Cristian Toader
Browse files
Options
Downloads
Patches
Plain Diff
changed paramfilter type to intptr_t
parent
8dfa5772
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/sandbox.c
+9
-9
9 additions, 9 deletions
src/common/sandbox.c
src/common/sandbox.h
+3
-1
3 additions, 1 deletion
src/common/sandbox.h
with
12 additions
and
10 deletions
src/common/sandbox.c
+
9
−
9
View file @
7cf1dbfd
...
...
@@ -34,8 +34,8 @@
static
ParFilter
param_filter
[]
=
{
// Example entries
{
SCMP_SYS
(
execve
),
"/usr/local/bin/tor"
,
0
},
{
SCMP_SYS
(
execve
),
"/usr/local/bin/tor"
,
0
}
{
SCMP_SYS
(
execve
),
(
intptr_t
)(
"/usr/local/bin/tor"
)
,
0
},
{
SCMP_SYS
(
execve
),
(
intptr_t
)(
"/usr/local/bin/tor"
)
,
0
}
};
/** Variable used for storing all syscall numbers that will be allowed with the
...
...
@@ -165,9 +165,9 @@ get_prot_param(char *param)
}
for
(
i
=
0
;
i
<
filter_size
;
i
++
)
{
if
(
param_filter
[
i
].
prot
&&
!
strncmp
(
param
,
param_filter
[
i
].
param
,
if
(
param_filter
[
i
].
prot
&&
!
strncmp
(
param
,
(
char
*
)
param_filter
[
i
].
param
,
MAX_PARAM_LEN
))
{
return
param_filter
[
i
].
param
;
return
(
char
*
)(
param_filter
[
i
].
param
)
;
}
}
...
...
@@ -190,7 +190,7 @@ add_param_filter(scmp_filter_ctx ctx)
for
(
i
=
0
;
i
<
filter_size
;
i
++
)
{
if
(
!
param_filter
[
i
].
prot
)
{
// allocating protected memory region for parameter
param_size
=
1
+
strnlen
(
param_filter
[
i
].
param
,
MAX_PARAM_LEN
);
param_size
=
1
+
strnlen
(
(
char
*
)
param_filter
[
i
].
param
,
MAX_PARAM_LEN
);
if
(
param_size
==
MAX_PARAM_LEN
)
{
log_warn
(
LD_BUG
,
"(Sandbox) Parameter %i length too large!"
,
i
);
}
...
...
@@ -203,18 +203,18 @@ add_param_filter(scmp_filter_ctx ctx)
}
// copying from non protected to protected + pointer reassign
memcpy
(
map
,
param_filter
[
i
].
param
,
param_size
);
param_filter
[
i
].
param
=
map
;
memcpy
(
map
,
(
char
*
)
param_filter
[
i
].
param
,
param_size
);
param_filter
[
i
].
param
=
(
intptr_t
)
map
;
// protecting from writes
if
(
mprotect
(
param_filter
[
i
].
param
,
param_size
,
PROT_READ
))
{
if
(
mprotect
(
(
char
*
)
param_filter
[
i
].
param
,
param_size
,
PROT_READ
))
{
log_err
(
LD_BUG
,
"(Sandbox) failed to protect memory!"
);
return
-
1
;
}
}
// if not protected
rc
=
seccomp_rule_add
(
ctx
,
SCMP_ACT_ALLOW
,
param_filter
[
i
].
syscall
,
1
,
SCMP_A0
(
SCMP_CMP_EQ
,
(
intptr_t
)
param_filter
[
i
].
param
));
SCMP_A0
(
SCMP_CMP_EQ
,
param_filter
[
i
].
param
));
if
(
rc
!=
0
)
{
log_err
(
LD_BUG
,
"(Sandbox) failed to add syscall index %d, "
"received libseccomp error %d"
,
i
,
rc
);
...
...
This diff is collapsed.
Click to expand it.
src/common/sandbox.h
+
3
−
1
View file @
7cf1dbfd
...
...
@@ -22,6 +22,8 @@
#endif
#include
"torint.h"
/**
* Linux definitions
*/
...
...
@@ -34,7 +36,7 @@
typedef
struct
{
int
syscall
;
char
*
param
;
intptr_t
param
;
// TODO: make this intptr_t to support multiple types
char
prot
;
}
ParFilter
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment