1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-12 01:20:14 +00:00
Joel Granados 2dc164a48e 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>
2025-11-27 15:43:20 +01:00
..
2025-10-04 11:28:45 -07:00
2025-10-03 17:41:12 -07:00
2025-10-07 08:40:15 -07:00
2025-10-04 11:13:11 -07:00
2025-10-07 08:40:15 -07:00
2025-10-02 15:17:01 -07:00
2025-10-11 16:06:04 -07:00
2025-08-30 10:15:28 -04:00
2025-09-30 08:22:16 -07:00
2025-10-02 18:44:54 -07:00
2025-10-02 18:44:54 -07:00
2025-09-25 09:23:54 +02:00
2025-09-29 11:20:29 -07:00
2025-09-29 11:20:29 -07:00
2025-09-29 11:20:29 -07:00
2025-10-02 18:44:54 -07:00
2025-09-25 09:23:54 +02:00
2025-09-29 11:20:29 -07:00