代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/xfsprogs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 7ea701ffc7cf306a903f2966519b3f5aedfb77ea Mon Sep 17 00:00:00 2001
From: Eric Biggers <ebiggers@google.com>
Date: Tue, 11 Jun 2024 11:29:28 -0700
Subject: xfs_io: fix mread with length 1 mod page size
Fix a weird bug in mread where if you passed it a length that was 1
modulo the page size, for example
xfs_io -r file -c "mmap -r 0 8192" -c "mread -v 0 4097"
... it never reset its pointer into the buffer into which it copies the
data from the memory map. This caused an out-of-bounds write, which
depending on the length passed could be very large and reliably
segfault. Also nothing was printed, despite the use of -v option.
(I don't know if this case gets reached by any existing xfstest, but
presumably not. I noticed it while working on a patch to an xfstest.)
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
io/mmap.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/io/mmap.c b/io/mmap.c
index 425957d..a5f30e0 100644
--- a/io/mmap.c
+++ b/io/mmap.c
@@ -472,34 +472,26 @@ mread_f(
dumplen = pagesize;
if (rflag) {
- for (tmp = length - 1, c = 0; tmp >= 0; tmp--, c = 1) {
- *bp = *(((char *)mapping->addr) + dumpoffset + tmp);
- cnt++;
- if (c && cnt == dumplen) {
+ for (tmp = length - 1; tmp >= 0; tmp--) {
+ bp[cnt++] = ((char *)mapping->addr)[dumpoffset + tmp];
+ if (cnt == dumplen) {
if (dump) {
dump_buffer(printoffset, dumplen);
printoffset += dumplen;
}
- bp = (char *)io_buffer;
dumplen = pagesize;
cnt = 0;
- } else {
- bp++;
}
}
} else {
- for (tmp = 0, c = 0; tmp < length; tmp++, c = 1) {
- *bp = *(((char *)mapping->addr) + dumpoffset + tmp);
- cnt++;
- if (c && cnt == dumplen) {
+ for (tmp = 0; tmp < length; tmp++) {
+ bp[cnt++] = ((char *)mapping->addr)[dumpoffset + tmp];
+ if (cnt == dumplen) {
if (dump)
dump_buffer(printoffset + tmp -
(dumplen - 1), dumplen);
- bp = (char *)io_buffer;
dumplen = pagesize;
cnt = 0;
- } else {
- bp++;
}
}
}
--
2.43.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。