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

Side by Side Diff: sandbox/linux/seccomp/library.h

Issue 1294001: Make the seccomp sandbox compatible with tcmalloc:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef LIBRARY_H__ 5 #ifndef LIBRARY_H__
6 #define LIBRARY_H__ 6 #define LIBRARY_H__
7 7
8 #include <elf.h> 8 #include <elf.h>
9 #include <functional>
9 #include <map> 10 #include <map>
10 #include <set> 11 #include <set>
11 #include <string> 12 #include <string>
12 #include <string.h> 13 #include <string.h>
13 #include <sys/mman.h> 14 #include <sys/mman.h>
14 15
15 #include "maps.h" 16 #include "maps.h"
16 17
17 #if defined(__x86_64__) 18 #if defined(__x86_64__)
18 typedef Elf64_Ehdr Elf_Ehdr; 19 typedef Elf64_Ehdr Elf_Ehdr;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 const int getSectionIndex(const string& section); 129 const int getSectionIndex(const string& section);
129 void makeWritable(bool state) const; 130 void makeWritable(bool state) const;
130 void patchSystemCalls(); 131 void patchSystemCalls();
131 bool isVDSO() const { return isVDSO_; } 132 bool isVDSO() const { return isVDSO_; }
132 133
133 protected: 134 protected:
134 bool parseSymbols(); 135 bool parseSymbols();
135 136
136 private: 137 private:
137 class GreaterThan : public std::binary_function<Elf_Addr, Elf_Addr, bool> { 138 class GreaterThan : public std::binary_function<Elf_Addr, Elf_Addr, bool> {
139 // We create the RangeMap with a GreaterThan rather than the default
140 // comparator, as that allows us to use lower_bound() to find memory
141 // mappings.
138 public: 142 public:
139 bool operator() (Elf_Addr s1, Elf_Addr s2) const { 143 bool operator() (Elf_Addr s1, Elf_Addr s2) const {
140 return s1 > s2; 144 return s1 > s2;
141 } 145 }
142 }; 146 };
143 147
144 struct Range { 148 struct Range {
145 Range(void* start, void* stop, int prot) : 149 Range(void* start, void* stop, int prot) :
146 start(start), stop(stop), prot(prot) { } 150 start(start), stop(stop), prot(prot) { }
147 void* start; 151 void* start;
148 void* stop; 152 void* stop;
149 int prot; 153 int prot;
150 }; 154 };
151 155
152 typedef std::map<Elf_Addr, Range, GreaterThan> RangeMap; 156 typedef std::map<Elf_Addr, Range, GreaterThan,
153 typedef std::map<string, std::pair<int, Elf_Shdr> > SectionTable; 157 SystemAllocator<std::pair<const Elf_Addr,
154 typedef std::map<string, Elf_Sym> SymbolTable; 158 Range> > > RangeMap;
155 typedef std::map<string, Elf_Addr> PltTable; 159 typedef std::map<string, std::pair<int, Elf_Shdr>, std::less<string>,
160 SystemAllocator<std::pair<const string,
161 std::pair<int, Elf_Shdr> > > >
162 SectionTable;
163 typedef std::map<string, Elf_Sym, std::less<string>,
164 SystemAllocator<std::pair<const string,
165 Elf_Sym> > > SymbolTable;
166 typedef std::map<string, Elf_Addr, std::less<string>,
167 SystemAllocator<std::pair<const string,
168 Elf_Addr> > > PltTable;
156 169
157 char* getBytes(char* dst, const char* src, ssize_t len); 170 char* getBytes(char* dst, const char* src, ssize_t len);
158 static bool isSafeInsn(unsigned short insn); 171 static bool isSafeInsn(unsigned short insn);
159 static int isSimpleSystemCall(char *start, char *end); 172 static int isSimpleSystemCall(char *start, char *end);
160 static char* getScratchSpace(const Maps* maps, char* near, int needed, 173 static char* getScratchSpace(const Maps* maps, char* near, int needed,
161 char** extraSpace, int* extraLength); 174 char** extraSpace, int* extraLength);
162 void patchSystemCallsInFunction(const Maps* maps, char *start, char *end, 175 void patchSystemCallsInFunction(const Maps* maps, char *start, char *end,
163 char** extraSpace, int* extraLength); 176 char** extraSpace, int* extraLength);
164 int patchVSystemCalls(); 177 int patchVSystemCalls();
165 void patchVDSO(char** extraSpace, int* extraLength); 178 void patchVDSO(char** extraSpace, int* extraLength);
(...skipping 11 matching lines...) Expand all
177 char* image_; 190 char* image_;
178 size_t image_size_; 191 size_t image_size_;
179 static char* __kernel_vsyscall; 192 static char* __kernel_vsyscall;
180 static char* __kernel_sigreturn; 193 static char* __kernel_sigreturn;
181 static char* __kernel_rt_sigreturn; 194 static char* __kernel_rt_sigreturn;
182 }; 195 };
183 196
184 } // namespace 197 } // namespace
185 198
186 #endif // LIBRARY_H__ 199 #endif // LIBRARY_H__
OLDNEW
« no previous file with comments | « no previous file | sandbox/linux/seccomp/maps.h » ('j') | third_party/tcmalloc/chromium/src/base/spinlock_linux-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698