Skip to contentSkip to conversation

bitmap-fix-bitmap_cut-for-partial-overlapping-case.patch removed from -mm tree

merged [email protected] 1 participant 1 message Aug 12, 2020

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: lib/bitmap.c: fix bitmap_cut() for partial overlapping case
has been removed from the -mm tree. Its filename was
bitmap-fix-bitmap_cut-for-partial-overlapping-case.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Stefano Brivio <[email protected]>
Subject: lib/bitmap.c: fix bitmap_cut() for partial overlapping case

Patch series "lib: Fix bitmap_cut() for overlaps, add test"

This patch (of 2):

Yury Norov reports that bitmap_cut() will not produce the right outcome if src and dst partially overlap, with src pointing at some location after dst, because the memmove() affects src before we store the bits that we need to keep, that is, the bits preceding the cut -- as long as we the beginning of the cut is not aligned to a long.

Fix this by storing those bits before the memmove().

Note that this is just a theoretical concern so far, as the only user of this function, pipapo_drop() from the nftables set back-end implemented in net/netfilter/nft_set_pipapo.c, always supplies entirely overlapping src and dst.

---

 lib/bitmap.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bitmap.c renamed from lib/bitmap.c~bitmap-fix-bitmap_cut-for-partial-overlapping-case +2 -2
@@ -212,13 +212,13 @@ void bitmap_cut(unsigned long *dst, cons
 	unsigned long keep = 0, carry;
 	int i;
 
-	memmove(dst, src, len * sizeof(*dst));
-
 	if (first % BITS_PER_LONG) {
 		keep = src[first / BITS_PER_LONG] &
 		       (~0UL >> (BITS_PER_LONG - first % BITS_PER_LONG));
 	}
 
+	memmove(dst, src, len * sizeof(*dst));
+
 	while (cut--) {
 		for (i = first / BITS_PER_LONG; i < len; i++) {
 			if (i < len - 1)

_

Patches currently in -mm which might be from [email protected] are