Page MenuHomeFreeBSD

linuxkpi: seq_read: Fix one by one error
ClosedPublic

Authored by manu on Dec 21 2022, 11:44 AM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 26 2024, 8:09 AM
Unknown Object (File)
Apr 26 2024, 8:09 AM
Unknown Object (File)
Apr 26 2024, 8:09 AM
Unknown Object (File)
Apr 26 2024, 12:50 AM
Unknown Object (File)
Dec 23 2023, 2:56 AM
Unknown Object (File)
Dec 22 2023, 10:50 AM
Unknown Object (File)
Dec 12 2023, 11:42 AM
Unknown Object (File)
Sep 19 2023, 8:16 AM

Details

Summary

strscpy needs the buffer length not the string length (so including
the '\0').

Fixes: f697b9432d9c ("linuxkpi: drm-kmod debugfs support")
Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

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

Event Timeline

manu requested review of this revision.Dec 21 2022, 11:44 AM

Thanks for finding this. I was under the impression the sbuf_len returned
the entire length of the sbuf including the null terminator. On second
thought, you're certainly right. This same fix should really be put on top
of this review, though.

https://reviews.freebsd.org/D37101

Or set SBUF_INCLUDENUL which will then return the + 1? Without looking based on @jfree 's comment is the logic between sbuf_len and the strscpy correct without the SBUF_INCLUDENUL?

Ignore me; the sbuf is finished further up (Phabricator had hid that) so we'll always get the len without the +1.

sys/compat/linuxkpi/common/src/linux_seq_file.c
66

That size < 1 check could go to the top as well?

This revision is now accepted and ready to land.Dec 21 2022, 4:46 PM

Thanks for finding this. I was under the impression the sbuf_len returned
the entire length of the sbuf including the null terminator. On second
thought, you're certainly right. This same fix should really be put on top
of this review, though.

https://reviews.freebsd.org/D37101

Wasn't aware of this one, it seems that there is still some questions about it so I'll commit this in the meantime so debugfs can work with drm.

This revision was automatically updated to reflect the committed changes.