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, Oct 18, 11:08 PM
Unknown Object (File)
Fri, Oct 18, 11:08 PM
Unknown Object (File)
Fri, Oct 18, 11:08 PM
Unknown Object (File)
Fri, Oct 18, 10:34 PM
Unknown Object (File)
Oct 3 2024, 9:52 AM
Unknown Object (File)
Oct 2 2024, 12:47 PM
Unknown Object (File)
Oct 2 2024, 5:22 AM
Unknown Object (File)
Oct 2 2024, 5:00 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 55332
Build 52221: arc lint + arc unit

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.