From: Dust Li <dust.li@linux.alibaba.com>
To: stable@vger.kernel.org
Cc: Dust Li <dust.li@linux.alibaba.com>,
Federico Kirschbaum <federico.kirschbaum@xbow.com>,
Baul Lee <baul.lee@xbow.com>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH 6.12.y] dibs: loopback: validate offset and size in move_data()
Date: Tue, 21 Jul 2026 21:01:49 +0800 [thread overview]
Message-ID: <20260721130149.3828003-1-dust.li@linux.alibaba.com> (raw)
In-Reply-To: <2026072130-tadpole-coauthor-d48e@gregkh>
commit 78237e3c0720fcc6eb9b87e90fd70f63eeca886f upstream.
The loopback move_data() performs a memcpy into the registered DMB
without checking whether offset + size exceeds the DMB length. Unlike
real ISM hardware, which enforces memory region bounds natively, the
software loopback has no such protection.
A peer-supplied out-of-bounds offset or oversized write would result in
an OOB write past the allocated kernel buffer. Add an explicit bounds
check before the memcpy to reject such requests with -EINVAL.
Fixes: f7a22071dbf3 ("net/smc: implement DMB-related operations of loopback-ism")
Cc: stable@vger.kernel.org
Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
Reported-by: Baul Lee <baul.lee@xbow.com>
Link: https://patch.msgid.link/20260707074318.1448662-1-dust.li@linux.alibaba.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 78237e3c0720fcc6eb9b87e90fd70f63eeca886f)
[backport for smc_loopback instead of dibs_loopback]
Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
---
net/smc/smc_loopback.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/smc/smc_loopback.c b/net/smc/smc_loopback.c
index 85f0b7853b17..0bf9e4075f03 100644
--- a/net/smc/smc_loopback.c
+++ b/net/smc/smc_loopback.c
@@ -245,6 +245,11 @@ static int smc_lo_move_data(struct smcd_dev *smcd, u64 dmb_tok,
read_unlock_bh(&ldev->dmb_ht_lock);
return -EINVAL;
}
+ if ((u64)offset + size > rmb_node->len) {
+ read_unlock_bh(&ldev->dmb_ht_lock);
+ return -EINVAL;
+ }
+
memcpy((char *)rmb_node->cpu_addr + offset, data, size);
read_unlock_bh(&ldev->dmb_ht_lock);
--
2.43.7
prev parent reply other threads:[~2026-07-21 13:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 9:14 FAILED: patch "[PATCH] dibs: loopback: validate offset and size in move_data()" failed to apply to 6.12-stable tree gregkh
2026-07-21 13:01 ` Dust Li [this message]
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=20260721130149.3828003-1-dust.li@linux.alibaba.com \
--to=dust.li@linux.alibaba.com \
--cc=baul.lee@xbow.com \
--cc=federico.kirschbaum@xbow.com \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/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