Page MenuHomeFreeBSD

LinuxKPI: add kstrtou32_from_user() and mac_pton()
ClosedPublic

Authored by bz on Oct 22 2022, 6:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 24, 8:22 AM
Unknown Object (File)
Nov 28 2024, 7:34 PM
Unknown Object (File)
Nov 22 2024, 1:43 AM
Unknown Object (File)
Nov 2 2024, 4:36 PM
Unknown Object (File)
Sep 30 2024, 8:09 PM
Unknown Object (File)
Sep 18 2024, 2:54 PM
Unknown Object (File)
Sep 11 2024, 1:28 PM
Unknown Object (File)
Sep 11 2024, 1:28 PM
Subscribers

Details

Summary

Add kstrtou32_from_user() based on other examples in the file.

Also add a rudimentarily hacked up version of mac_pton() which is
leanient accepting non-well-formed input but so far only with ':'
separators. It does not seem to obviously belong to any networking
header file so add it here.

Both are needed for debugfs supprot for iwlwifi.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

Test Plan

Someone should make sure the mac_pton does indeed work.

Diff Detail

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

Event Timeline

bz requested review of this revision.Oct 22 2022, 6:08 PM

Anyone? Or would it help if I split this up into two part?

Looks OK, even if there is duplication between kstrtou32_from_user and kstrtouint_from_user, and kstrtou32 and kstrtouint. I guess we can hope the compiler optimizes that away.

sys/compat/linuxkpi/common/include/linux/kernel.h
735

What about strings with too many digits, e.g. 123:456:....

Looks OK, even if there is duplication between kstrtou32_from_user and kstrtouint_from_user, and kstrtou32 and kstrtouint. I guess we can hope the compiler optimizes that away.

I am wondering why kstrtouint_from_user() has an int * argument and not an uint_t *? Otherwise we could probably #define one to the other (and the same for kstrtoxxx(). Should I just do that and fix the type? In that case probably splitting this up makes sense?

I am wondering why kstrtouint_from_user() has an int * argument and not an uint_t *

Oh, I didn't look close enough to spot that :)
Looks like it was a bug in 8e587a5f13ce676d7763ffa920148fe31bc3bfae

bz edited the test plan for this revision. (Show Details)

#redefine two u32 to the uint versions; fix an argument from int to uint
in one version.

Check for invalid long input in mac_pton().

@emaste (or anyone else) -- does this look better now?

Adding x11 as that is where the original kstrtouint_from_user() came from (now unsigned as it should have been).

Unless there's any further comments this will go in before the Christmas holidays.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 13 2023, 12:37 AM
This revision was automatically updated to reflect the committed changes.
bz marked an inline comment as done.