From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794063794; b=Pg927BLVgTGh3uW49Gt6dNk/WOO8N9YFVRdGraari8EKkDY82H4qz1VytYNu7m0jXb0Z 3TzlxFBLUVYZvK9vE21aHfT4mPEEHoUx/A5wLFxsdZLU443Nn6GvR0/etSaGdHCcK+ob9 8vMQs+2Z4Oej4l+poud/k4kHZv3V9VhO2vK65A+e9Sfb6gH0fhGX8ELYyIL6HomhoPaPU ms+p/vuWrImFRezwfAjGguV/YzA6lz5CXxxk3+BoHK63kMdpnMQm0e16EET8X+rVK/LUK 30c6ZH821NYqF2RdmDNXtqE6lQNL84WGUNjnrMjOAHyHrXtwYPCMKNGqdQd9lLUMkrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794063794; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=IhbXa5IHaM09bv+UGoUu5f5AXFenuf6YwA4rGsWnhzo=; b=t8jT090HtPSLgsyjHVmeXW4ju3lXxhG1ee28L28OfBEiSqG3j6DeRYk/vgXSjTK9B7/e 9sfWo0dHLWPoH5WdaHJE1kqIKvkV4iZPSs+qnWvHA+nmnojZzsaoT2j8LuLgvmzpV/kHb icNcbJgPYlOAREZlGGpwhGUQPcFeAofwt6jGbImEyqxyY/4QtD3wz4CJCKYEeIbmZyYe8 0swiMRfCqEP/6aOEu6lIaB7nctX5FFAWclwajgaBwROPd2oMChPkcLoY7aTmgjdZTpPpY wNX+BJ8ieI9hpa07+sRUOhLY99iKtgnWXtPaeVtSz1UvOE1tOjRqQQcrRwl2EXtJn6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oFTDB7UK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A516D606D826; Sat, 7 Nov 2026 15:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oFTDB7UK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58C331F0089F; Sat, 7 Nov 2026 15:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794063793; bh=IhbXa5IHaM09bv+UGoUu5f5AXFenuf6YwA4rGsWnhzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oFTDB7UK0HF6pzhHSyrcdJ1zw/fUCMnhfD822y6uFmqgzn74OEFxsb5Hm239z/JWr f23pYdZmLResxuX5vbejuUs4sQnFhy4yaiYCXaw6/esUXcLMcw89Jga79UWCIbk1kf hwNZefhkJypB2tj3nlvfnenQWCsoTLv5T4Vlk3l4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sami Tolvanen , Alice Ryhl , Gary Guo , Danilo Krummrich , Miguel Ojeda , Sasha Levin Subject: [PATCH 7.3 0007/1257] rust: irq: declare cfi_encoding for irqreturn Date: Sat, 7 Nov 2026 08:38:23 -0500 Message-ID: <20261107134939.638403179@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134939.434104957@linuxfoundation.org> References: <20261107134939.434104957@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sami Tolvanen [ Upstream commit 01f3e6b4b1c8c1748e59ba53631ab1f5d9ad0ea4 ] The IRQ callbacks return c_uint. C calls them through irq_handler_t, which returns enum irqreturn. kCFI encodes enum types by name even with integer normalization, so the type ids never match and every call fails the CFI check. Generate irqreturn as a newtype with a cfi_encoding, as is done for lru_status, and return bindings::irqreturn_t from the callbacks. Fixes: 0851d34a8cc3 ("rust: irq: add support for non-threaded IRQs and handlers") Fixes: 135d40523244 ("rust: irq: add support for threaded IRQs and handlers") Signed-off-by: Sami Tolvanen Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Acked-by: Danilo Krummrich Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261019-rust-cfi-fixes-v1-1-9503472ba738@google.com Signed-off-by: Miguel Ojeda [ sashal: Adjusted insertion context to preserve existing fwctl_rpc_scope CFI declarations. ] Signed-off-by: Sasha Levin --- rust/bindgen_parameters | 2 ++ rust/kernel/irq/request.rs | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/rust/bindgen_parameters b/rust/bindgen_parameters index 39aae62dca669..cbc0a302647e5 100644 --- a/rust/bindgen_parameters +++ b/rust/bindgen_parameters @@ -29,6 +29,8 @@ # enums that appear in indirect function calls should specify a cfi type --newtype-enum fwctl_rpc_scope --with-attribute-custom-enum=fwctl_rpc_scope='#[cfi_encoding="15fwctl_rpc_scope"]' +--newtype-enum irqreturn +--with-attribute-custom-enum=irqreturn='#[cfi_encoding="9irqreturn"]' --newtype-enum lru_status --with-attribute-custom-enum=lru_status='#[cfi_encoding="10lru_status"]' diff --git a/rust/kernel/irq/request.rs b/rust/kernel/irq/request.rs index c1c6525a676a7..1afa9fcaad1f6 100644 --- a/rust/kernel/irq/request.rs +++ b/rust/kernel/irq/request.rs @@ -25,10 +25,10 @@ #[repr(u32)] pub enum IrqReturn { /// The interrupt was not from this device or was not handled. - None = bindings::irqreturn_IRQ_NONE, + None = bindings::irqreturn::IRQ_NONE.0, /// The interrupt was handled by this device. - Handled = bindings::irqreturn_IRQ_HANDLED, + Handled = bindings::irqreturn::IRQ_HANDLED.0, } /// Callbacks for an IRQ handler. @@ -240,25 +240,28 @@ fn drop(self: Pin<&mut Self>) { /// # Safety /// /// This function should be only used as the callback in `request_irq`. -unsafe extern "C" fn handle_irq_callback(_irq: i32, ptr: *mut c_void) -> c_uint { +unsafe extern "C" fn handle_irq_callback( + _irq: i32, + ptr: *mut c_void, +) -> bindings::irqreturn_t { let ptr = ptr.cast_const().cast::>(); // SAFETY: `ptr` is a pointer to `Registration<'_, T>` set in `Registration::new()`. let registration = unsafe { &*ptr }; - T::handle(®istration.handler) as c_uint + bindings::irqreturn_t(T::handle(®istration.handler) as c_uint) } /// The value that can be returned from [`ThreadedHandler::handle`]. #[repr(u32)] pub enum ThreadedIrqReturn { /// The interrupt was not from this device or was not handled. - None = bindings::irqreturn_IRQ_NONE, + None = bindings::irqreturn::IRQ_NONE.0, /// The interrupt was handled by this device. - Handled = bindings::irqreturn_IRQ_HANDLED, + Handled = bindings::irqreturn::IRQ_HANDLED.0, /// The handler wants the handler thread to wake up. - WakeThread = bindings::irqreturn_IRQ_WAKE_THREAD, + WakeThread = bindings::irqreturn::IRQ_WAKE_THREAD.0, } /// Callbacks for a threaded IRQ handler. @@ -461,23 +464,26 @@ fn drop(self: Pin<&mut Self>) { unsafe extern "C" fn handle_threaded_irq_callback( _irq: i32, ptr: *mut c_void, -) -> c_uint { +) -> bindings::irqreturn_t { let ptr = ptr.cast_const().cast::>(); // SAFETY: `ptr` is a pointer to `ThreadedRegistration<'_, T>` set in // `ThreadedRegistration::new()`. let registration = unsafe { &*ptr }; - T::handle(®istration.handler) as c_uint + bindings::irqreturn_t(T::handle(®istration.handler) as c_uint) } /// # Safety /// /// This function should be only used as the callback in `request_threaded_irq`. -unsafe extern "C" fn thread_fn_callback(_irq: i32, ptr: *mut c_void) -> c_uint { +unsafe extern "C" fn thread_fn_callback( + _irq: i32, + ptr: *mut c_void, +) -> bindings::irqreturn_t { let ptr = ptr.cast_const().cast::>(); // SAFETY: `ptr` is a pointer to `ThreadedRegistration<'_, T>` set in // `ThreadedRegistration::new()`. let registration = unsafe { &*ptr }; - T::handle_threaded(®istration.handler) as c_uint + bindings::irqreturn_t(T::handle_threaded(®istration.handler) as c_uint) } -- 2.53.0