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)
Sep 29 2024, 11:30 PM
Unknown Object (File)
Sep 29 2024, 11:14 PM
Unknown Object (File)
Sep 20 2024, 3:31 AM
Unknown Object (File)
Sep 16 2024, 9:10 PM
Unknown Object (File)
Sep 4 2024, 7:52 PM
Unknown Object (File)
Aug 31 2024, 9:51 PM
Unknown Object (File)
Aug 31 2024, 9:13 PM
Unknown Object (File)
Aug 26 2024, 11:22 PM

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.