lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250107035058.818539-12-alistair@alistair23.me>
Date: Tue,  7 Jan 2025 13:50:58 +1000
From: Alistair Francis <alistair@...stair23.me>
To: bhelgaas@...gle.com,
	rust-for-linux@...r.kernel.org,
	lukas@...ner.de,
	gary@...yguo.net,
	akpm@...ux-foundation.org,
	tmgross@...ch.edu,
	boqun.feng@...il.com,
	ojeda@...nel.org,
	linux-cxl@...r.kernel.org,
	bjorn3_gh@...tonmail.com,
	a.hindborg@...nel.org,
	me@...enk.dev,
	linux-kernel@...r.kernel.org,
	aliceryhl@...gle.com,
	alistair.francis@....com,
	linux-pci@...r.kernel.org,
	benno.lossin@...ton.me,
	alex.gaynor@...il.com,
	Jonathan.Cameron@...wei.com
Cc: alistair23@...il.com,
	wilfred.mallawa@....com,
	Alistair Francis <alistair@...stair23.me>,
	Dirk Behme <dirk.behme@...bosch.com>
Subject: [PATCH v5 11/11] rust: helpers: Remove uaccess helpers

Now that we support wrap-static-fns we no longer need the custom helper.

Signed-off-by: Alistair Francis <alistair@...stair23.me>
Tested-by: Dirk Behme <dirk.behme@...bosch.com>
---
 rust/bindgen_static_functions |  3 +++
 rust/helpers/helpers.c        |  6 ++----
 rust/helpers/uaccess.c        | 15 ---------------
 rust/kernel/uaccess.rs        |  5 +++--
 4 files changed, 8 insertions(+), 21 deletions(-)
 delete mode 100644 rust/helpers/uaccess.c

diff --git a/rust/bindgen_static_functions b/rust/bindgen_static_functions
index 8bc291a7a799..ec48ad2e8c78 100644
--- a/rust/bindgen_static_functions
+++ b/rust/bindgen_static_functions
@@ -27,3 +27,6 @@
 
 --allowlist-function get_task_struct
 --allowlist-function put_task_struct
+
+--allowlist-function copy_from_user
+--allowlist-function copy_to_user
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 2731ddf736dd..eae067fe2528 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions
- * cannot be called either. This file explicitly creates functions ("helpers")
- * that wrap those so that they can be called from Rust.
+ * Non-trivial C macros cannot be used in Rust. This file explicitly creates
+ * functions ("helpers") that wrap those so that they can be called from Rust.
  *
  * Sorted alphabetically.
  */
@@ -21,7 +20,6 @@
 #include "slab.c"
 #include "spinlock.c"
 #include "task.c"
-#include "uaccess.c"
 #include "vmalloc.c"
 #include "wait.c"
 #include "workqueue.c"
diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c
deleted file mode 100644
index f49076f813cd..000000000000
--- a/rust/helpers/uaccess.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#include <linux/uaccess.h>
-
-unsigned long rust_helper_copy_from_user(void *to, const void __user *from,
-					 unsigned long n)
-{
-	return copy_from_user(to, from, n);
-}
-
-unsigned long rust_helper_copy_to_user(void __user *to, const void *from,
-				       unsigned long n)
-{
-	return copy_to_user(to, from, n);
-}
diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs
index cc044924867b..d8f75de93073 100644
--- a/rust/kernel/uaccess.rs
+++ b/rust/kernel/uaccess.rs
@@ -226,7 +226,8 @@ pub fn read_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> Result {
         }
         // SAFETY: `out_ptr` points into a mutable slice of length `len`, so we may write
         // that many bytes to it.
-        let res = unsafe { bindings::copy_from_user(out_ptr, self.ptr as *const c_void, len) };
+        let res =
+            unsafe { bindings::copy_from_user(out_ptr, self.ptr as *const c_void, len as u64) };
         if res != 0 {
             return Err(EFAULT);
         }
@@ -330,7 +331,7 @@ pub fn write_slice(&mut self, data: &[u8]) -> Result {
         }
         // SAFETY: `data_ptr` points into an immutable slice of length `len`, so we may read
         // that many bytes from it.
-        let res = unsafe { bindings::copy_to_user(self.ptr as *mut c_void, data_ptr, len) };
+        let res = unsafe { bindings::copy_to_user(self.ptr as *mut c_void, data_ptr, len as u64) };
         if res != 0 {
             return Err(EFAULT);
         }
-- 
2.47.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ