OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Alexey Kuznetsov <kuznet@virtuozzo.com>
To: devel@openvz.org, khorenko@virtuozzo.com, kui.liu@virtuozzo.com,
	azaitsev@virtuozzo.com
Subject: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
Date: Mon, 30 Nov 2026 22:57:17 +0800	[thread overview]
Message-ID: <aw2OzUHFpvEwwuS5@mops2> (raw)

Actually, this assertion was deliberate and served its purpose.
We were not supposed to arrive at this place ever. Nevertheless,
new kernels have allowed O_DIRECT access to tmpfs
(e88e0d366f9c "tmpfs: trivial support for direct IO"), which does
not imply any memory alignment constraints. Our tests really use
tmpfs.

Notes:

- vstorage deliberately does not check memory alignment anywhere.
  The fact that linux fs used to reject unaligned direct io is considered
  as a kernel flaw, which is going to be fixed one day, so that we do not
  pollute our code with such checks. Cf. #VSTOR-53260 where
  the investigation has been undertaken
- alignment check in decrypt protects deficient algorithm
  in decrypt_data(), which is not able to handle a 512-byte crypto sector
  split over 2 pages. We could repair this instead of rejection,
  but it would complicate code significantly, and
  until this is required in production we do not want this.
- it is safe to fail any operation in cs accel with an error:
  any error condition causes fallback to slow path and
  as long as the condition is truly exceptional, it is all right.

Fixes: 5acc64b761cd ("fuse: implement fast access to encrypted CSes")
https://virtuozzo.atlassian.net/browse/VSTOR-157924

Affects: #VSTOR-157924

Signed-off-by: Alexey Kuznetsov <kuznet@virtuozzo.com>

Feature: vStorage
---
 fs/fuse/kio/pcs/pcs_cs_accel.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs_accel.c b/fs/fuse/kio/pcs/pcs_cs_accel.c
index bc11f47352db..c8bdc606c63b 100644
--- a/fs/fuse/kio/pcs/pcs_cs_accel.c
+++ b/fs/fuse/kio/pcs/pcs_cs_accel.c
@@ -326,7 +326,15 @@ static int decrypt_data(struct pcs_int_request * ireq,  struct crypto_sync_skcip
 
 		len = iov_iter_get_pages2(it, &page, size - pos, 1, &offset);
 		BUG_ON(len <= 0);
-		BUG_ON(len & 511);
+		if (unlikely(len & 511)) {
+			put_page(page);
+			FUSE_KTRACE(ireq->cc->fc,
+				    "Unaligned memory, ireq:%px : %llu:%u+%u",
+				    ireq, (unsigned long long)ireq->iochunk.chunk,
+				    (unsigned int)ireq->iochunk.offset,
+				    (unsigned int)ireq->iochunk.size);
+			return -EINVAL;
+		}
 
 		if (is_ctr) {
 			for (; len > 0; len -= 512) {
-- 
2.47.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

             reply	other threads:[~2026-11-30 14:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 14:57 Alexey Kuznetsov [this message]
2026-11-30 16:02 ` Konstantin Khorenko
2026-11-30 18:12   ` Alexey Kuznetsov
2026-11-30 16:04 ` Konstantin Khorenko
2026-12-01  1:06 ` no-reply
2026-12-01 12:13 ` Konstantin Khorenko
2026-12-01 12:30 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw2OzUHFpvEwwuS5@mops2 \
    --to=kuznet@virtuozzo.com \
    --cc=azaitsev@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=kui.liu@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox