diff options
| author | Joel Granados <joel.granados@kernel.org> | 2025-10-06 14:40:01 +0200 |
|---|---|---|
| committer | Joel Granados <joel.granados@kernel.org> | 2025-11-27 15:43:20 +0100 |
| commit | 2dc164a48e6fdb03066614e2b82464b9b7c790ca (patch) | |
| tree | e03d7aedc2450941d9a2754d2644e4ff9ab5cbf6 /tools/docs/parse-headers.py | |
| parent | 551bf1845027650ff6c9da598fb270ba362e9218 (diff) | |
sysctl: Create converter functions with two new macros
Eight converter functions are created using two new macros
(SYSCTL_USER_TO_KERN_INT_CONV & SYSCTL_KERN_TO_USER_INT_CONV); they are
called from four pre-existing converter functions: do_proc_dointvec_conv
and do_proc_dointvec{,_userhz,_ms}_jiffies_conv. The function names
generated by the macros are differentiated by a string suffix passed as
the first macro argument.
The SYSCTL_USER_TO_KERN_INT_CONV macro first executes the u_ptr_op
operation, then checks for overflow, assigns sign (-, +) and finally
writes to the kernel var with WRITE_ONCE; it always returns an -EINVAL
when an overflow is detected. The SYSCTL_KERN_TO_USER_INT_CONV uses
READ_ONCE, casts to unsigned long, then executes the k_ptr_op before
assigning the value to the user space buffer.
The overflow check is always done against MAX_INT after applying
{k,u}_ptr_op. This approach avoids rounding or precision errors that
might occur when using the inverse operations.
Signed-off-by: Joel Granados <joel.granados@kernel.org>
Diffstat (limited to 'tools/docs/parse-headers.py')
0 files changed, 0 insertions, 0 deletions
