summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-15 16:50:06 +0100
committerSimon Rettberg2024-01-15 16:50:06 +0100
commit596d8e1c0d50f2df3b87c119abdb4e7bc6c7e8ad (patch)
treee6bffe3219418289eefe1045030e8a119f4eebb3
parentFix Mr. Bauer's crimes against the kernel coding guidelines :) (diff)
downloadxloop-596d8e1c0d50f2df3b87c119abdb4e7bc6c7e8ad.tar.gz
xloop-596d8e1c0d50f2df3b87c119abdb4e7bc6c7e8ad.tar.xz
xloop-596d8e1c0d50f2df3b87c119abdb4e7bc6c7e8ad.zip
Make it build on 6.6 (to be tested)
-rw-r--r--src/kernel/xloop_file_fmt_raw.c108
-rw-r--r--src/kernel/xloop_main.c4
-rw-r--r--src/kernel/xloop_main.h4
3 files changed, 8 insertions, 108 deletions
diff --git a/src/kernel/xloop_file_fmt_raw.c b/src/kernel/xloop_file_fmt_raw.c
index f77476f..5f8d453 100644
--- a/src/kernel/xloop_file_fmt_raw.c
+++ b/src/kernel/xloop_file_fmt_raw.c
@@ -34,68 +34,6 @@ static inline loff_t __raw_file_fmt_rq_get_pos(struct xloop_file_fmt *xlo_fmt, s
return ((loff_t)blk_rq_pos(rq) << 9) + xlo->xlo_offset;
}
-/* transfer function for DEPRECATED cryptoxloop support */
-static inline int __raw_file_fmt_do_transfer(struct xloop_device *xlo, int cmd, struct page *rpage, unsigned int roffs,
- struct page *lpage, unsigned int loffs, int size, sector_t rblock)
-{
- int ret;
-
- ret = xlo->transfer(xlo, cmd, rpage, roffs, lpage, loffs, size, rblock);
- if (likely(!ret))
- return 0;
-
- pr_err_ratelimited("transfer error at byte offset %llu, length %i.\n", (unsigned long long)rblock << 9, size);
- return ret;
-}
-
-static int __raw_file_fmt_read_transfer(struct xloop_device *xlo, struct request *rq, loff_t pos)
-{
- struct bio_vec bvec, b;
- struct req_iterator iter;
- struct iov_iter i;
- struct page *page;
- ssize_t len;
- int ret = 0;
-
- page = alloc_page(GFP_NOIO);
- if (unlikely(!page))
- return -ENOMEM;
-
- rq_for_each_segment(bvec, rq, iter) {
- loff_t offset = pos;
-
- b.bv_page = page;
- b.bv_offset = 0;
- b.bv_len = bvec.bv_len;
-
- iov_iter_bvec(&i, READ, &b, 1, b.bv_len);
- len = vfs_iter_read(xlo->xlo_backing_file, &i, &pos, 0);
- if (len < 0) {
- ret = len;
- goto out_free_page;
- }
-
- ret = __raw_file_fmt_do_transfer(xlo, READ, page, 0, bvec.bv_page, bvec.bv_offset, len, offset >> 9);
- if (ret)
- goto out_free_page;
-
- flush_dcache_page(bvec.bv_page);
-
- if (len != bvec.bv_len) {
- struct bio *bio;
-
- __rq_for_each_bio(bio, rq)
- zero_fill_bio(bio);
- break;
- }
- }
-
- ret = 0;
-out_free_page:
- __free_page(page);
- return ret;
-}
-
static int raw_file_fmt_read(struct xloop_file_fmt *xlo_fmt, struct request *rq)
{
struct bio_vec bvec;
@@ -108,11 +46,8 @@ static int raw_file_fmt_read(struct xloop_file_fmt *xlo_fmt, struct request *rq)
xlo = xloop_file_fmt_get_xlo(xlo_fmt);
pos = __raw_file_fmt_rq_get_pos(xlo_fmt, rq);
- if (xlo->transfer)
- return __raw_file_fmt_read_transfer(xlo, rq, pos);
-
rq_for_each_segment(bvec, rq, iter) {
- iov_iter_bvec(&i, READ, &bvec, 1, bvec.bv_len);
+ iov_iter_bvec(&i, READ, &bvec, 1, bvec.bv_len); // READ -> ITER_DEST at some point
len = vfs_iter_read(xlo->xlo_backing_file, &i, &pos, 0);
if (len < 0)
return len;
@@ -286,40 +221,6 @@ static int __raw_file_fmt_write_bvec(struct file *file, struct bio_vec *bvec, lo
return bw;
}
-/*
- * This is the slow, transforming version that needs to double buffer the
- * data as it cannot do the transformations in place without having direct
- * access to the destination pages of the backing file.
- */
-static int __raw_file_fmt_write_transfer(struct xloop_device *xlo, struct request *rq, loff_t pos)
-{
- struct bio_vec bvec, b;
- struct req_iterator iter;
- struct page *page;
- int ret = 0;
-
- page = alloc_page(GFP_NOIO);
- if (unlikely(!page))
- return -ENOMEM;
-
- rq_for_each_segment(bvec, rq, iter) {
- ret = __raw_file_fmt_do_transfer(xlo, WRITE, page, 0, bvec.bv_page, bvec.bv_offset, bvec.bv_len,
- pos >> 9);
- if (unlikely(ret))
- break;
-
- b.bv_page = page;
- b.bv_offset = 0;
- b.bv_len = bvec.bv_len;
- ret = __raw_file_fmt_write_bvec(xlo->xlo_backing_file, &b, &pos);
- if (ret < 0)
- break;
- }
-
- __free_page(page);
- return ret;
-}
-
static int raw_file_fmt_write(struct xloop_file_fmt *xlo_fmt, struct request *rq)
{
struct bio_vec bvec;
@@ -331,9 +232,6 @@ static int raw_file_fmt_write(struct xloop_file_fmt *xlo_fmt, struct request *rq
xlo = xloop_file_fmt_get_xlo(xlo_fmt);
pos = __raw_file_fmt_rq_get_pos(xlo_fmt, rq);
- if (xlo->transfer)
- return __raw_file_fmt_write_transfer(xlo, rq, pos);
-
rq_for_each_segment(bvec, rq, iter) {
ret = __raw_file_fmt_write_bvec(xlo->xlo_backing_file, &bvec, &pos);
if (ret < 0)
@@ -357,9 +255,7 @@ static int __raw_file_fmt_fallocate(struct xloop_device *xlo, struct request *rq
{
/*
* We use fallocate to manipulate the space mappings used by the image
- * a.k.a. discard/zerorange. However we do not support this if
- * encryption is enabled, because it may give an attacker useful
- * information.
+ * a.k.a. discard/zerorange.
*/
struct file *file = xlo->xlo_backing_file;
int ret;
diff --git a/src/kernel/xloop_main.c b/src/kernel/xloop_main.c
index 2047cff..cff7aa3 100644
--- a/src/kernel/xloop_main.c
+++ b/src/kernel/xloop_main.c
@@ -10,6 +10,8 @@
#include "xloop_main_rhel_8.5.c"
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
#include "xloop_main_4.18.c"
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
#include "xloop_main_5.15.c"
+#else
+#include "xloop_main_6.6.c"
#endif
diff --git a/src/kernel/xloop_main.h b/src/kernel/xloop_main.h
index b49fc97..b4615d6 100644
--- a/src/kernel/xloop_main.h
+++ b/src/kernel/xloop_main.h
@@ -15,6 +15,8 @@
#include "xloop_main_rhel_8.5.h"
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
#include "xloop_main_4.18.h"
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
#include "xloop_main_5.15.h"
+#else
+#include "xloop_main_6.6.h"
#endif