From ea21db88b73530ef1ffcb7f63615a5081ccd8df9000a9cc12da660d78d33c5ed Mon Sep 17 00:00:00 2001 From: Coly Li Date: Fri, 26 May 2023 02:53:17 +0000 Subject: [PATCH] Accepting request 1089071 from home:colyli:branches:openSUSE:Factory - Grow: fix possible memory leak (bsc#1208618) 0060-Grow-fix-possible-memory-leak.patch - Grow: fix can't change bitmap type from none to clustered (bsc#1208618) 0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch - Use source code mdadm-4.2.tar.xz from kernel.org version for checksum - mdadm-4.2.tar.xz OBS-URL: https://build.opensuse.org/request/show/1089071 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=225 --- 0060-Grow-fix-possible-memory-leak.patch | 42 +++++++++++++++++ ...e-bitmap-type-from-none-to-clustered.patch | 47 +++++++++++++++++++ mdadm-4.2.tar.xz | 2 +- mdadm.changes | 12 +++++ mdadm.spec | 4 ++ 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 0060-Grow-fix-possible-memory-leak.patch create mode 100644 0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch diff --git a/0060-Grow-fix-possible-memory-leak.patch b/0060-Grow-fix-possible-memory-leak.patch new file mode 100644 index 0000000..a6fde80 --- /dev/null +++ b/0060-Grow-fix-possible-memory-leak.patch @@ -0,0 +1,42 @@ +From 434b3b9bb96a76dc12f693b64cf23b581781e20b Mon Sep 17 00:00:00 2001 +From: Blazej Kucman +Date: Tue, 20 Dec 2022 12:07:51 +0100 +Subject: [PATCH] Grow: fix possible memory leak. +Git-commit: 434b3b9bb96a76dc12f693b64cf23b581781e20b +Patch-mainline: mdadm-4.2+ +References: bsc#1208618 + +Signed-off-by: Blazej Kucman +Signed-off-by: Jes Sorensen +Signed-off-by: Coly Li +--- + Grow.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Grow.c b/Grow.c +index e362403..b73ec2a 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -432,6 +432,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) + if (((disk.state & (1 << MD_DISK_WRITEMOSTLY)) == 0) && + (strcmp(s->bitmap_file, "clustered") == 0)) { + pr_err("%s disks marked write-mostly are not supported with clustered bitmap\n",devname); ++ free(mdi); + return 1; + } + fd2 = dev_open(dv, O_RDWR); +@@ -453,8 +454,10 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) + pr_err("failed to load super-block.\n"); + } + close(fd2); +- if (rv) ++ if (rv) { ++ free(mdi); + return 1; ++ } + } + if (offset_setable) { + st->ss->getinfo_super(st, mdi, NULL); +-- +2.35.3 + diff --git a/0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch b/0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch new file mode 100644 index 0000000..2213e5f --- /dev/null +++ b/0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch @@ -0,0 +1,47 @@ +From d07e561810a2e33b667a8a9476edaff42eb119b9 Mon Sep 17 00:00:00 2001 +From: Heming Zhao +Date: Thu, 23 Feb 2023 22:39:39 +0800 +Subject: [PATCH] Grow: fix can't change bitmap type from none to clustered. +Git-commit: d07e561810a2e33b667a8a9476edaff42eb119b9 +Patch-mainline: mdadm-4.2+ +References: bsc#1208618 + +Commit a042210648ed ("disallow create or grow clustered bitmap with +writemostly set") introduced this bug. We should use 'true' logic not +'== 0' to deny setting up clustered array under WRITEMOSTLY condition. + +How to trigger + +``` +~/mdadm # ./mdadm -Ss && ./mdadm --zero-superblock /dev/sd{a,b} +~/mdadm # ./mdadm -C /dev/md0 -l mirror -b clustered -e 1.2 -n 2 \ +/dev/sda /dev/sdb --assume-clean +mdadm: array /dev/md0 started. +~/mdadm # ./mdadm --grow /dev/md0 --bitmap=none +~/mdadm # ./mdadm --grow /dev/md0 --bitmap=clustered +mdadm: /dev/md0 disks marked write-mostly are not supported with clustered bitmap +``` + +Signed-off-by: Heming Zhao +Acked-by: Coly Li +Signed-off-by: Jes Sorensen +--- + Grow.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Grow.c b/Grow.c +index 8f5cf07..bb5fe45 100644 +--- a/Grow.c ++++ b/Grow.c +@@ -429,7 +429,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s) + dv = map_dev(disk.major, disk.minor, 1); + if (!dv) + continue; +- if (((disk.state & (1 << MD_DISK_WRITEMOSTLY)) == 0) && ++ if ((disk.state & (1 << MD_DISK_WRITEMOSTLY)) && + (strcmp(s->bitmap_file, "clustered") == 0)) { + pr_err("%s disks marked write-mostly are not supported with clustered bitmap\n",devname); + free(mdi); +-- +2.35.3 + diff --git a/mdadm-4.2.tar.xz b/mdadm-4.2.tar.xz index 28ff165..5acaaf7 100644 --- a/mdadm-4.2.tar.xz +++ b/mdadm-4.2.tar.xz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:48567f4688112018d8be8588fd3e6c830d7d2a9ece33334a82973034836b2a0d +oid sha256:461c215670864bb74a4d1a3620684aa2b2f8296dffa06743f26dda5557acf01d size 453624 diff --git a/mdadm.changes b/mdadm.changes index f0a816a..0c16702 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Fri May 26 02:29:42 UTC 2023 - Coly Li + +- Grow: fix possible memory leak (bsc#1208618) + 0060-Grow-fix-possible-memory-leak.patch +- Grow: fix can't change bitmap type from none to clustered + (bsc#1208618) + 0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch +- Use source code mdadm-4.2.tar.xz from kernel.org version for + checksum + - mdadm-4.2.tar.xz + ------------------------------------------------------------------- Mon Apr 24 15:06:42 UTC 2023 - Coly Li diff --git a/mdadm.spec b/mdadm.spec index 5fd278f..2a501d0 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -100,6 +100,8 @@ Patch56: 0056-mdmon-Remove-need-for-KillMode-none.patch Patch57: 0057-mdmon-Improve-switchroot-interactions.patch Patch58: 0058-mdopen-always-try-create_named_array.patch Patch59: 0059-Improvements-for-IMSM_NO_PLATFORM-testing.patch +Patch60: 0060-Grow-fix-possible-memory-leak.patch +Patch61: 0061-Grow-fix-can-t-change-bitmap-type-from-none-to-clustered.patch Patch1001: 1001-display-timeout-status.patch Patch1002: 1002-OnCalendar-format-fix-of-mdcheck_start-timer.patch Patch1003: 1003-mdadm-treat-the-Dell-softraid-array-as-local-array.patch @@ -171,6 +173,8 @@ mdadm is a program that can be used to control Linux md devices. %patch57 -p1 %patch58 -p1 %patch59 -p1 +%patch60 -p1 +%patch61 -p1 %patch1001 -p1 %patch1002 -p1 %patch1003 -p1