Re: [PATCH v2 03/11] unwind: Introduce SFrame user space unwinding

From: Florian Weimer
Date: Wed Oct 02 2024 - 04:18:45 EST


* Steven Rostedt:

> On Tue, 1 Oct 2024 11:20:35 -0700
> Indu Bhagat <indu.bhagat@xxxxxxxxxx> wrote:
>
>> > So we trust user space to have this table sorted?
>> >
>>
>> GNU ld will create this table sorted when linking .sframe sections and
>> will set SFRAME_F_FDE_SORTED in flags in the output .sframe section. In
>> the current patch, I see the __sframe_add_section () includes a check
>> for SFRAME_F_FDE_SORTED for admitting SFrame sections.
>>
>> So proceeding here with the assumption that the SFrame FDE list is
>> sorted should work fine.
>
> No not at all! We *cannot trust* user space. This could lead to a security
> hole if we assume it's sorted. The kernel must not trust anything it
> receives from user space. Because an attacker will be looking for ways to
> confuse the kernel to exploit it.

I don't quite understand, sorry.

Doing a binary search on an unordered table fails to find some entries
that could be discovered by a linear scan. But an attacker could just
as well use an incomplete table from the start. So assuming an ordered
table seems rather unlikely to introduce additional problems. (Given
the lack of a formal threat model, it's impossible to make more precise
claims in either direction.)

Thanks,
Florian