Re: [PATCH RFC v6 4/5] iio: osf: add authenticated stream parser

From: Jonathan Cameron

Date: Mon Jun 29 2026 - 19:06:44 EST


On Mon, 29 Jun 2026 17:10:31 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Mon, Jun 29, 2026 at 04:13:36AM +0900, Jinseob Kim wrote:
> > Add a UART byte-stream parser for Open Sensor Fusion frames.
> >
> > The parser searches for the OSF0 wire magic, keeps partial frames
> > buffered, checks header length and payload bounds, and passes complete
> > candidate frames to the core decoder.
> >
> > Rejected candidate frames drop only the current head byte before
> > resynchronizing, so a corrupted unauthenticated payload length cannot
> > make the parser skip later valid frames.
>
> ...
>
> > +#define OSF_STREAM_MAGIC_LEN 4
> > +#define OSF_STREAM_MAX_PAYLOAD_LEN \
> > + (OSF_STREAM_MAX_FRAME_LEN - OSF_FRAME_HEADER_LEN - OSF_FRAME_CRC_LEN)
> > +
> > +static const u8 osf_stream_magic[OSF_STREAM_MAGIC_LEN] = {
> > + 'O', 'S', 'F', '0',
> > +};
>
> You have already this in the header (as FourCC), use that.
>
> ...
>
> > +static size_t osf_stream_discard_to_magic(struct osf_stream *stream)
> > +{
> > + size_t old_len = stream->len;
> > + size_t match_len;
>
> > + size_t i;
> > +
> > + for (i = 0; i < stream->len; i++) {
>
> for (size_t i = 0; i < stream->len; i++) {
>
> > + match_len = stream->len - i;
> > + if (match_len > OSF_STREAM_MAGIC_LEN)
> > + match_len = OSF_STREAM_MAGIC_LEN;
> > +
> > + if (osf_stream_magic_match(stream->buf + i, match_len)) {
> > + if (i)
> > + osf_stream_discard(stream, i);
> > + return i;
> > + }
> > + }
> > +
> > + stream->len = 0;
> > + return old_len;
> > +}
>
> ...
>
> I stop here, because it's obvious that you neglected and ignored my previous
> reviews. No explanation given, nothing. This is not how you should interact
> with the community.
>
> Come again when each of the given comment will be either addressed or argued.
>
Likewise. Please make sure to address every comment either through
changes or through reply to the earlier thread. Perhaps some emails
have gone astray (it happens!). It can be a good idea to take a quick
look at lore.kernel.org to make sure you aren't missing any feedback
on a previous version.

Thanks,

Jonathan