002-Fix-build-for-Linux-6.18-rc1.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. It's no longer required to use nth_page() when iterating pages within a
  9. single scatterlist entry.
  10. Note I believe this code path in `sg_advance` is currently unreachable:
  11. It is only called from `get_userbuf_srtp`, passing in a scatterlist
  12. copied from one created by `__get_userbuf`, which only generates
  13. entries such that `sg->offset + sg->length <= PAGE_SIZE`.
  14. On the other hand, this code path in `sg_advance` requires that
  15. `sg->offset + sg->length > sg->offset + consumed >= PAGE_SIZE`.
  16. See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f8f03eb5f0f91fddc9bb8563c7e82bd7d3ba1dd0
  17. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce00897b94bc5c62fab962625efcf1ab824d3688
  18. Signed-off-by: Joan Bruguera Micó <[email protected]>
  19. ---
  20. util.c | 5 +++++
  21. 1 file changed, 5 insertions(+)
  22. --- a/util.c
  23. +++ b/util.c
  24. @@ -21,6 +21,7 @@
  25. #include <crypto/scatterwalk.h>
  26. #include <linux/scatterlist.h>
  27. +#include <linux/version.h>
  28. #include "util.h"
  29. /* These were taken from Maxim Levitsky's patch to lkml.
  30. @@ -44,8 +45,12 @@ struct scatterlist *sg_advance(struct sc
  31. sg->length -= consumed;
  32. if (sg->offset >= PAGE_SIZE) {
  33. +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 18, 0))
  34. + struct page *page = sg_page(sg) + (sg->offset / PAGE_SIZE);
  35. +#else
  36. struct page *page =
  37. nth_page(sg_page(sg), sg->offset / PAGE_SIZE);
  38. +#endif
  39. sg_set_page(sg, page, sg->length, sg->offset % PAGE_SIZE);
  40. }