|
| 1 | +From 08644db02d43478f802755903212f5ee506af73b Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= < [email protected]> |
| 3 | +Date: Sat, 6 Sep 2025 20:36:38 +0000 |
| 4 | +Subject: [PATCH] Fix build for Linux 6.18-rc1 |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +It's no longer required to use nth_page() when iterating pages within a |
| 10 | +single scatterlist entry. |
| 11 | + |
| 12 | +Note I believe this code path in `sg_advance` is currently unreachable: |
| 13 | +It is only called from `get_userbuf_srtp`, passing in a scatterlist |
| 14 | +copied from one created by `__get_userbuf`, which only generates |
| 15 | +entries such that `sg->offset + sg->length <= PAGE_SIZE`. |
| 16 | +On the other hand, this code path in `sg_advance` requires that |
| 17 | +`sg->offset + sg->length > sg->offset + consumed >= PAGE_SIZE`. |
| 18 | + |
| 19 | +See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f8f03eb5f0f91fddc9bb8563c7e82bd7d3ba1dd0 |
| 20 | + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce00897b94bc5c62fab962625efcf1ab824d3688 |
| 21 | + |
| 22 | +Signed-off-by: Joan Bruguera Micó < [email protected]> |
| 23 | +--- |
| 24 | + util.c | 5 +++++ |
| 25 | + 1 file changed, 5 insertions(+) |
| 26 | + |
| 27 | +--- a/util.c |
| 28 | ++++ b/util.c |
| 29 | +@@ -21,6 +21,7 @@ |
| 30 | + |
| 31 | + #include <crypto/scatterwalk.h> |
| 32 | + #include <linux/scatterlist.h> |
| 33 | ++#include <linux/version.h> |
| 34 | + #include "util.h" |
| 35 | + |
| 36 | + /* These were taken from Maxim Levitsky's patch to lkml. |
| 37 | +@@ -44,8 +45,12 @@ struct scatterlist *sg_advance(struct sc |
| 38 | + sg->length -= consumed; |
| 39 | + |
| 40 | + if (sg->offset >= PAGE_SIZE) { |
| 41 | ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 18, 0)) |
| 42 | ++ struct page *page = sg_page(sg) + (sg->offset / PAGE_SIZE); |
| 43 | ++#else |
| 44 | + struct page *page = |
| 45 | + nth_page(sg_page(sg), sg->offset / PAGE_SIZE); |
| 46 | ++#endif |
| 47 | + sg_set_page(sg, page, sg->length, sg->offset % PAGE_SIZE); |
| 48 | + } |
| 49 | + |
0 commit comments