| Index: sandbox/linux/seccomp/library.h
|
| ===================================================================
|
| --- sandbox/linux/seccomp/library.h (revision 39965)
|
| +++ sandbox/linux/seccomp/library.h (working copy)
|
| @@ -1,3 +1,7 @@
|
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| #ifndef LIBRARY_H__
|
| #define LIBRARY_H__
|
|
|
| @@ -30,6 +34,8 @@
|
| class Library {
|
| friend class Maps;
|
| public:
|
| + typedef Maps::string string;
|
| +
|
| Library() :
|
| valid_(false),
|
| isVDSO_(false),
|
| @@ -50,14 +56,24 @@
|
|
|
| void addMemoryRange(void* start, void* stop, Elf_Addr offset,
|
| int prot, int isVDSO) {
|
| + isVDSO_ = isVDSO;
|
| + RangeMap::const_iterator iter = memory_ranges_.find(offset);
|
| + if (iter != memory_ranges_.end()) {
|
| + // It is possible to have overlapping mappings. This is particularly
|
| + // likely to happen with very small programs or libraries. If it does
|
| + // happen, we really only care about the text segment. Look for a
|
| + // mapping that is mapped executable.
|
| + if ((prot & PROT_EXEC) == 0) {
|
| + return;
|
| + }
|
| + }
|
| memory_ranges_.insert(std::make_pair(offset, Range(start, stop, prot)));
|
| - isVDSO_ = isVDSO;
|
| }
|
|
|
| char *get(Elf_Addr offset, char *buf, size_t len);
|
| - std::string get(Elf_Addr offset);
|
| + string get(Elf_Addr offset);
|
| char *getOriginal(Elf_Addr offset, char *buf, size_t len);
|
| - std::string getOriginal(Elf_Addr offset);
|
| + string getOriginal(Elf_Addr offset);
|
|
|
| template<class T>T* get(Elf_Addr offset, T* t) {
|
| if (!valid_) {
|
| @@ -108,10 +124,8 @@
|
|
|
| bool parseElf();
|
| const Elf_Ehdr* getEhdr();
|
| - const Elf_Shdr* getSection(const std::string& section);
|
| - const int getSectionIndex(const std::string& section);
|
| - void **getRelocation(const std::string& symbol);
|
| - void *getSymbol(const std::string& symbol);
|
| + const Elf_Shdr* getSection(const string& section);
|
| + const int getSectionIndex(const string& section);
|
| void makeWritable(bool state) const;
|
| void patchSystemCalls();
|
| bool isVDSO() const { return isVDSO_; }
|
| @@ -136,9 +150,9 @@
|
| };
|
|
|
| typedef std::map<Elf_Addr, Range, GreaterThan> RangeMap;
|
| - typedef std::map<std::string, std::pair<int, Elf_Shdr> > SectionTable;
|
| - typedef std::map<std::string, Elf_Sym> SymbolTable;
|
| - typedef std::map<std::string, Elf_Addr> PltTable;
|
| + typedef std::map<string, std::pair<int, Elf_Shdr> > SectionTable;
|
| + typedef std::map<string, Elf_Sym> SymbolTable;
|
| + typedef std::map<string, Elf_Addr> PltTable;
|
|
|
| char* getBytes(char* dst, const char* src, ssize_t len);
|
| static bool isSafeInsn(unsigned short insn);
|
|
|