Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-04 Thread JP Kobryn
On Sun, Dec 03, 2023 at 02:32:15PM +0900, Dominique Martinet wrote: > Steven Rostedt wrote on Sat, Dec 02, 2023 at 11:15:24PM -0500: > > > Also, for custom tracepoints e.g. bpftrace the program needs to know how > > > many bytes can be read safely even if it's just for dumping -- unless > > > dynam

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-02 Thread Dominique Martinet
Steven Rostedt wrote on Sat, Dec 02, 2023 at 11:15:24PM -0500: > > Also, for custom tracepoints e.g. bpftrace the program needs to know how > > many bytes can be read safely even if it's just for dumping -- unless > > dynamic_array is a "fat pointer" that conveys its own size? > > (Sorry didn't tak

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-02 Thread Steven Rostedt
On Sun, 3 Dec 2023 10:33:32 +0900 Dominique Martinet wrote: > > TP_printk("clnt %lu %s(tag = %d)\n%.3x: %16ph\n%.3x: %16ph\n", > > (unsigned long)__entry->clnt, > > show_9p_op(__entry->type), > > __entry->tag, 0, __get_dynamic_array(line),

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-02 Thread Dominique Martinet
Steven Rostedt wrote on Sat, Dec 02, 2023 at 08:14:09PM -0500: > > AFAICS __entry is a local variable on stack, and array __entry->line not > > intialized with zeros, i.e. the dump would contain trash at the end. Maybe > > prepending memset() before memcpy()? Well spotted! Now I'm thinking about i

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-02 Thread Steven Rostedt
On Sat, 02 Dec 2023 14:05:24 +0100 Christian Schoenebeck wrote: > > > --- a/include/trace/events/9p.h > > > +++ b/include/trace/events/9p.h > > > @@ -185,7 +185,8 @@ TRACE_EVENT(9p_protocol_dump, > > > __entry->clnt = clnt; > > > __entry->type = pdu->id; > > >

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-02 Thread Christian Schoenebeck
On Saturday, December 2, 2023 5:35:18 AM CET asmad...@codewreck.org wrote: > JP Kobryn wrote on Fri, Dec 01, 2023 at 07:04:10PM -0800: > > An out of bounds read can occur within the tracepoint 9p_protocol_dump(). > > In the fast assign, there is a memcpy that uses a constant size of 32 > > (macro d

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-01 Thread asmadeus
asmad...@codewreck.org wrote on Sat, Dec 02, 2023 at 01:35:18PM +0900: > > diff --git a/include/trace/events/9p.h b/include/trace/events/9p.h > > index 4dfa6d7f83ba..8690a7086252 100644 > > --- a/include/trace/events/9p.h > > +++ b/include/trace/events/9p.h > > @@ -185,7 +185,8 @@ TRACE_EVENT(9p_pr

Re: [PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-01 Thread asmadeus
JP Kobryn wrote on Fri, Dec 01, 2023 at 07:04:10PM -0800: > An out of bounds read can occur within the tracepoint 9p_protocol_dump(). > In the fast assign, there is a memcpy that uses a constant size of 32 > (macro definition as P9_PROTO_DUMP_SZ). When the copy is invoked, the > source buffer is no

[PATCH] 9p: prevent read overrun in protocol dump tracepoint

2023-12-01 Thread JP Kobryn
An out of bounds read can occur within the tracepoint 9p_protocol_dump(). In the fast assign, there is a memcpy that uses a constant size of 32 (macro definition as P9_PROTO_DUMP_SZ). When the copy is invoked, the source buffer is not guaranteed match this size. It was found that in some cases the