Page MenuHomeFreeBSD

kern: tty: fix ttyinq_read_uio assertion
ClosedPublic

Authored by kevans on Jan 9 2024, 6:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 28, 3:26 AM
Unknown Object (File)
Fri, Jun 28, 3:26 AM
Unknown Object (File)
Thu, Jun 27, 6:46 PM
Unknown Object (File)
Thu, Jun 27, 6:33 PM
Unknown Object (File)
May 4 2024, 1:17 PM
Unknown Object (File)
Apr 30 2024, 8:40 PM
Unknown Object (File)
Apr 24 2024, 8:53 PM
Unknown Object (File)
Apr 24 2024, 8:52 PM
Subscribers

Details

Summary

It's clear from later context that rlen was always expected to include
flen, as we'll trim flen bytes from the end of the read. Relax our
initial assertion to only require the total size less trimmed bytes to
lie within the out buffer size.

While we're here, I note that if we have to read more than one block and
we're trimming from the end then we'll do the wrong thing and omit
flen bytes from every block, rather than just the end. Add an
assertion to make sure we're not doing that, but the only caller that
specifies a non-zero flen today will only really be doing so if rlen
is entirely within a single buffer.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Jan 9 2024, 6:24 PM
cy added a subscriber: cy.

Looks reasonable.

This revision is now accepted and ready to land.Jan 9 2024, 8:07 PM

These look fine. one nit of a suggestion.
I've not gone and looked at all callers though to see if we can expect to see fallout or not. I don't think so, but...

sys/kern/tty_inq.c
168

I'd be tempted to have a MPASS(rlen >= flen) too

This revision was automatically updated to reflect the committed changes.