* [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
@ 2026-11-30 14:57 Alexey Kuznetsov
2026-11-30 16:02 ` Konstantin Khorenko
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Alexey Kuznetsov @ 2026-11-30 14:57 UTC (permalink / raw)
To: devel, khorenko, kui.liu, azaitsev
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
2026-11-30 14:57 [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel Alexey Kuznetsov
@ 2026-11-30 16:02 ` Konstantin Khorenko
2026-11-30 18:12 ` Alexey Kuznetsov
2026-11-30 16:04 ` Konstantin Khorenko
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 16:02 UTC (permalink / raw)
To: Alexey Kuznetsov; +Cc: azaitsev, devel, kui.liu
Please, send an ACK for the patch and after that
i can apply this with the following fixes on my side:
- trailers: dropped "Affects:" (it repeats the URL) and the blank
lines between them, put them in the usual order: URL, Fixes,
Feature, Signed-off-by. With the blank lines git saw only Feature:
as a trailer.
On Mon, 30 Nov 2026 22:57:17 +0800, Alexey Kuznetsov wrote:
> 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.
Not only tmpfs. On ext4/xfs CS disks an O_DIRECT read of a hole or
an unwritten extent goes through iomap_dio_hole_iter(), which fills
the buffer without the memory alignment check of the bio path, and
ext4 data=journal falls back to buffered reads. So the BUG_ON could
fire in production before the tmpfs change, and the fix is worth
having on every branch with 5acc64b761cd.
> - vstorage deliberately does not check memory alignment anywhere.
init_crypted_data() does check it, (bv_offset | bv_len) & 511, before
the encrypted write is submitted.
> + if (unlikely(len & 511)) {
> + put_page(page);
No change needed now, a thought for later: this fires only after the
local read is done and the earlier pages are decrypted in place.
The error then goes through map_notify_soft_error() and closes the
congestion window of the local CS (eff_cwnd = 1) until its next
success. The same check in csa_submit() for IREQ_F_CRYPT, as on the
write path, would fall back before any IO and without that.
Separate patches, not needed for this one. I created a task:
1. csa_submit() leaks the crc_page[] references taken by
quick_crc_fetch() on its synchronous error returns ("Not a bvec",
"AIO submit rejected"); the caller falls back to the network and
the union with iochunk.ir overwrites the pointers. Unaligned
O_DIRECT reads on block-backed CS storage with CRC take this path.
https://virtuozzo.atlassian.net/browse/VSTOR-158112
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
2026-11-30 14:57 [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel Alexey Kuznetsov
2026-11-30 16:02 ` Konstantin Khorenko
@ 2026-11-30 16:04 ` Konstantin Khorenko
2026-12-01 1:06 ` no-reply
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 16:04 UTC (permalink / raw)
To: Alexey Kuznetsov, kui.liu, azaitsev; +Cc: devel
+ please clarify which kernel this should go?
1. to 8.2 (26.x) - so no rush here
or
2. to 8.1 (24.x) - so we have to hurry up and respin the kernel once again?
--
Konstantin
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
2026-11-30 16:02 ` Konstantin Khorenko
@ 2026-11-30 18:12 ` Alexey Kuznetsov
0 siblings, 0 replies; 7+ messages in thread
From: Alexey Kuznetsov @ 2026-11-30 18:12 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: azaitsev, kui.liu, devel
Acknowledged.
It is for 8.1 as marked in the subject, and of course of 8.2.
Actually all the versions are affected, but I would not care,
it is still marginal. But because such simple and fatal bug
has been found in testing 8.1 I guess it would be better
to fix it at least starting from there.
> Not only tmpfs
Sure. There are lots of bizarre configurations.
F.e. csd could be started even on top on vstorage itself. :-)
Meatbags are more stupid than Claude but still have a common
sense which saves a lot of time and have to protect themselves
of redundant anality. tmpfs is special in sense it is really used in tests.
Anyway, in production it would be not so bad to reject initialization cs accel
requests unless it is ext4 with options used in real life i.e. ordered metadata
journal, no fast commits, no crypto. Acttually, it is not about kernel part,
user space will corrupt itself unless it is ext4 with exactly these properties.
It is safe but inconvenient, we will have to add knobs to override this
for tests.
> The error then goes through map_notify_soft_error() and closes the
congestion window of the local CS
It should not. It was supposed to be intercepted in map_read_error()
and ignored w/o harming any state. But everything is possible,
I will check.
> csa_submit() leaks the crc_page
This sounds really serious! If this is true, it is a bug
much worse than even oops. "AIO submit rejected" path is not exotic
and if it leaks it is fatal.
On Tue, Dec 1, 2026 at 12:11 AM Konstantin Khorenko
<khorenko@virtuozzo.com> wrote:
>
> Please, send an ACK for the patch and after that
>
> i can apply this with the following fixes on my side:
>
> - trailers: dropped "Affects:" (it repeats the URL) and the blank
> lines between them, put them in the usual order: URL, Fixes,
> Feature, Signed-off-by. With the blank lines git saw only Feature:
> as a trailer.
>
> On Mon, 30 Nov 2026 22:57:17 +0800, Alexey Kuznetsov wrote:
> > 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.
>
> Not only tmpfs. On ext4/xfs CS disks an O_DIRECT read of a hole or
> an unwritten extent goes through iomap_dio_hole_iter(), which fills
> the buffer without the memory alignment check of the bio path, and
> ext4 data=journal falls back to buffered reads. So the BUG_ON could
> fire in production before the tmpfs change, and the fix is worth
> having on every branch with 5acc64b761cd.
>
> > - vstorage deliberately does not check memory alignment anywhere.
>
> init_crypted_data() does check it, (bv_offset | bv_len) & 511, before
> the encrypted write is submitted.
>
> > + if (unlikely(len & 511)) {
> > + put_page(page);
>
> No change needed now, a thought for later: this fires only after the
> local read is done and the earlier pages are decrypted in place.
> The error then goes through map_notify_soft_error() and closes the
> congestion window of the local CS (eff_cwnd = 1) until its next
> success. The same check in csa_submit() for IREQ_F_CRYPT, as on the
> write path, would fall back before any IO and without that.
>
> Separate patches, not needed for this one. I created a task:
>
> 1. csa_submit() leaks the crc_page[] references taken by
> quick_crc_fetch() on its synchronous error returns ("Not a bvec",
> "AIO submit rejected"); the caller falls back to the network and
> the union with iochunk.ir overwrites the pointers. Unaligned
> O_DIRECT reads on block-backed CS storage with CRC take this path.
> https://virtuozzo.atlassian.net/browse/VSTOR-158112
>
> --
> Konstantin Khorenko,
> Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
2026-11-30 14:57 [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel Alexey Kuznetsov
2026-11-30 16:02 ` Konstantin Khorenko
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
4 siblings, 0 replies; 7+ messages in thread
From: no-reply @ 2026-12-01 1:06 UTC (permalink / raw)
To: Alexey Kuznetsov, devel, khorenko, kui.liu, azaitsev
> 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>
Sashiko has reviewed this patch and found no issues.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/aw2OzUHFpvEwwuS5@mops2?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
2026-11-30 14:57 [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel Alexey Kuznetsov
` (2 preceding siblings ...)
2026-12-01 1:06 ` no-reply
@ 2026-12-01 12:13 ` Konstantin Khorenko
2026-12-01 12:30 ` Konstantin Khorenko
4 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-12-01 12:13 UTC (permalink / raw)
To: devel, kui.liu, azaitsev, Alexey Kuznetsov
On Mon, 30 Nov 2026 22:57:17 +0800, Alexey Kuznetsov wrote:
> fs/fuse/kio: do not panic on unaligned memory access in cs accel
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.26.7.vz10, thanks!
[1/1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/dfab76a3475b
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
2026-11-30 14:57 [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel Alexey Kuznetsov
` (3 preceding siblings ...)
2026-12-01 12:13 ` Konstantin Khorenko
@ 2026-12-01 12:30 ` Konstantin Khorenko
4 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-12-01 12:30 UTC (permalink / raw)
To: devel, kui.liu, azaitsev, Alexey Kuznetsov
On Mon, 30 Nov 2026 22:57:17 +0800, Alexey Kuznetsov wrote:
> fs/fuse/kio: do not panic on unaligned memory access in cs accel
Applied to branch-rh10-6.12.0-211.75.1.24.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.6.vz10, thanks!
[1/1] fs/fuse/kio: do not panic on unaligned memory access in cs accel
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/2f5ff39f2027
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-01 12:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 14:57 [Devel] [PATCH hci-8.1] fs/fuse/kio: do not panic on unaligned memory access in cs accel Alexey Kuznetsov
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox