mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
ldso: don't destruct Rm_area singleton in file.cc
This is needed to avoid access to invalid caps in forked noux programs. ref #989
This commit is contained in:
parent
6ca8a41232
commit
df066521a5
@ -18,6 +18,7 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <util/list.h>
|
#include <util/list.h>
|
||||||
|
#include <util/construct_at.h>
|
||||||
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
|
||||||
@ -38,6 +39,8 @@ namespace Genode {
|
|||||||
addr_t _base; /* base address of dataspace */
|
addr_t _base; /* base address of dataspace */
|
||||||
Allocator_avl _range; /* VM range allocator */
|
Allocator_avl _range; /* VM range allocator */
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
Rm_area(addr_t base)
|
Rm_area(addr_t base)
|
||||||
: Rm_connection(0, RESERVATION), _range(env()->heap())
|
: Rm_connection(0, RESERVATION), _range(env()->heap())
|
||||||
{
|
{
|
||||||
@ -51,8 +54,19 @@ namespace Genode {
|
|||||||
|
|
||||||
static Rm_area *r(addr_t base = 0)
|
static Rm_area *r(addr_t base = 0)
|
||||||
{
|
{
|
||||||
static Rm_area _area(base);
|
/*
|
||||||
return &_area;
|
* The capabilities in this class become invalid when doing a
|
||||||
|
* fork in the noux environment. Hence avoid destruction of
|
||||||
|
* the singleton object as the destructor would try to access
|
||||||
|
* the capabilities also in the forked process.
|
||||||
|
*/
|
||||||
|
static bool constructed = 0;
|
||||||
|
static char placeholder[sizeof(Rm_area)];
|
||||||
|
if (!constructed) {
|
||||||
|
construct_at<Rm_area>(placeholder, base);
|
||||||
|
constructed = 1;
|
||||||
|
}
|
||||||
|
return reinterpret_cast<Rm_area *>(placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user