Bug 275986 - [exp-run] annotate user memory copying functions with __result_use_check
Summary: [exp-run] annotate user memory copying functions with __result_use_check
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-28 17:45 UTC by Mark Johnston
Modified: 2024-01-11 14:38 UTC (History)
1 user (show)

See Also:
antoine: exp-run+


Attachments
patch (11.61 KB, patch)
2023-12-28 17:46 UTC, Mark Johnston
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Johnston freebsd_committer freebsd_triage 2023-12-28 17:45:34 UTC
The attached patch (applied onto src commit d068ea16e32 or later) modifies some kernel interfaces to force callers to do something with the return value.  It might break some kmod ports, so an exp-run of at least those ports would be appreciated.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2023-12-28 17:46:28 UTC
Created attachment 247321 [details]
patch

Attached the patch.
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2024-01-02 18:29:19 UTC
(In reply to Antoine Brodin from comment #2)
Thanks.  These all need to be patched.  I did that locally here:
https://github.com/markjdb/freebsd-ports/tree/main-copyinout-checking

Most of those ports don't have maintainers so I'm not sure how to get them approved.  I did create one review: https://reviews.freebsd.org/D43273

Would it be possible to retry with these patches, and see if any other kmods fail?
Comment 4 Antoine Brodin freebsd_committer freebsd_triage 2024-01-02 19:15:00 UTC
Ports patch approved.
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-01-03 01:01:46 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0524b7ffff66cbc220a165480cc553e8d18bdc91

commit 0524b7ffff66cbc220a165480cc553e8d18bdc91
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-02 18:07:59 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-03 00:59:29 +0000

    sysutils/mbgtools: Add error checking for copyin() and copyout() calls

    This will be required soon, and the previous lack of such error handling
    was a bug.

    PR:             275986
    Approved by:    antoine

 sysutils/mbgtools/Makefile                              |  1 +
 .../mbgtools/files/patch-mbglib_common_macioctl.h (new) | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-01-03 01:01:47 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=823c8faa750685c75c8a9a701f0e36808dd7bd48

commit 823c8faa750685c75c8a9a701f0e36808dd7bd48
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-02 18:10:47 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-03 01:00:26 +0000

    net/aoe: Fix error handling for a copyout() call

    This will soon be required by the base system.

    PR:             275986
    Approved by:    antoine

 net/aoe/Makefile                   |  2 +-
 net/aoe/files/patch-aoeblk.c (new) | 23 ++++++++++++++++++
 net/aoe/files/patch-aoecmd.c       | 48 ++++++++++++++++++++++++++++++++++----
 3 files changed, 67 insertions(+), 6 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-01-03 01:01:48 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e6728be27592820616fb830006265b973d1764d1

commit e6728be27592820616fb830006265b973d1764d1
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-02 18:21:22 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-03 01:00:31 +0000

    multimedia/linux_dvbwrapper: Add error handling for copyout() calls

    The base system will soon require all copyout() calls to have explicit
    handling of return values.

    PR:             275986
    Approved by:    antoine

 multimedia/linux_dvbwrapper-kmod/Makefile          |  2 +-
 .../files/patch-linux__dvbwrapper.c                | 31 ++++++++++++++++++----
 2 files changed, 27 insertions(+), 6 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-01-03 17:01:09 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=eaa12eb57a422be10df72d567aea693dcafc6c19

commit eaa12eb57a422be10df72d567aea693dcafc6c19
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-03 16:58:37 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-03 16:59:53 +0000

    comms/opencbm-kmod: Add error handling for copyin() and copyout() calls

    This will be required soon as my intent is to annotate copyin() and
    related functions with __result_use_check.  Moreover, the lack of error
    handling here is a real bug.

    The patch was submitted upstream as well.

    PR:             275986
    Approved by:    zirias
    Differential Revision:  https://reviews.freebsd.org/D43273

 comms/opencbm-kmod/Makefile                        |  1 +
 .../files/patch-compat-freebsd-14 (gone)           | 34 --------------
 comms/opencbm-kmod/files/patch-opencbm.c (new)     | 54 ++++++++++++++++++++++
 3 files changed, 55 insertions(+), 34 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-01-03 21:55:01 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d0d5a75f66a400f72b5206debdf60ca5fa05da53

commit d0d5a75f66a400f72b5206debdf60ca5fa05da53
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-02 18:18:53 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-03 21:53:33 +0000

    sysutils/acpi_call: Check for errors from copyout()

    The base system will soon require all copyout() calls to either preserve
    the return value or explicitly ignore it.

    PR:             275986
    Approved by:    antoine

 sysutils/acpi_call/Makefile                 |  2 +-
 sysutils/acpi_call/files/patch-acpi__call.c | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
Comment 10 Mark Johnston freebsd_committer freebsd_triage 2024-01-11 14:38:19 UTC
This is all committed now.  Thanks Antoine!