* [PATCH] bcachefs: Fix memmove when move keys down
@ 2025-02-18 6:37 Alan Huang
2025-02-18 12:04 ` Alan Huang
0 siblings, 1 reply; 4+ messages in thread
From: Alan Huang @ 2025-02-18 6:37 UTC (permalink / raw)
To: kent.overstreet
Cc: linux-bcachefs, ryncsn, akpm, Alan Huang,
syzbot+38a0cbd267eff2d286ff
Reported-by: syzbot+38a0cbd267eff2d286ff@syzkaller.appspotmail.com
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
fs/bcachefs/btree_io.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index e71b278672b6..0022529522f1 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -997,7 +997,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
}
got_good_key:
le16_add_cpu(&i->u64s, -next_good_key);
- memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
+ memmove_u64s_down(k, (u64 *) k + next_good_key, (u64 *) vstruct_end(i) - (u64 *) k - next_good_key);
set_btree_node_need_rewrite(b);
}
fsck_err:
@@ -1259,7 +1259,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
i->u64s = cpu_to_le16(le16_to_cpu(i->u64s) - k->u64s);
memmove_u64s_down(k, bkey_p_next(k),
- (u64 *) vstruct_end(i) - (u64 *) k);
+ (u64 *) vstruct_end(i) - (u64 *) bkey_p_next(k));
set_btree_bset_end(b, b->set);
set_btree_node_need_rewrite(b);
continue;
--
2.47.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bcachefs: Fix memmove when move keys down
2025-02-18 6:37 Alan Huang
@ 2025-02-18 12:04 ` Alan Huang
0 siblings, 0 replies; 4+ messages in thread
From: Alan Huang @ 2025-02-18 12:04 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs, ryncsn, akpm, syzbot+38a0cbd267eff2d286ff
Ignore this.
> On Feb 18, 2025, at 14:37, Alan Huang <mmpgouride@gmail.com> wrote:
>
> Reported-by: syzbot+38a0cbd267eff2d286ff@syzkaller.appspotmail.com
> Signed-off-by: Alan Huang <mmpgouride@gmail.com>
> ---
> fs/bcachefs/btree_io.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
> index e71b278672b6..0022529522f1 100644
> --- a/fs/bcachefs/btree_io.c
> +++ b/fs/bcachefs/btree_io.c
> @@ -997,7 +997,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
> }
> got_good_key:
> le16_add_cpu(&i->u64s, -next_good_key);
> - memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
> + memmove_u64s_down(k, (u64 *) k + next_good_key, (u64 *) vstruct_end(i) - (u64 *) k - next_good_key);
> set_btree_node_need_rewrite(b);
> }
> fsck_err:
> @@ -1259,7 +1259,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
>
> i->u64s = cpu_to_le16(le16_to_cpu(i->u64s) - k->u64s);
> memmove_u64s_down(k, bkey_p_next(k),
> - (u64 *) vstruct_end(i) - (u64 *) k);
> + (u64 *) vstruct_end(i) - (u64 *) bkey_p_next(k));
> set_btree_bset_end(b, b->set);
> set_btree_node_need_rewrite(b);
> continue;
> --
> 2.47.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] bcachefs: Fix memmove when move keys down
@ 2025-02-20 10:56 Alan Huang
2025-02-20 17:32 ` Kent Overstreet
0 siblings, 1 reply; 4+ messages in thread
From: Alan Huang @ 2025-02-20 10:56 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs, ryncsn, Alan Huang
The fix alone doesn't fix [1], but should be applied before debugging
that.
[1] https://syzkaller.appspot.com/bug?extid=38a0cbd267eff2d286ff
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
fs/bcachefs/btree_io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index e71b278672b6..80a0094be356 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -997,7 +997,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
}
got_good_key:
le16_add_cpu(&i->u64s, -next_good_key);
- memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
+ memmove_u64s_down(k, (u64 *) k + next_good_key, (u64 *) vstruct_end(i) - (u64 *) k);
set_btree_node_need_rewrite(b);
}
fsck_err:
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bcachefs: Fix memmove when move keys down
2025-02-20 10:56 [PATCH] bcachefs: Fix memmove when move keys down Alan Huang
@ 2025-02-20 17:32 ` Kent Overstreet
0 siblings, 0 replies; 4+ messages in thread
From: Kent Overstreet @ 2025-02-20 17:32 UTC (permalink / raw)
To: Alan Huang; +Cc: linux-bcachefs, ryncsn
On Thu, Feb 20, 2025 at 06:56:08PM +0800, Alan Huang wrote:
> The fix alone doesn't fix [1], but should be applied before debugging
> that.
>
> [1] https://syzkaller.appspot.com/bug?extid=38a0cbd267eff2d286ff
>
> Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Applied
> ---
> fs/bcachefs/btree_io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
> index e71b278672b6..80a0094be356 100644
> --- a/fs/bcachefs/btree_io.c
> +++ b/fs/bcachefs/btree_io.c
> @@ -997,7 +997,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
> }
> got_good_key:
> le16_add_cpu(&i->u64s, -next_good_key);
> - memmove_u64s_down(k, bkey_p_next(k), (u64 *) vstruct_end(i) - (u64 *) k);
> + memmove_u64s_down(k, (u64 *) k + next_good_key, (u64 *) vstruct_end(i) - (u64 *) k);
> set_btree_node_need_rewrite(b);
> }
> fsck_err:
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-20 17:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 10:56 [PATCH] bcachefs: Fix memmove when move keys down Alan Huang
2025-02-20 17:32 ` Kent Overstreet
-- strict thread matches above, loose matches on Subject: below --
2025-02-18 6:37 Alan Huang
2025-02-18 12:04 ` Alan Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox