genode/repos/base
Piotr Tworek 53a990579b base: Fix UAF in Genode::Pd_session_component::free
This was discovered when building the code with clang instead of GCC. In
this setup the run/ping on base-hw/arm_v8a/virt_qemu would crash
on shutdown due to uncaught Deref_unconstructed_object exception thrown
for Genode::Reconstructible<Genode::Account<Genode::Ram_quota>>. The
specific instance throwing this exception was
Pd_session_component::_ram_account. My investigation exposed the
following problem:

1. The Pd_session_component has a _sliced_heap member backed by
   _constrained_ram_alloc which in turn uses Pd_session_component itself
   as its Ram_allocator.
2. When ~Pd_session_component is called it first destroys _ram_account,
   followed by _signal_broker.
3. The signal broker holds a reference to
   Pd_session_component::_sliced_heap as Signal_broker::_md_alloc.
4. The base-hw implementation of ~Signal_broker destroys some contexts
   and does this by calling Genode::destroy on some slabs using the
   _md_alloc (ref to Pd_session_component::_sliced_heap).
5. The Genode::Slab calls the Ram_allocator::free which ends up calling
   Pd_session_component::free.
6. The Pd_session_component::free can among other things call replenish
   method on Pd_session_component::_ram_account which has already been
   freed at this point.

From my POV calling replenish at this point is basically an undefined
behavior. The Genode::Constructible holding the Genode::Account was
already detroyed at this point. GCC builds happen to somehow manage to
go through the -> operator call without raising any alarms, while clang
builds trip on the _check_constructed() call.

This fix moves the _ram_account a bit higher in class declaration to
ensure its destroyed after _sliced_heap. This seems like the simpliest
solution for this problem.

Fixes #3941
2020-11-23 12:02:58 +01:00
..
etc tools.conf: fix check for arm_64 2019-11-19 14:17:29 +01:00
include base: extend vm_session API with native vcpu cap 2020-11-23 12:02:58 +01:00
lib base: support process-local signal submission 2020-11-23 12:02:53 +01:00
mk base: remove alarm library from base 2020-10-09 13:33:36 +02:00
ports grub2: avoid hardcoding boot disc 2020-06-29 14:22:28 +02:00
recipes depot: update recipe hashes 2020-10-23 14:16:38 +02:00
run test/timer_rate: determine lowest accurate period 2020-10-09 13:37:10 +02:00
src base: Fix UAF in Genode::Pd_session_component::free 2020-11-23 12:02:58 +01:00
xsd base_types.xsd: allow session labels of length 0 2018-11-16 14:37:19 +01:00
README core: add information about infos provided by core 2017-06-29 11:59:52 +02:00

This is generic part of the Genode implementation. It consists of two parts:

:_Core_: is the ultimate root of the Genode application tree
  and provides abstractions for the lowest-level hardware resources
  such as RAM, ROM, CPU, and generic device access. All generic parts of Core
  can be found here - for system-specific implementations refer to the
  appropriate 'base-<system>' directory.

:_Base libraries and protocols_: that are used by each Genode component
  to interact with other components. This is the glue that holds everything
  together.

_Core_ may export information about the hardware platform by an ROM
called 'platform_info'. Depending on the platform, e.g. ARM or x86 or riscv,
and depending on the boot mode and boot loader and kernel, some nodes may not
be populated.

!<platform_info>
! <acpi revision="2" rsdt="0x1fe93074" xsdt="0x1fe930e8"/>
! <boot>
!   <framebuffer phys="0x7300000" width="1024" height="768" bpp="32"/>
! </boot>
!</platform_info>

If the ACPI RSDT and XSDT physical pointer is reported by the used kernel
and/or bootloader, _Core_ may provide this information by the ROM.

If the graphic device is initialised and can be directly used by a framebuffer
driver, _Core_ may provide the physical pointer to the framebuffer, the
resolution and color depth in bits.