Page MenuHomeFreeBSD

systm: Relax __result_use_check annotations
ClosedPublic

Authored by markj on Jan 12 2024, 3:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jun 5, 2:06 PM
Unknown Object (File)
Apr 27 2024, 10:41 AM
Unknown Object (File)
Apr 27 2024, 10:40 AM
Unknown Object (File)
Apr 27 2024, 10:40 AM
Unknown Object (File)
Apr 27 2024, 9:43 AM
Unknown Object (File)
Apr 27 2024, 3:53 AM
Unknown Object (File)
Feb 25 2024, 6:17 AM
Unknown Object (File)
Feb 5 2024, 3:01 PM
Subscribers

Details

Summary

When compiling with gcc, functions annotated this way can not have their
return values cast away, e.g., with (void)copyout(...). clang permits
it but gcc does not. Since we have a number of such casts for calls
which copy data out of the kernel, and since failing to check for errors
when copying *in* is a much larger problem, remove some of the
annotations in order to make the gcc build happy.

Reported by: Jenkins
Fixes: 8e36732e6eb5 ("systm: Annotate copyin() and related functions with __result_use_check")

Diff Detail

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

Event Timeline

markj requested review of this revision.Jan 12 2024, 3:10 PM

Would it make more sense to change __result_use_check to be off for gcc for now?
It would be also useful to have some symbol that turn them forcibly on/off.

In D43418#989890, @kib wrote:

Would it make more sense to change __result_use_check to be off for gcc for now?
It would be also useful to have some symbol that turn them forcibly on/off.

I think my original change was just too aggressive. It's sometimes ok to ignore the return value of copyout(), and gcc documentation for this attribute states, "This is useful for functions where not checking the result is either a security problem or always a bug". This description applies to copyin(), but not to copyout().

This revision is now accepted and ready to land.Jan 12 2024, 4:09 PM
This revision was automatically updated to reflect the committed changes.