Skip to content

Commit

Permalink
Backed out 5 changesets (bug 1662564, bug 1664922, bug 1440203) for V…
Browse files Browse the repository at this point in the history
…algrind bustages. CLOSED TREE

Backed out changeset 9366b15ee97c (bug 1440203)
Backed out changeset bb512f5fdeda (bug 1440203)
Backed out changeset be90d6aec690 (bug 1664922)
Backed out changeset f6527a1d0f14 (bug 1662564)
Backed out changeset 3a2941fa7d4b (bug 1662564)
  • Loading branch information
Razvan Maries committed Oct 7, 2020
1 parent dcaf015 commit a03d69f
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -809,14 +809,6 @@ add_task(async function() {
continue;
}

// "Files" from memfd_create() are similar to tmpfs but never
// exist in the filesystem; however, they have names which are
// exposed in procfs, and the I/O interposer observes when
// they're close()d.
if (LINUX && filename.startsWith("/memfd:")) {
continue;
}

// Shared memory uses temporary files on MacOS <= 10.11 to avoid
// a kernel security bug that will never be patched (see
// https://crbug.com/project-zero/1671 for details). This can
Expand Down
8 changes: 0 additions & 8 deletions build/moz.configure/headers.configure
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ check_headers(
'byteswap.h',
)

# memfd_create(2) -- Note that older versions of the Linux man-pages
# project incorrectly cite <sys/memfd.h>, which doesn't exist; this
# was fixed in the man-pages-5.00 release.
set_define('HAVE_MEMFD_CREATE',
try_compile(includes=['sys/mman.h'],
body='memfd_create("", 0);',
check_msg='for memfd_create in sys/mman.h'))

# TODO: Move these checks to file specific to --enable-project=js.
have_perf_event_h = check_header('linux/perf_event.h',
when=building_linux)
Expand Down
5 changes: 0 additions & 5 deletions config/system-headers.mozbuild
Original file line number Diff line number Diff line change
Expand Up @@ -1349,10 +1349,5 @@ if CONFIG['OS_TARGET'] == 'Linux' and CONFIG['CPU_ARCH'].startswith('mips'):
'sys/cachectl.h',
]

if CONFIG['OS_TARGET'] == 'FreeBSD':
system_headers += [
'sys/capsicum.h',
]

if CONFIG['MOZ_APP_SYSTEM_HEADERS']:
include("../" + CONFIG['MOZ_BUILD_APP'] + "/app-system-headers.mozbuild")
69 changes: 0 additions & 69 deletions ipc/chromium/src/base/linux_memfd_defs.h

This file was deleted.

55 changes: 19 additions & 36 deletions ipc/chromium/src/base/shared_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef FileDescriptor SharedMemoryHandle;
class SharedMemory {
public:
// Create a new SharedMemory object.
SharedMemory() = default;
SharedMemory();

// Create a new SharedMemory object from an existing, open
// shared memory file.
Expand All @@ -46,7 +46,7 @@ class SharedMemory {
}

// Move constructor; transfers ownership.
SharedMemory(SharedMemory&& other) = default;
SharedMemory(SharedMemory&& other);

// Destructor. Will close any open files.
~SharedMemory();
Expand All @@ -60,7 +60,7 @@ class SharedMemory {
static bool IsHandleValid(const SharedMemoryHandle& handle);

// IsHandleValid applied to this object's handle.
bool IsValid() const { return static_cast<bool>(mapped_file_); }
bool IsValid() const;

// Return invalid handle (see comment above for exact definition).
static SharedMemoryHandle NULLHandle();
Expand All @@ -85,7 +85,9 @@ class SharedMemory {
bool Map(size_t bytes, void* fixed_address = nullptr);

// Unmaps the shared memory from the caller's address space.
void Unmap() { memory_ = nullptr; }
// Returns true if successful; returns false on error or if the
// memory is not mapped.
bool Unmap();

// Get the size of the opened shared memory backing file.
// Note: This size is only available to the creator of the
Expand All @@ -96,24 +98,19 @@ class SharedMemory {

// Gets a pointer to the opened memory space if it has been
// Mapped via Map(). Returns NULL if it is not mapped.
void* memory() const { return memory_.get(); }
void* memory() const { return memory_; }

// Extracts the underlying file handle; similar to
// GiveToProcess(GetCurrentProcId(), ...) but returns a RAII type.
// Like GiveToProcess, this unmaps the memory as a side-effect (and
// cleans up any OS-specific resources).
mozilla::UniqueFileHandle TakeHandle() {
mozilla::UniqueFileHandle handle = std::move(mapped_file_);
Close();
return handle;
}
// Like GiveToProcess, this unmaps the memory as a side-effect.
mozilla::UniqueFileHandle TakeHandle();

#ifdef OS_WIN
// Used only in gfx/ipc/SharedDIBWin.cpp; should be removable once
// NPAPI goes away.
HANDLE GetHandle() {
freezeable_ = false;
return mapped_file_.get();
return mapped_file_;
}
#endif

Expand Down Expand Up @@ -194,34 +191,20 @@ class SharedMemory {

bool CreateInternal(size_t size, bool freezeable);

// Unmapping shared memory requires the mapped size on Unix but not
// Windows; this encapsulates that difference.
struct MappingDeleter {
#ifdef OS_POSIX
// A default-constructed deleter must be used only with nullptr
// (to allow default-constructing UniqueMapping). A deleter with
// a size must be used at most once.
size_t mapped_size_ = 0;
explicit MappingDeleter(size_t size) : mapped_size_(size) {}
#endif
MappingDeleter() = default;
void operator()(void* ptr);
};
using UniqueMapping = mozilla::UniquePtr<void, MappingDeleter>;

UniqueMapping memory_;
size_t max_size_ = 0;
mozilla::UniqueFileHandle mapped_file_;
#if defined(OS_WIN)
// If true indicates this came from an external source so needs extra checks
// before being mapped.
bool external_section_ = false;
bool external_section_;
HANDLE mapped_file_;
#elif defined(OS_POSIX)
mozilla::UniqueFileHandle frozen_file_;
bool is_memfd_ = false;
int mapped_file_;
int frozen_file_;
size_t mapped_size_;
#endif
bool read_only_ = false;
bool freezeable_ = false;
void* memory_;
bool read_only_;
bool freezeable_;
size_t max_size_;

DISALLOW_EVIL_CONSTRUCTORS(SharedMemory);
};
Expand Down
Loading

0 comments on commit a03d69f

Please sign in to comment.