Re: [PATCH v2 03/11] unwind: Introduce SFrame user space unwinding
From: Steven Rostedt
Date: Tue Oct 01 2024 - 14:35:46 EST
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.
When I look at code that reads user space, I do not look at it as if it
were made by the compiler. I look at it as if it were made by someone
that's trying to find ways to crack the system. Every read from user space
*must* be validated *every* time it's read. It can not even validate it
once and then think its immutable (unless the kernel actually made it
immutable).
-- Steve