[PATCH 2/3] lib: sbi: sse: Disable injection if callbacks are set

Clément Léger cleger at rivosinc.com
Tue Dec 10 01:23:37 PST 2024



On 09/12/2024 19:46, Atish Kumar Patra wrote:
> On Fri, Dec 6, 2024 at 1:00 PM Clément Léger <cleger at rivosinc.com> wrote:
>>
>> Once a 'driver' as registered callback for an event, disable event
>> injection for that event to avoid messing up with the driver.
>>
> 
> Why ? To avoid DoS type attacks ?
> 
> Otherwise, I think inject is useful to test/debug the driver without
> actually triggering the hardware events which can generate the SSE.

Yeah, this is not strictly necessary, but that does not seemed right to
me to allow generating event without any real reason. This can be
dropped if needed.

Clément

> 
>> Signed-off-by: Clément Léger <cleger at rivosinc.com>
>> ---
>>  lib/sbi/sbi_sse.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/lib/sbi/sbi_sse.c b/lib/sbi/sbi_sse.c
>> index 5679c26f..f9340381 100644
>> --- a/lib/sbi/sbi_sse.c
>> +++ b/lib/sbi/sbi_sse.c
>> @@ -887,6 +887,9 @@ int sbi_sse_set_cb_ops(uint32_t event_id, const struct sbi_sse_cb_ops *cb_ops)
>>                 return SBI_EINVAL;
>>
>>         e->cb_ops = cb_ops;
>> +       /* Do not mess with events that are handled by drivers */
>> +       e->attrs.status &= ~BIT(SBI_SSE_ATTR_STATUS_INJECT_OFFSET);
>> +
>>         sse_event_put(e);
>>
>>         return SBI_OK;
>> --
>> 2.45.2
>>




More information about the opensbi mailing list