Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: sandbox/linux/seccomp-bpf/sandbox_bpf.cc

Issue 10542028: Explicitly test bit 30 in the system call number to distinguish between the new x32 API and older I… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/seccomp-bpf/sandbox_bpf.cc
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
index a60b2080827704c9ffeaef8dff00c7cfb7b7a866..f07327fa320ad039d5f04cb4317404804d9ef288 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf.cc
@@ -215,8 +215,7 @@ void Sandbox::installFilter() {
// system call.
std::vector<struct sock_filter> program;
program.push_back((struct sock_filter)
- BPF_STMT(BPF_LD+BPF_W+BPF_ABS,
- offsetof(struct arch_seccomp_data, arch)));
+ BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct arch_seccomp_data, arch)));
program.push_back((struct sock_filter)
BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, SECCOMP_ARCH, 1, 0));
program.push_back((struct sock_filter)
@@ -226,6 +225,21 @@ void Sandbox::installFilter() {
program.push_back((struct sock_filter)
BPF_STMT(BPF_LD+BPF_W+BPF_ABS, offsetof(struct arch_seccomp_data, nr)));
+ // On Intel architectures, verify that system call numbers are in the
+ // expected number range. The older i386 and x86-64 APIs clear bit 30
+ // on all system calls. The newer x86-32 API always sets bit 30.
+#if defined(__i386__) || defined(__x86_64__)
Chris Evans 2012/06/07 01:02:38 I don't quite get this bit. If we're compiling for
Markus (顧孟勤) 2012/06/07 01:33:28 The preprocessor tests check for the expected API
+#if defined(__x86_64__) && defined(__ILP32__)
+ program.push_back((struct sock_filter)
+ BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 0x40000000, 1, 0));
+#else
+ program.push_back((struct sock_filter)
+ BPF_JUMP(BPF_JMP+BPF_JSET+BPF_K, 0x40000000, 0, 1));
+#endif
+ program.push_back((struct sock_filter)
+ BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ERRNO + SECCOMP_DENY_ERRNO));
Chris Evans 2012/06/07 01:02:38 If we get here, seems like something extraordinari
Markus (顧孟勤) 2012/06/07 01:33:28 Let me know, what you prefer until we get a better
+#endif
+
// Evaluate all possible system calls and depending on their
// exit codes generate a BPF filter.
// This is very inefficient right now. We need to be much smarter
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698