packages: consolidate genodeSources patches

post-mortem
Emery Hemingway 2 years ago
parent 4a613364df
commit ba1d50ab6b

@ -35,11 +35,7 @@ let
version = builtins.substring 0 7 upstreamSources.rev;
src = upstreamSources;
nativeBuildInputs = [ expect gnumake tcl ];
patches = [
./patches/binary-labels.patch
./patches/label-fail.patch
./patches/phdr.patch
];
patches = [ ./patches/sources.patch ];
configurePhase = ''
patchShebangs ./tool
substituteInPlace repos/base/etc/tools.conf \
@ -335,12 +331,6 @@ let
'';
};
basePatches = [
./patches/cxx-align.patch
./patches/core-diag.patch
./patches/ld-ro.patch
];
in makePackages // depotPackages // {
genodeSources = genodeSources // {
@ -353,7 +343,6 @@ in makePackages // depotPackages // {
KERNEL = "hw";
BOARD = "pc";
targets = [ "bootstrap" "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/lib/ld-hw.lib.so $out/lib/ld.lib.so
mv $out/bin/hw_timer_drv $out/bin/timer_drv
@ -369,7 +358,6 @@ in makePackages // depotPackages // {
KERNEL = "hw";
BOARD = "virt_qemu";
targets = [ "bootstrap" "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/lib/ld-hw.lib.so $out/lib/ld.lib.so
mv $out/bin/hw_timer_drv $out/bin/timer_drv
@ -384,7 +372,6 @@ in makePackages // depotPackages // {
KERNEL = "linux";
BOARD = "linux";
targets = [ "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/lib/ld-linux.lib.so $out/lib/ld.lib.so
mv $out/bin/linux_timer_drv $out/bin/timer_drv
@ -397,7 +384,6 @@ in makePackages // depotPackages // {
outputs = [ "out" "coreObj" ];
KERNEL = "nova";
targets = [ "core" "timer" "lib/ld" ];
patches = basePatches;
postInstall = ''
mv $out/lib/ld-nova.lib.so $out/lib/ld.lib.so
mv $out/bin/nova_timer_drv $out/bin/timer_drv

@ -98,7 +98,7 @@ in {
imx53_qsb_drivers = { };
imx8_fb_drv = { };
imx8q_evk_drivers = { };
init.patches = [ ./patches/sandbox.patch ./patches/xml-fail.patch ];
init = { };
input_event_bridge = { };
intel_fb_drv = {
BOARD = "pc";
@ -306,7 +306,7 @@ in {
vbox5-nova = vbox5';
verify = { };
vesa_drv.portInputs = with ports; [ libc x86emu ];
vfs.patches = [ ./patches/vfs.patch ];
vfs = { };
vfs_audit = { };
vfs_block = { };
vfs_fatfs = { };

@ -1,98 +0,0 @@
commit 2d76b3271fa826a97c3974b7e67f2799e9ba448d
Author: Emery Hemingway <ehmry@posteo.net>
Date: Fri May 29 18:42:57 2020 +0530
Use 128-byte strings for session labels
Sixty-four bytes is insufficient for Nix store paths.
diff --git a/repos/base/include/base/child.h b/repos/base/include/base/child.h
index 8c7b33a9d9..3bd6483547 100644
--- a/repos/base/include/base/child.h
+++ b/repos/base/include/base/child.h
@@ -44,9 +44,9 @@ namespace Genode {
*/
struct Genode::Child_policy
{
- typedef String<64> Name;
- typedef String<64> Binary_name;
- typedef String<64> Linker_name;
+ typedef String<128> Name;
+ typedef String<128> Binary_name;
+ typedef String<128> Linker_name;
virtual ~Child_policy() { }
@@ -407,7 +407,7 @@ class Genode::Child : protected Rpc_object<Parent>,
Id_space<Parent::Client>::Id const _client_id;
- typedef String<64> Label;
+ typedef String<128> Label;
Args const _args;
diff --git a/repos/base/include/base/shared_object.h b/repos/base/include/base/shared_object.h
index f4dd1622fe..7ffe5fa34c 100644
--- a/repos/base/include/base/shared_object.h
+++ b/repos/base/include/base/shared_object.h
@@ -128,7 +128,7 @@ class Genode::Dynamic_linker
struct Object_info
{
/* name of shared library, or "binary" for the main program */
- typedef String<64> Name;
+ typedef String<128> Name;
Name name;
Rom_dataspace_capability ds_cap;
diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h
index a8875a781e..e06749f7ef 100644
--- a/repos/base/src/lib/ldso/include/file.h
+++ b/repos/base/src/lib/ldso/include/file.h
@@ -98,7 +98,7 @@ struct Linker::Elf_file : File
Ram_dataspace_capability ram_cap[Phdr::MAX_PHDR];
bool const loaded;
- typedef String<64> Name;
+ typedef String<128> Name;
Rom_dataspace_capability _rom_dataspace(Name const &name)
{
diff --git a/repos/libports/src/lib/libc/internal/types.h b/repos/libports/src/lib/libc/internal/types.h
index 233da10b47..afaee3f8d7 100644
--- a/repos/libports/src/lib/libc/internal/types.h
+++ b/repos/libports/src/lib/libc/internal/types.h
@@ -23,7 +23,7 @@ namespace Libc {
using namespace Genode;
typedef Genode::uint64_t uint64_t;
- typedef String<64> Binary_name;
+ typedef String<128> Binary_name;
}
#endif /* _LIBC__INTERNAL__TYPES_H_ */
diff --git a/repos/libports/src/lib/libc/kernel.cc b/repos/libports/src/lib/libc/kernel.cc
index 430295e7d5..bdb3c66598 100644
--- a/repos/libports/src/lib/libc/kernel.cc
+++ b/repos/libports/src/lib/libc/kernel.cc
@@ -300,7 +300,7 @@ void Libc::Kernel::_clone_state_from_parent()
/* clone RW segment of a shared library or the binary */
if (node.type() == "rw") {
- typedef String<64> Name;
+ typedef String<128> Name;
Name const name = node.attribute_value("name", Name());
/*
diff --git a/repos/os/src/lib/sandbox/child.h b/repos/os/src/lib/sandbox/child.h
index 030ccbd66d..5164d33ba5 100644
--- a/repos/os/src/lib/sandbox/child.h
+++ b/repos/os/src/lib/sandbox/child.h
@@ -119,7 +119,6 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
throw Missing_name_attribute();
}
- typedef String<64> Name;
Name const _unique_name { _name_from_xml(_start_node->xml()) };
static Binary_name _binary_from_xml(Xml_node start_node,

@ -1,39 +0,0 @@
From 55f35e33680287ba925accf3bddadaa46d5ff30a Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 7 Nov 2020 08:37:29 +0100
Subject: [PATCH] core: log ROM requests with affirmative "diag" flag
---
repos/base/src/core/include/rom_session_component.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/repos/base/src/core/include/rom_session_component.h b/repos/base/src/core/include/rom_session_component.h
index c584701f5f..2c93302e14 100644
--- a/repos/base/src/core/include/rom_session_component.h
+++ b/repos/base/src/core/include/rom_session_component.h
@@ -35,12 +35,20 @@ namespace Genode {
{
/* extract label */
Session_label const label = label_from_args(args);
+ auto const name = label.last_element();
+
+ /* extract diag flag */
+ bool diag = session_diag_from_args(args).enabled;
/* find ROM module for trailing label element */
- Rom_module const * rom = rom_fs.find(label.last_element().string());
- if (rom)
+ Rom_module const * rom = rom_fs.find(name.string());
+
+ if (rom) {
+ if (diag) log("serve ROM \"", name, "\" to \"", label, "\"");
return *rom;
+ }
+ error("ROM not found for ", args);
throw Service_denied();
}
--
2.29.2

@ -1,57 +0,0 @@
commit 0df2ea0956e46f3914be01aa9d7b20a06d805e53
Author: Emery Hemingway <ehmry@posteo.net>
Date: Wed Apr 8 12:39:44 2020 +0530
cxx: align exception allocator to sixteen bytes
diff --git a/repos/base/src/lib/cxx/malloc_free.cc b/repos/base/src/lib/cxx/malloc_free.cc
index b551dfe627..870dbb6c6d 100644
--- a/repos/base/src/lib/cxx/malloc_free.cc
+++ b/repos/base/src/lib/cxx/malloc_free.cc
@@ -61,27 +61,23 @@ void Genode::init_cxx_heap(Env &env)
}
-typedef unsigned long Block_header;
+typedef size_t Block_header;
extern "C" void *malloc(size_t size)
{
- /* enforce size to be a multiple of 4 bytes */
- size = (size + 3) & ~3;
-
/*
- * We store the size of the allocation at the very
- * beginning of the allocated block and return
- * the subsequent address. This way, we can retrieve
- * the size information when freeing the block.
+ * We pad each allocation with 16 leading bytes for
+ * storing the size of the allocation. This way, we can
+ * retrieve the size information when freeing the block.
*/
- unsigned long real_size = size + sizeof(Block_header);
- void *addr = 0;
- if (!cxx_heap().alloc(real_size, &addr))
- return 0;
+ size_t real_size = size + 16;
+ addr_t real_addr = 0;
+ if (!cxx_heap().alloc(real_size, (void**)&real_addr))
+ return nullptr;
- *(Block_header *)addr = real_size;
- return (Block_header *)addr + 1;
+ *(Block_header *)real_addr = real_size;
+ return (void*)(real_addr + 16);
}
@@ -101,7 +97,7 @@ extern "C" void free(void *ptr)
{
if (!ptr) return;
- unsigned long *addr = ((unsigned long *)ptr) - 1;
+ unsigned long *addr = (unsigned long *)(addr_t(ptr) - 16);
cxx_heap().free(addr, *addr);
}

@ -1,184 +0,0 @@
From 4250346b87b8e24a48d04ddacc77512eaa20ce0e Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 7 Nov 2020 11:23:03 +0100
Subject: [PATCH 1/3] base: fail on label truncation
---
repos/base/include/base/session_label.h | 27 ++++++++++++++++++++++---
repos/base/include/util/arg_string.h | 6 ++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/repos/base/include/base/session_label.h b/repos/base/include/base/session_label.h
index d5e752d120..85034904e5 100644
--- a/repos/base/include/base/session_label.h
+++ b/repos/base/include/base/session_label.h
@@ -16,10 +16,14 @@
#define _INCLUDE__BASE__SESSION_LABEL_H_
#include <base/snprintf.h>
+#include <base/log.h>
#include <util/arg_string.h>
#include <util/string.h>
-namespace Genode { struct Session_label; }
+namespace Genode {
+ struct Session_label;
+ class Label_overflow : Exception { };
+}
struct Genode::Session_label : String<160>
{
@@ -33,6 +37,8 @@ struct Genode::Session_label : String<160>
using String = String<capacity()>;
using String::String;
+ /* TODO: String::String can still truncate and break labels */
+
/**
* Copy constructor
*
@@ -41,7 +47,13 @@ struct Genode::Session_label : String<160>
*/
template <size_t N>
Session_label(Genode::String<N> const &other)
- : Genode::String<160>(other) { }
+ : Genode::String<160>(other)
+ {
+ if (length() < other.length()) {
+ error(__func__, " overflow - «", other, "»");
+ throw Label_overflow();
+ }
+ }
Session_label last_element() const
{
@@ -90,8 +102,13 @@ namespace Genode {
inline Session_label label_from_args(char const *args)
{
char buf[Session_label::capacity()];
- Arg_string::find_arg(args, "label").string(buf, sizeof(buf), "");
+ auto arg = Arg_string::find_arg(args, "label");
+ if (Session_label::capacity() <= arg.length()) {
+ error(__func__, " overflow - «", (char const *)args, "»");
+ throw Label_overflow();
+ }
+ arg.string(buf, sizeof(buf), "");
return Session_label(Cstring(buf));
}
@@ -103,6 +120,10 @@ namespace Genode {
String<N2> const &label)
{
String<N1 + N2 + 4> const prefixed_label(prefix, " -> ", label);
+ if (Session_label::capacity() <= prefixed_label.length()) {
+ error(__func__, " overflow - «", prefix, "» - «", label, "»");
+ throw Label_overflow();
+ }
return Session_label(prefixed_label);
}
}
diff --git a/repos/base/include/util/arg_string.h b/repos/base/include/util/arg_string.h
index 610fbb16b3..48777e0c2a 100644
--- a/repos/base/include/util/arg_string.h
+++ b/repos/base/include/util/arg_string.h
@@ -114,6 +114,12 @@ class Genode::Arg
inline bool valid() const { return _key; }
+ size_t length() const
+ {
+ return _value.type() == Token::STRING
+ ? _value.len() - 2 : _value.len();
+ }
+
unsigned long ulong_value(unsigned long default_value) const
{
unsigned long value = 0;
--
2.30.0
From 252c08cf61ad7feef83bd2e542465330633ba41f Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 10 Feb 2021 13:32:42 +0100
Subject: [PATCH 2/3] Detect destroyed argument buffers at Env::session
Session request arguments are silently zeroed when their length
exceedes some buffer size.
---
repos/base/src/lib/base/component.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/repos/base/src/lib/base/component.cc b/repos/base/src/lib/base/component.cc
index 568be31efb..913687ea7f 100644
--- a/repos/base/src/lib/base/component.cc
+++ b/repos/base/src/lib/base/component.cc
@@ -122,6 +122,10 @@ namespace {
Affinity const &affinity) override
{
Mutex::Guard guard(_mutex);
+ if (!args.valid_string()) {
+ error("invalid args for ", name.string(), " service request");
+ throw Service_denied();
+ }
/*
* Since we account for the backing store for session meta data on
--
2.30.0
From 53641e192bc3f9a756ae15b91640a42ac7e70918 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 11 Feb 2021 14:10:50 +0100
Subject: [PATCH 3/3] Increase session arguments buffer size to 240 bytes
---
repos/base/include/parent/parent.h | 2 +-
repos/base/include/root/root.h | 2 +-
repos/base/lib/symbols/ld | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/repos/base/include/parent/parent.h b/repos/base/include/parent/parent.h
index 7379342e5b..6e94047788 100644
--- a/repos/base/include/parent/parent.h
+++ b/repos/base/include/parent/parent.h
@@ -54,7 +54,7 @@ class Genode::Parent
public:
typedef Rpc_in_buffer<64> Service_name;
- typedef Rpc_in_buffer<160> Session_args;
+ typedef Rpc_in_buffer<240> Session_args;
typedef Rpc_in_buffer<160> Upgrade_args;
struct Client : Interface { typedef Id_space<Client>::Id Id; };
diff --git a/repos/base/include/root/root.h b/repos/base/include/root/root.h
index c7e3a0c908..4fda9e341f 100644
--- a/repos/base/include/root/root.h
+++ b/repos/base/include/root/root.h
@@ -29,7 +29,7 @@ namespace Genode {
struct Genode::Root
{
- typedef Rpc_in_buffer<160> Session_args;
+ typedef Rpc_in_buffer<240> Session_args;
typedef Rpc_in_buffer<160> Upgrade_args;
virtual ~Root() { }
diff --git a/repos/base/lib/symbols/ld b/repos/base/lib/symbols/ld
index 3cfbdd7466..d7603e8ca4 100644
--- a/repos/base/lib/symbols/ld
+++ b/repos/base/lib/symbols/ld
@@ -398,6 +398,8 @@ _ZThn236_N5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_
_ZThn236_N5Timer10Connection9curr_timeEv T
_ZThn288_N5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_handlerE T
_ZThn288_N5Timer10Connection9curr_timeEv T
+_ZThn368_N5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_handlerE T
+_ZThn368_N5Timer10Connection9curr_timeEv T
_ZThn8_N6Genode17Timeout_scheduler14handle_timeoutENS_8DurationE T
_ZThn8_N6Genode17Timeout_schedulerD0Ev T
_ZThn8_N6Genode17Timeout_schedulerD1Ev T
--
2.30.0

@ -1,90 +0,0 @@
From 8c4bb7d84838e8c01673caa8ad45a4c042ccdd11 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Mon, 6 Apr 2020 16:32:13 +0530
Subject: [PATCH] ld: support for loading read-only segments
---
repos/base/src/lib/ldso/include/file.h | 24 ++++++++++++++++++--
repos/base/src/lib/ldso/include/region_map.h | 10 ++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h
index 1c9ce53ca3..6688f0edd2 100644
--- a/repos/base/src/lib/ldso/include/file.h
+++ b/repos/base/src/lib/ldso/include/file.h
@@ -34,6 +34,9 @@ namespace Linker {
static inline bool is_rw(Elf::Phdr const &ph) {
return ((ph.p_flags & PF_MASK) == (PF_R | PF_W)); }
+
+ static inline bool is_ro(Elf::Phdr const &ph) {
+ return ((ph.p_flags & PF_MASK) == PF_R); }
}
@@ -280,15 +283,21 @@ struct Linker::Elf_file : File
else if (is_rw(*ph))
load_segment_rw(*ph, i);
+ else if (is_ro(*ph))
+ load_segment_ro(*ph);
+
else {
- error("LD: Non-RW/RX segment");
+ auto X = ph->p_flags & PF_X ? "X" : "-";
+ auto W = ph->p_flags & PF_W ? "W" : "-";
+ auto R = ph->p_flags & PF_R ? "R" : "-";
+ error("LD: unhandled ", X,W,R, " segment at file offset ", Hex(ph->p_offset));
throw Invalid_file();
}
}
}
/**
- * Map read-only segment
+ * Map read-execute-only segment
*/
void load_segment_rx(Elf::Phdr const &p)
{
@@ -318,6 +327,17 @@ struct Linker::Elf_file : File
env.rm().detach(src);
}
+ /**
+ * Map read-only segment
+ */
+ void load_segment_ro(Elf::Phdr const &p)
+ {
+ Region_map::r()->attach_readonly(rom_cap,
+ trunc_page(p.p_vaddr) + reloc_base,
+ round_page(p.p_memsz),
+ trunc_page(p.p_offset));
+ }
+
/**
* Unmap segements, RM regions, and free allocated dataspaces
*/
diff --git a/repos/base/src/lib/ldso/include/region_map.h b/repos/base/src/lib/ldso/include/region_map.h
index cbee34c639..b30c2221da 100644
--- a/repos/base/src/lib/ldso/include/region_map.h
+++ b/repos/base/src/lib/ldso/include/region_map.h
@@ -122,6 +122,16 @@ class Linker::Region_map
[&] () { _env.upgrade(Parent::Env::pd(), "ram_quota=8K"); });
}
+ Local_addr attach_readonly(Dataspace_capability ds, addr_t local_addr,
+ size_t size = 0, off_t offset = 0)
+ {
+ return retry<Genode::Out_of_ram>(
+ [&] () {
+ return _rm.attach(ds, size, offset, true, local_addr - _base, false, false);
+ },
+ [&] () { _env.upgrade(Parent::Env::pd(), "ram_quota=8K"); });
+ }
+
void detach(Local_addr local_addr) { _rm.detach((addr_t)local_addr - _base); }
};
--
2.28.0

@ -1,27 +0,0 @@
From 45c73b01d4609f59ca576141bc836baad8e468ed Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 28 Jan 2021 13:39:29 +0100
Subject: [PATCH] genode_dyn.ld: do not emit PHDR segment
Recent version of binutils check that PHDR segments are covered
by a LOAD segment. In this case the unloaded PHDR segment can be
ommited.
---
repos/base/src/ld/genode_dyn.ld | 1 -
1 file changed, 1 deletion(-)
diff --git a/repos/base/src/ld/genode_dyn.ld b/repos/base/src/ld/genode_dyn.ld
index 5fa6ddc29e..57ec92f0f6 100644
--- a/repos/base/src/ld/genode_dyn.ld
+++ b/repos/base/src/ld/genode_dyn.ld
@@ -18,7 +18,6 @@
PHDRS
{
- phdr PT_PHDR PHDRS;
interp PT_INTERP;
ro PT_LOAD;
rw PT_LOAD;
--
2.29.2

@ -1,7 +1,98 @@
From 735e7af9458005092451f448ddf3dfc1cad4acbd Mon Sep 17 00:00:00 2001
From bf2613eb22091125c0aff894e580063dac5e2bff Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Mon, 6 Apr 2020 16:32:13 +0530
Subject: [PATCH 01/16] ld: support for loading read-only segments
---
repos/base/src/lib/ldso/include/file.h | 24 ++++++++++++++++++--
repos/base/src/lib/ldso/include/region_map.h | 10 ++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h
index 1c9ce53ca3..6688f0edd2 100644
--- a/repos/base/src/lib/ldso/include/file.h
+++ b/repos/base/src/lib/ldso/include/file.h
@@ -34,6 +34,9 @@ namespace Linker {
static inline bool is_rw(Elf::Phdr const &ph) {
return ((ph.p_flags & PF_MASK) == (PF_R | PF_W)); }
+
+ static inline bool is_ro(Elf::Phdr const &ph) {
+ return ((ph.p_flags & PF_MASK) == PF_R); }
}
@@ -280,15 +283,21 @@ struct Linker::Elf_file : File
else if (is_rw(*ph))
load_segment_rw(*ph, i);
+ else if (is_ro(*ph))
+ load_segment_ro(*ph);
+
else {
- error("LD: Non-RW/RX segment");
+ auto X = ph->p_flags & PF_X ? "X" : "-";
+ auto W = ph->p_flags & PF_W ? "W" : "-";
+ auto R = ph->p_flags & PF_R ? "R" : "-";
+ error("LD: unhandled ", X,W,R, " segment at file offset ", Hex(ph->p_offset));
throw Invalid_file();
}
}
}
/**
- * Map read-only segment
+ * Map read-execute-only segment
*/
void load_segment_rx(Elf::Phdr const &p)
{
@@ -318,6 +327,17 @@ struct Linker::Elf_file : File
env.rm().detach(src);
}
+ /**
+ * Map read-only segment
+ */
+ void load_segment_ro(Elf::Phdr const &p)
+ {
+ Region_map::r()->attach_readonly(rom_cap,
+ trunc_page(p.p_vaddr) + reloc_base,
+ round_page(p.p_memsz),
+ trunc_page(p.p_offset));
+ }
+
/**
* Unmap segements, RM regions, and free allocated dataspaces
*/
diff --git a/repos/base/src/lib/ldso/include/region_map.h b/repos/base/src/lib/ldso/include/region_map.h
index 78d2c7033d..f17d6dfec0 100644
--- a/repos/base/src/lib/ldso/include/region_map.h
+++ b/repos/base/src/lib/ldso/include/region_map.h
@@ -130,6 +130,16 @@ class Linker::Region_map
[&] () { _env.upgrade(Parent::Env::pd(), "ram_quota=8K"); });
}
+ Local_addr attach_readonly(Dataspace_capability ds, addr_t local_addr,
+ size_t size = 0, off_t offset = 0)
+ {
+ return retry<Genode::Out_of_ram>(
+ [&] () {
+ return _rm.attach(ds, size, offset, true, local_addr - _base, false, false);
+ },
+ [&] () { _env.upgrade(Parent::Env::pd(), "ram_quota=8K"); });
+ }
+
void detach(Local_addr local_addr) { _rm.detach((addr_t)local_addr - _base); }
};
--
2.30.0
From 525ab24c481acdf9bb784cac36e663a20084b55b Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 25 Apr 2020 17:10:03 +0530
Subject: [PATCH 1/4] init/sandbox: <routes> support
Subject: [PATCH 02/16] init/sandbox: <routes> support
Apply routing rules to a child from a <routes> node at the top-level of
a sandbox config, unless the corresponding start node has as <route>
@ -180,14 +271,123 @@ index 7afcaebf00..36aab737f2 100644
if (!scoped_label)
return false;
--
2.29.2
2.30.0
From 16106e96b1cf7639b050097b131b3be3cdbcf739 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Fri, 29 May 2020 18:42:57 +0530
Subject: [PATCH 03/16] Use 128-byte strings for session labels
Sixty-four bytes is insufficient for Nix store paths.
---
repos/base/include/base/child.h | 8 ++++----
repos/base/include/base/shared_object.h | 2 +-
repos/base/src/lib/ldso/include/file.h | 2 +-
repos/libports/src/lib/libc/internal/types.h | 2 +-
repos/libports/src/lib/libc/kernel.cc | 2 +-
repos/os/src/lib/sandbox/child.h | 1 -
6 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/repos/base/include/base/child.h b/repos/base/include/base/child.h
index 8c7b33a9d9..3bd6483547 100644
--- a/repos/base/include/base/child.h
+++ b/repos/base/include/base/child.h
@@ -44,9 +44,9 @@ namespace Genode {
*/
struct Genode::Child_policy
{
- typedef String<64> Name;
- typedef String<64> Binary_name;
- typedef String<64> Linker_name;
+ typedef String<128> Name;
+ typedef String<128> Binary_name;
+ typedef String<128> Linker_name;
virtual ~Child_policy() { }
@@ -407,7 +407,7 @@ class Genode::Child : protected Rpc_object<Parent>,
Id_space<Parent::Client>::Id const _client_id;
- typedef String<64> Label;
+ typedef String<128> Label;
Args const _args;
diff --git a/repos/base/include/base/shared_object.h b/repos/base/include/base/shared_object.h
index f4dd1622fe..7ffe5fa34c 100644
--- a/repos/base/include/base/shared_object.h
+++ b/repos/base/include/base/shared_object.h
@@ -128,7 +128,7 @@ class Genode::Dynamic_linker
struct Object_info
{
/* name of shared library, or "binary" for the main program */
- typedef String<64> Name;
+ typedef String<128> Name;
Name name;
Rom_dataspace_capability ds_cap;
diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h
index 6688f0edd2..e763264eee 100644
--- a/repos/base/src/lib/ldso/include/file.h
+++ b/repos/base/src/lib/ldso/include/file.h
@@ -101,7 +101,7 @@ struct Linker::Elf_file : File
Ram_dataspace_capability ram_cap[Phdr::MAX_PHDR];
bool const loaded;
- typedef String<64> Name;
+ typedef String<128> Name;
Rom_dataspace_capability _rom_dataspace(Name const &name)
{
diff --git a/repos/libports/src/lib/libc/internal/types.h b/repos/libports/src/lib/libc/internal/types.h
index 233da10b47..afaee3f8d7 100644
--- a/repos/libports/src/lib/libc/internal/types.h
+++ b/repos/libports/src/lib/libc/internal/types.h
@@ -23,7 +23,7 @@ namespace Libc {
using namespace Genode;
typedef Genode::uint64_t uint64_t;
- typedef String<64> Binary_name;
+ typedef String<128> Binary_name;
}
#endif /* _LIBC__INTERNAL__TYPES_H_ */
diff --git a/repos/libports/src/lib/libc/kernel.cc b/repos/libports/src/lib/libc/kernel.cc
index ac208b223e..3b81be01a9 100644
--- a/repos/libports/src/lib/libc/kernel.cc
+++ b/repos/libports/src/lib/libc/kernel.cc
@@ -364,7 +364,7 @@ void Libc::Kernel::_clone_state_from_parent()
/* clone RW segment of a shared library or the binary */
if (node.type() == "rw") {
- typedef String<64> Name;
+ typedef String<128> Name;
Name const name = node.attribute_value("name", Name());
/*
diff --git a/repos/os/src/lib/sandbox/child.h b/repos/os/src/lib/sandbox/child.h
index 81836a2045..f7b41ddd5b 100644
--- a/repos/os/src/lib/sandbox/child.h
+++ b/repos/os/src/lib/sandbox/child.h
@@ -128,7 +128,6 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
throw Missing_name_attribute();
}
- typedef String<64> Name;
Name const _unique_name { _name_from_xml(_start_node->xml()) };
static Binary_name _binary_from_xml(Xml_node start_node,
--
2.30.0
From 0b65d7660784dbff4ef4fe392af686103c60a32d Mon Sep 17 00:00:00 2001
From 3f38eacb25348a811f37ce267323253b1941cad2 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 4 Nov 2020 11:03:49 +0100
Subject: [PATCH 2/4] init/sandbox: do not parse <parent-provides> if <routes>
is present
Subject: [PATCH 04/16] init/sandbox: do not parse <parent-provides> if
<routes> is present
---
repos/os/src/lib/sandbox/library.cc | 124 +++++++++++++++++++---------
@ -331,13 +531,13 @@ index 30d0f2dfc1..caa9840ea6 100644
--
2.29.2
2.30.0
From 67d834c4556969e37bc050e151baeedddfb05ac9 Mon Sep 17 00:00:00 2001
From ef28369a1e6ba0f8910da3a6cb757f9e5ec334ad Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 4 Nov 2020 20:02:03 +0100
Subject: [PATCH 3/4] init/sandbox: simplify routing
Subject: [PATCH 05/16] init/sandbox: simplify routing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -535,7 +735,7 @@ index d25e3d9683..46aa22411c 100644
_default_caps_accessor(default_caps_accessor),
_ram_limit_accessor(ram_limit_accessor),
diff --git a/repos/os/src/lib/sandbox/child.h b/repos/os/src/lib/sandbox/child.h
index 81836a2045..f9d04cfdaf 100644
index f7b41ddd5b..fd254d7f49 100644
--- a/repos/os/src/lib/sandbox/child.h
+++ b/repos/os/src/lib/sandbox/child.h
@@ -49,7 +49,6 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
@ -554,7 +754,7 @@ index 81836a2045..f9d04cfdaf 100644
Routes_accessor &_routes_accessor;
Default_caps_accessor &_default_caps_accessor;
Ram_limit_accessor &_ram_limit_accessor;
@@ -481,7 +479,6 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
@@ -480,7 +478,6 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
Id id,
Report_update_trigger &report_update_trigger,
Xml_node start_node,
@ -697,13 +897,182 @@ index 36aab737f2..639a4be4dd 100644
* Find service with certain values in given registry
*
--
2.29.2
2.30.0
From 92c1f192d432f177c681e3ab001214e66e96e0f0 Mon Sep 17 00:00:00 2001
From 79ae552230809f62e1717a08f5ce9a63c044abf9 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 7 Nov 2020 08:37:29 +0100
Subject: [PATCH 06/16] core: log ROM requests with affirmative "diag" flag
---
repos/base/src/core/include/rom_session_component.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/repos/base/src/core/include/rom_session_component.h b/repos/base/src/core/include/rom_session_component.h
index c584701f5f..2c93302e14 100644
--- a/repos/base/src/core/include/rom_session_component.h
+++ b/repos/base/src/core/include/rom_session_component.h
@@ -35,12 +35,20 @@ namespace Genode {
{
/* extract label */
Session_label const label = label_from_args(args);
+ auto const name = label.last_element();
+
+ /* extract diag flag */
+ bool diag = session_diag_from_args(args).enabled;
/* find ROM module for trailing label element */
- Rom_module const * rom = rom_fs.find(label.last_element().string());
- if (rom)
+ Rom_module const * rom = rom_fs.find(name.string());
+
+ if (rom) {
+ if (diag) log("serve ROM \"", name, "\" to \"", label, "\"");
return *rom;
+ }
+ error("ROM not found for ", args);
throw Service_denied();
}
--
2.30.0
From 0e1ea49ea6ce4f85e2e30a01aa5ace7928b20267 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 7 Nov 2020 11:23:03 +0100
Subject: [PATCH 07/16] base: fail on label truncation
---
repos/base/include/base/session_label.h | 27 ++++++++++++++++++++++---
repos/base/include/util/arg_string.h | 6 ++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/repos/base/include/base/session_label.h b/repos/base/include/base/session_label.h
index d5e752d120..85034904e5 100644
--- a/repos/base/include/base/session_label.h
+++ b/repos/base/include/base/session_label.h
@@ -16,10 +16,14 @@
#define _INCLUDE__BASE__SESSION_LABEL_H_
#include <base/snprintf.h>
+#include <base/log.h>
#include <util/arg_string.h>
#include <util/string.h>
-namespace Genode { struct Session_label; }
+namespace Genode {
+ struct Session_label;
+ class Label_overflow : Exception { };
+}
struct Genode::Session_label : String<160>
{
@@ -33,6 +37,8 @@ struct Genode::Session_label : String<160>
using String = String<capacity()>;
using String::String;
+ /* TODO: String::String can still truncate and break labels */
+
/**
* Copy constructor
*
@@ -41,7 +47,13 @@ struct Genode::Session_label : String<160>
*/
template <size_t N>
Session_label(Genode::String<N> const &other)
- : Genode::String<160>(other) { }
+ : Genode::String<160>(other)
+ {
+ if (length() < other.length()) {
+ error(__func__, " overflow - «", other, "»");
+ throw Label_overflow();
+ }
+ }
Session_label last_element() const
{
@@ -90,8 +102,13 @@ namespace Genode {
inline Session_label label_from_args(char const *args)
{
char buf[Session_label::capacity()];
- Arg_string::find_arg(args, "label").string(buf, sizeof(buf), "");
+ auto arg = Arg_string::find_arg(args, "label");
+ if (Session_label::capacity() <= arg.length()) {
+ error(__func__, " overflow - «", (char const *)args, "»");
+ throw Label_overflow();
+ }
+ arg.string(buf, sizeof(buf), "");
return Session_label(Cstring(buf));
}
@@ -103,6 +120,10 @@ namespace Genode {
String<N2> const &label)
{
String<N1 + N2 + 4> const prefixed_label(prefix, " -> ", label);
+ if (Session_label::capacity() <= prefixed_label.length()) {
+ error(__func__, " overflow - «", prefix, "» - «", label, "»");
+ throw Label_overflow();
+ }
return Session_label(prefixed_label);
}
}
diff --git a/repos/base/include/util/arg_string.h b/repos/base/include/util/arg_string.h
index 610fbb16b3..48777e0c2a 100644
--- a/repos/base/include/util/arg_string.h
+++ b/repos/base/include/util/arg_string.h
@@ -114,6 +114,12 @@ class Genode::Arg
inline bool valid() const { return _key; }
+ size_t length() const
+ {
+ return _value.type() == Token::STRING
+ ? _value.len() - 2 : _value.len();
+ }
+
unsigned long ulong_value(unsigned long default_value) const
{
unsigned long value = 0;
--
2.30.0
From 2c193324a6702e123c8cafabda45c30c7ca09257 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 7 Nov 2020 13:49:41 +0100
Subject: [PATCH 08/16] init: log error when configuration cannot be parsed
---
repos/os/src/init/main.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/repos/os/src/init/main.cc b/repos/os/src/init/main.cc
index 7b69c95721..f1c1a1435a 100644
--- a/repos/os/src/init/main.cc
+++ b/repos/os/src/init/main.cc
@@ -47,6 +47,10 @@ struct Init::Main : Sandbox::State_handler
_config.update();
Xml_node const config = _config.xml();
+ if (config.has_type("empty")) {
+ error("failed to parse config ROM");
+ return;
+ };
bool reporter_enabled = false;
config.with_sub_node("report", [&] (Xml_node report) {
--
2.30.0
From 5d07e900e3c7f0fe507844bccc5f168bad046a3c Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 28 Nov 2020 14:00:49 +0100
Subject: [PATCH 4/4] Do not default Child::binary_name() to Child::name()
Subject: [PATCH 09/16] Do not default Child::binary_name() to Child::name()
---
repos/base/include/base/child.h | 2 +-
@ -712,7 +1081,7 @@ Subject: [PATCH 4/4] Do not default Child::binary_name() to Child::name()
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/repos/base/include/base/child.h b/repos/base/include/base/child.h
index 8c7b33a9d9..bca0d566f2 100644
index 3bd6483547..a00e59e3a4 100644
--- a/repos/base/include/base/child.h
+++ b/repos/base/include/base/child.h
@@ -58,7 +58,7 @@ struct Genode::Child_policy
@ -738,10 +1107,10 @@ index d480585221..7acacf0ffd 100644
Session_label const &label) override
{
diff --git a/repos/os/src/lib/sandbox/child.h b/repos/os/src/lib/sandbox/child.h
index f9d04cfdaf..a1e45dab0d 100644
index fd254d7f49..036e7f8fc2 100644
--- a/repos/os/src/lib/sandbox/child.h
+++ b/repos/os/src/lib/sandbox/child.h
@@ -595,6 +595,7 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
@@ -594,6 +594,7 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup
****************************/
Child_policy::Name name() const override { return _unique_name; }
@ -750,5 +1119,320 @@ index f9d04cfdaf..a1e45dab0d 100644
Pd_session &ref_pd() override { return _env.pd(); }
Pd_session_capability ref_pd_cap() const override { return _env.pd_session_cap(); }
--
2.29.2
2.30.0
From 0ac7fd14676b451e11b74c9e66f7de265b3ee4e6 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 3 Dec 2020 12:19:10 +0100
Subject: [PATCH 10/16] vfs: create missing root directories for writeable
sessions
This is the expected behavior.
---
repos/os/src/server/vfs/main.cc | 47 ++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/repos/os/src/server/vfs/main.cc b/repos/os/src/server/vfs/main.cc
index b780b1fdd7..358afd28a9 100644
--- a/repos/os/src/server/vfs/main.cc
+++ b/repos/os/src/server/vfs/main.cc
@@ -841,6 +841,41 @@ class Vfs_server::Root : public Genode::Root_component<Session_component>,
Genode::Signal_transmitter(_reactivate_handler).submit();
}
+ /**
+ * Open a directory, ensuring all parent directories exists.
+ */
+ void _create_session_dir(Path const &path)
+ {
+ using namespace Genode;
+ typedef Vfs::Directory_service::Opendir_result Result;
+
+ Vfs_handle *handle { nullptr };
+ Vfs::File_system &vfs = _vfs_env.root_dir();
+
+ switch (vfs.opendir(path.string(), true, &handle, _vfs_heap)) {
+ case Result::OPENDIR_OK:
+ handle->close();
+ return;
+ case Result::OPENDIR_ERR_NODE_ALREADY_EXISTS:
+ if (vfs.directory(path.string())) return;
+ break;
+ case Result::OPENDIR_ERR_LOOKUP_FAILED: {
+ Path parent = path;
+ parent.strip_last_element();
+ _create_session_dir(parent.string());
+ auto res = vfs.opendir(path.string(), true, &handle, _vfs_heap);
+ if (res == Result::OPENDIR_OK) {
+ handle->close();
+ return;
+ }
+ }
+ default: break;
+ }
+
+ error("cannot create session root at ", path);
+ throw Service_denied();
+ }
+
protected:
Session_component *_create_session(const char *args) override
@@ -916,10 +951,14 @@ class Vfs_server::Root : public Genode::Root_component<Session_component>,
}
/* check if the session root exists */
- if (!((session_root == "/")
- || _vfs_env.root_dir().directory(session_root.base()))) {
- error("session root '", session_root, "' not found for '", label, "'");
- throw Service_denied();
+ if (session_root != "/") {
+ if (!_vfs_env.root_dir().directory(session_root.base())) {
+ if (writeable) { _create_session_dir(session_root); }
+ else {
+ error("session root '", session_root, "' not found for '", label, "'");
+ throw Service_denied();
+ }
+ }
}
Session_component *session = new (md_alloc())
--
2.30.0
From 6842e2d0c2c784d224a9d7bc100e491545b8e5e6 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 28 Jan 2021 13:39:29 +0100
Subject: [PATCH 11/16] genode_dyn.ld: do not emit PHDR segment
Recent version of binutils check that PHDR segments are covered
by a LOAD segment. In this case the unloaded PHDR segment can be
ommited.
---
repos/base/src/ld/genode_dyn.ld | 1 -
1 file changed, 1 deletion(-)
diff --git a/repos/base/src/ld/genode_dyn.ld b/repos/base/src/ld/genode_dyn.ld
index 5fa6ddc29e..57ec92f0f6 100644
--- a/repos/base/src/ld/genode_dyn.ld
+++ b/repos/base/src/ld/genode_dyn.ld
@@ -18,7 +18,6 @@
PHDRS
{
- phdr PT_PHDR PHDRS;
interp PT_INTERP;
ro PT_LOAD;
rw PT_LOAD;
--
2.30.0
From ff8ffb77ccf4238001abd7253c45dece86fe8983 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 3 Feb 2021 15:20:39 +0100
Subject: [PATCH 12/16] vfs: support for loading plugins by label
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Make the VFS plugin recognize <plugin label="…"/> nodes.
---
repos/os/src/lib/vfs/file_system_factory.cc | 33 ++++++++++++++++-----
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/repos/os/src/lib/vfs/file_system_factory.cc b/repos/os/src/lib/vfs/file_system_factory.cc
index 5cdf20e8e3..1cf5d587ea 100644
--- a/repos/os/src/lib/vfs/file_system_factory.cc
+++ b/repos/os/src/lib/vfs/file_system_factory.cc
@@ -56,8 +56,16 @@ struct Vfs::Global_file_system_factory::Entry_base : Vfs::File_system_factory,
Entry_base(Fs_type_name const &name) : name(name) { }
- bool matches(Genode::Xml_node node) const {
- return node.has_type(name.string()); }
+ bool matches(Genode::Xml_node node) const
+ {
+ if (node.has_type(name.string()))
+ return true;
+
+ if (node.has_type("plugin") && node.has_attribute("load"))
+ return node.attribute("load").has_value(name.string());
+
+ return false;
+ }
};
@@ -165,14 +173,25 @@ Vfs::File_system_factory &Vfs::Global_file_system_factory::_load_factory(Vfs::En
bool Vfs::Global_file_system_factory::_probe_external_factory(Vfs::Env &env,
Genode::Xml_node node)
{
- Library_name const lib_name = _library_name(node.type());
-
try {
- _list.insert(new (env.alloc())
- External_entry(node.type().string(), _load_factory(env, lib_name)));
- return true;
+ if (node.has_type("plugin")) {
+ Library_name const lib_name = node.attribute_value("load", Library_name(""));
+
+ if (lib_name == "") {
+ error("missing \"load\" attribute at ", node);
+ return false;
+ }
+ _list.insert(new (env.alloc())
+ External_entry(lib_name.string(), _load_factory(env, lib_name)));
+ } else {
+ Library_name const lib_name = _library_name(node.type());
+
+ _list.insert(new (env.alloc())
+ External_entry(node.type().string(), _load_factory(env, lib_name)));
+ }
} catch (Factory_not_available) { return false; }
+ return true;
}
--
2.30.0
From 490fb611ceaad9ae67af35c22ac40dd65ddd7a42 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 3 Feb 2021 17:33:24 +0100
Subject: [PATCH 13/16] vfs: increase the capacity of tar ROM labels to 128
---
repos/os/src/lib/vfs/tar_file_system.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repos/os/src/lib/vfs/tar_file_system.h b/repos/os/src/lib/vfs/tar_file_system.h
index d9941deb5f..fcb06a1459 100644
--- a/repos/os/src/lib/vfs/tar_file_system.h
+++ b/repos/os/src/lib/vfs/tar_file_system.h
@@ -27,7 +27,7 @@ class Vfs::Tar_file_system : public File_system
Genode::Env &_env;
Genode::Allocator &_alloc;
- typedef Genode::String<64> Rom_name;
+ typedef Genode::String<128> Rom_name;
Rom_name _rom_name;
Genode::Attached_rom_dataspace _tar_ds { _env, _rom_name.string() };
--
2.30.0
From a9900477faf8d9d41dbe3fa59a0b40ce5cab037f Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 10 Feb 2021 13:32:42 +0100
Subject: [PATCH 14/16] Detect destroyed argument buffers at Env::session
Session request arguments are silently zeroed when their length
exceedes some buffer size.
---
repos/base/src/lib/base/component.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/repos/base/src/lib/base/component.cc b/repos/base/src/lib/base/component.cc
index 568be31efb..913687ea7f 100644
--- a/repos/base/src/lib/base/component.cc
+++ b/repos/base/src/lib/base/component.cc
@@ -122,6 +122,10 @@ namespace {
Affinity const &affinity) override
{
Mutex::Guard guard(_mutex);
+ if (!args.valid_string()) {
+ error("invalid args for ", name.string(), " service request");
+ throw Service_denied();
+ }
/*
* Since we account for the backing store for session meta data on
--
2.30.0
From d2da7f94d328336ab6ac618ff5779ae8093c5e9d Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 11 Feb 2021 14:10:50 +0100
Subject: [PATCH 15/16] Increase session arguments buffer size to 240 bytes
---
repos/base/include/parent/parent.h | 2 +-
repos/base/include/root/root.h | 2 +-
repos/base/lib/symbols/ld | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/repos/base/include/parent/parent.h b/repos/base/include/parent/parent.h
index 7379342e5b..6e94047788 100644
--- a/repos/base/include/parent/parent.h
+++ b/repos/base/include/parent/parent.h
@@ -54,7 +54,7 @@ class Genode::Parent
public:
typedef Rpc_in_buffer<64> Service_name;
- typedef Rpc_in_buffer<160> Session_args;
+ typedef Rpc_in_buffer<240> Session_args;
typedef Rpc_in_buffer<160> Upgrade_args;
struct Client : Interface { typedef Id_space<Client>::Id Id; };
diff --git a/repos/base/include/root/root.h b/repos/base/include/root/root.h
index c7e3a0c908..4fda9e341f 100644
--- a/repos/base/include/root/root.h
+++ b/repos/base/include/root/root.h
@@ -29,7 +29,7 @@ namespace Genode {
struct Genode::Root
{
- typedef Rpc_in_buffer<160> Session_args;
+ typedef Rpc_in_buffer<240> Session_args;
typedef Rpc_in_buffer<160> Upgrade_args;
virtual ~Root() { }
diff --git a/repos/base/lib/symbols/ld b/repos/base/lib/symbols/ld
index 3cfbdd7466..d7603e8ca4 100644
--- a/repos/base/lib/symbols/ld
+++ b/repos/base/lib/symbols/ld
@@ -398,6 +398,8 @@ _ZThn236_N5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_
_ZThn236_N5Timer10Connection9curr_timeEv T
_ZThn288_N5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_handlerE T
_ZThn288_N5Timer10Connection9curr_timeEv T
+_ZThn368_N5Timer10Connection11set_timeoutEN6Genode12MicrosecondsERNS1_15Timeout_handlerE T
+_ZThn368_N5Timer10Connection9curr_timeEv T
_ZThn8_N6Genode17Timeout_scheduler14handle_timeoutENS_8DurationE T
_ZThn8_N6Genode17Timeout_schedulerD0Ev T
_ZThn8_N6Genode17Timeout_schedulerD1Ev T
--
2.30.0
From 9b1a5e00ba1fc7fccfec5ba6671c6e80e428f129 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Fri, 19 Feb 2021 16:09:23 +0100
Subject: [PATCH 16/16] ldso: increase size of library names
---
repos/base/src/lib/ldso/include/config.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repos/base/src/lib/ldso/include/config.h b/repos/base/src/lib/ldso/include/config.h
index 5708df0930..db9014a95b 100644
--- a/repos/base/src/lib/ldso/include/config.h
+++ b/repos/base/src/lib/ldso/include/config.h
@@ -58,7 +58,7 @@ class Linker::Config : Noncopyable
bool verbose() const { return _verbose; }
bool check_ctors() const { return _check_ctors; }
- typedef String<100> Rom_name;
+ typedef String<128> Rom_name;
/**
* Call fn for each library specified in the configuration
--
2.30.0

@ -1,176 +0,0 @@
From a3063497d9aaf6bf06a3797804135105ad5f3bad Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 3 Dec 2020 12:19:10 +0100
Subject: [PATCH 1/3] vfs: create missing root directories for writeable
sessions
This is the expected behavior.
---
repos/os/src/server/vfs/main.cc | 47 ++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/repos/os/src/server/vfs/main.cc b/repos/os/src/server/vfs/main.cc
index b780b1fdd7..358afd28a9 100644
--- a/repos/os/src/server/vfs/main.cc
+++ b/repos/os/src/server/vfs/main.cc
@@ -841,6 +841,41 @@ class Vfs_server::Root : public Genode::Root_component<Session_component>,
Genode::Signal_transmitter(_reactivate_handler).submit();
}
+ /**
+ * Open a directory, ensuring all parent directories exists.
+ */
+ void _create_session_dir(Path const &path)
+ {
+ using namespace Genode;
+ typedef Vfs::Directory_service::Opendir_result Result;
+
+ Vfs_handle *handle { nullptr };
+ Vfs::File_system &vfs = _vfs_env.root_dir();
+
+ switch (vfs.opendir(path.string(), true, &handle, _vfs_heap)) {
+ case Result::OPENDIR_OK:
+ handle->close();
+ return;
+ case Result::OPENDIR_ERR_NODE_ALREADY_EXISTS:
+ if (vfs.directory(path.string())) return;
+ break;
+ case Result::OPENDIR_ERR_LOOKUP_FAILED: {
+ Path parent = path;
+ parent.strip_last_element();
+ _create_session_dir(parent.string());
+ auto res = vfs.opendir(path.string(), true, &handle, _vfs_heap);
+ if (res == Result::OPENDIR_OK) {
+ handle->close();
+ return;
+ }
+ }
+ default: break;
+ }
+
+ error("cannot create session root at ", path);
+ throw Service_denied();
+ }
+
protected:
Session_component *_create_session(const char *args) override
@@ -916,10 +951,14 @@ class Vfs_server::Root : public Genode::Root_component<Session_component>,
}
/* check if the session root exists */
- if (!((session_root == "/")
- || _vfs_env.root_dir().directory(session_root.base()))) {
- error("session root '", session_root, "' not found for '", label, "'");
- throw Service_denied();
+ if (session_root != "/") {
+ if (!_vfs_env.root_dir().directory(session_root.base())) {
+ if (writeable) { _create_session_dir(session_root); }
+ else {
+ error("session root '", session_root, "' not found for '", label, "'");
+ throw Service_denied();
+ }
+ }
}
Session_component *session = new (md_alloc())
--
2.30.0
From 0c91101db93422a4ff0aa2407b0ac7610abcf14f Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 3 Feb 2021 15:20:39 +0100
Subject: [PATCH 2/3] vfs: support for loading plugins by label
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Make the VFS plugin recognize <plugin label="…"/> nodes.
---
repos/os/src/lib/vfs/file_system_factory.cc | 33 ++++++++++++++++-----
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/repos/os/src/lib/vfs/file_system_factory.cc b/repos/os/src/lib/vfs/file_system_factory.cc
index 5cdf20e8e3..1cf5d587ea 100644
--- a/repos/os/src/lib/vfs/file_system_factory.cc
+++ b/repos/os/src/lib/vfs/file_system_factory.cc
@@ -56,8 +56,16 @@ struct Vfs::Global_file_system_factory::Entry_base : Vfs::File_system_factory,
Entry_base(Fs_type_name const &name) : name(name) { }
- bool matches(Genode::Xml_node node) const {
- return node.has_type(name.string()); }
+ bool matches(Genode::Xml_node node) const
+ {
+ if (node.has_type(name.string()))
+ return true;
+
+ if (node.has_type("plugin") && node.has_attribute("load"))
+ return node.attribute("load").has_value(name.string());
+
+ return false;
+ }
};
@@ -165,14 +173,25 @@ Vfs::File_system_factory &Vfs::Global_file_system_factory::_load_factory(Vfs::En
bool Vfs::Global_file_system_factory::_probe_external_factory(Vfs::Env &env,
Genode::Xml_node node)
{
- Library_name const lib_name = _library_name(node.type());
-
try {
- _list.insert(new (env.alloc())
- External_entry(node.type().string(), _load_factory(env, lib_name)));
- return true;
+ if (node.has_type("plugin")) {
+ Library_name const lib_name = node.attribute_value("load", Library_name(""));
+
+ if (lib_name == "") {
+ error("missing \"load\" attribute at ", node);
+ return false;
+ }
+ _list.insert(new (env.alloc())
+ External_entry(lib_name.string(), _load_factory(env, lib_name)));
+ } else {
+ Library_name const lib_name = _library_name(node.type());
+
+ _list.insert(new (env.alloc())
+ External_entry(node.type().string(), _load_factory(env, lib_name)));
+ }
} catch (Factory_not_available) { return false; }
+ return true;
}
--
2.30.0
From d2b15cb52415d18b9611862d9d184effc596bba6 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 3 Feb 2021 17:33:24 +0100
Subject: [PATCH 3/3] vfs: increase the capacity of tar ROM labels to 128
---
repos/os/src/lib/vfs/tar_file_system.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repos/os/src/lib/vfs/tar_file_system.h b/repos/os/src/lib/vfs/tar_file_system.h
index d9941deb5f..fcb06a1459 100644
--- a/repos/os/src/lib/vfs/tar_file_system.h
+++ b/repos/os/src/lib/vfs/tar_file_system.h
@@ -27,7 +27,7 @@ class Vfs::Tar_file_system : public File_system
Genode::Env &_env;
Genode::Allocator &_alloc;
- typedef Genode::String<64> Rom_name;
+ typedef Genode::String<128> Rom_name;
Rom_name _rom_name;
Genode::Attached_rom_dataspace _tar_ds { _env, _rom_name.string() };
--
2.30.0

@ -1,27 +0,0 @@
From 3898cf557ada28312731292074a8a09621d45abb Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Sat, 7 Nov 2020 13:49:41 +0100
Subject: [PATCH] init: log error when configuration cannot be parsed
---
repos/os/src/init/main.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/repos/os/src/init/main.cc b/repos/os/src/init/main.cc
index 7b69c95721..f1c1a1435a 100644
--- a/repos/os/src/init/main.cc
+++ b/repos/os/src/init/main.cc
@@ -47,6 +47,10 @@ struct Init::Main : Sandbox::State_handler
_config.update();
Xml_node const config = _config.xml();
+ if (config.has_type("empty")) {
+ error("failed to parse config ROM");
+ return;
+ };
bool reporter_enabled = false;
config.with_sub_node("report", [&] (Xml_node report) {
--
2.28.0
Loading…
Cancel
Save