commit:     3b4fbfbc8064d05456ebe58fcac91c913fe1c8cf
Author:     Sven Wegener <swegener <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 18:21:17 2026 +0000
Commit:     Sven Wegener <swegener <AT> gentoo <DOT> org>
CommitDate: Sat Jan  3 18:25:43 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3b4fbfbc

sys-kernel/cryptodev: fix building for linux-6.18

Signed-off-by: Sven Wegener <swegener <AT> gentoo.org>

 sys-kernel/cryptodev/cryptodev-1.14.ebuild         |  6 ++-
 .../files/cryptodev-1.14-linux-6.18.patch          | 51 ++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/sys-kernel/cryptodev/cryptodev-1.14.ebuild 
b/sys-kernel/cryptodev/cryptodev-1.14.ebuild
index 8c8d732f2bc2..407bb12cd483 100644
--- a/sys-kernel/cryptodev/cryptodev-1.14.ebuild
+++ b/sys-kernel/cryptodev/cryptodev-1.14.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2025 Gentoo Authors
+# Copyright 1999-2026 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -26,6 +26,10 @@ DEPEND="virtual/linux-sources"
 #test requires that the module is already loaded
 RESTRICT="test"
 
+PATCHES=(
+       "${FILESDIR}"/${P}-linux-6.18.patch
+)
+
 pkg_pretend() {
        use kernel_linux || die "cryptodev ebuild only support linux"
 

diff --git a/sys-kernel/cryptodev/files/cryptodev-1.14-linux-6.18.patch 
b/sys-kernel/cryptodev/files/cryptodev-1.14-linux-6.18.patch
new file mode 100644
index 000000000000..6627350d75e0
--- /dev/null
+++ b/sys-kernel/cryptodev/files/cryptodev-1.14-linux-6.18.patch
@@ -0,0 +1,51 @@
+From 08644db02d43478f802755903212f5ee506af73b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= <[email protected]>
+Date: Sat, 6 Sep 2025 20:36:38 +0000
+Subject: [PATCH] Fix build for Linux 6.18-rc1
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It's no longer required to use nth_page() when iterating pages within a
+single scatterlist entry.
+
+Note I believe this code path in `sg_advance` is currently unreachable:
+It is only called from `get_userbuf_srtp`, passing in a scatterlist
+copied from one created by `__get_userbuf`, which only generates
+entries such that `sg->offset + sg->length <= PAGE_SIZE`.
+On the other hand, this code path in `sg_advance` requires that
+`sg->offset + sg->length > sg->offset + consumed >= PAGE_SIZE`.
+
+See also: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f8f03eb5f0f91fddc9bb8563c7e82bd7d3ba1dd0
+          
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce00897b94bc5c62fab962625efcf1ab824d3688
+
+Signed-off-by: Joan Bruguera Micó <[email protected]>
+---
+ util.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/util.c b/util.c
+index 9eba483..d426781 100644
+--- a/util.c
++++ b/util.c
+@@ -21,6 +21,7 @@
+ 
+ #include <crypto/scatterwalk.h>
+ #include <linux/scatterlist.h>
++#include <linux/version.h>
+ #include "util.h"
+ 
+ /* These were taken from Maxim Levitsky's patch to lkml.
+@@ -44,8 +45,12 @@ struct scatterlist *sg_advance(struct scatterlist *sg, int 
consumed)
+       sg->length -= consumed;
+ 
+       if (sg->offset >= PAGE_SIZE) {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 18, 0))
++              struct page *page = sg_page(sg) + (sg->offset / PAGE_SIZE);
++#else
+               struct page *page =
+                       nth_page(sg_page(sg), sg->offset / PAGE_SIZE);
++#endif
+               sg_set_page(sg, page, sg->length, sg->offset % PAGE_SIZE);
+       }
+ 

Reply via email to