Compare commits

...
Sign in to create a new pull request.

6 commits

Author SHA1 Message Date
Xiao Ni
8e12c0fe9b Don't submit stop ioctl in assemble
The kernel commit 9e59d609763f ('md: call del_gendisk in control path')
breaks mdadm --assemble command. mdadm pr
https://github.com/md-raid-utilities/mdadm/pull/182 fixes this problem.

Resolves: bz#2388480

Signed-off-by: Xiao Ni <xni@redhat.com>
2025-08-14 08:00:13 -04:00
Fedora Release Engineering
bcbad9cf97 Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-24 21:29:05 +00:00
Adam Williamson
faab6a79df revert 'posix' name check to fix rhbz#2325906 2025-04-06 17:50:12 -07:00
Jonathan Wright
7cf27b1479 fix permissions on /usr/share/mdadm to be world-readable rhbz#2322402 2025-01-23 11:30:31 -06:00
Jonathan Wright
cfb3b4ae5e fix ftbfs on gcc15 rhbz#2340833 2025-01-23 11:29:51 -06:00
Fedora Release Engineering
6deed29770 Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-17 17:19:42 +00:00
3 changed files with 469 additions and 3 deletions

View file

@ -0,0 +1,428 @@
From 857ad175fe025f026a1173e38de0b482110fdce5 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Sun, 6 Apr 2025 14:13:45 -0700
Subject: [PATCH] Revert "mdadm: Follow POSIX Portable Character Set"
This reverts commit e2eb503bd797908f515b58428b274f1ba6a05349.
---
Detail.c | 17 +++++++-----
config.c | 13 +++------
lib.c | 58 +++++++++++-----------------------------
mdadm.8.in | 70 ++++++++++++++++++++++++++++---------------------
mdadm.conf.5.in | 4 +++
mdadm.h | 2 +-
super-intel.c | 47 +++++++++++++++++----------------
7 files changed, 100 insertions(+), 111 deletions(-)
diff --git a/Detail.c b/Detail.c
index aaa3dd6e..6d675152 100644
--- a/Detail.c
+++ b/Detail.c
@@ -254,9 +254,11 @@ int Detail(char *dev, struct context *c)
fname_from_uuid(st, info, nbuf, ':');
printf("MD_UUID=%s\n", nbuf + 5);
mp = map_by_uuid(&map, info->uuid);
-
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
+ if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) {
+ printf("MD_DEVNAME=");
+ print_escape(mp->path + DEV_MD_DIR_LEN);
+ putchar('\n');
+ }
if (st->ss->export_detail_super)
st->ss->export_detail_super(st);
@@ -269,9 +271,12 @@ int Detail(char *dev, struct context *c)
__fname_from_uuid(mp->uuid, 0, nbuf, ':');
printf("MD_UUID=%s\n", nbuf+5);
}
- if (mp && mp->path && strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0)
- printf("MD_DEVNAME=%s\n", mp->path + DEV_MD_DIR_LEN);
-
+ if (mp && mp->path &&
+ strncmp(mp->path, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) {
+ printf("MD_DEVNAME=");
+ print_escape(mp->path + DEV_MD_DIR_LEN);
+ putchar('\n');
+ }
map_free(map);
}
if (!c->no_devices && sra) {
diff --git a/config.c b/config.c
index 44f7dd2f..0a80eedb 100644
--- a/config.c
+++ b/config.c
@@ -199,9 +199,9 @@ inline void ident_init(struct mddev_ident *ident)
* /dev/md_d{number} (legacy)
* /dev/md_{name}
* /dev/md/{name}
- * {name}
+ * {name} - anything that doesn't start from '/' or '<'.
*
- * {name} must follow name's criteria and be POSIX compatible.
+ * {name} must follow name's criteria.
* If criteria passed, duplicate memory and set devname in @ident.
*
* Return: %MDADM_STATUS_SUCCESS or %MDADM_STATUS_ERROR.
@@ -241,8 +241,8 @@ mdadm_status_t _ident_set_devname(struct mddev_ident *ident, const char *devname
else
name = devname;
- if (is_name_posix_compatible(name) == false) {
- ident_log(prop_name, name, "Not POSIX compatible", cmdline);
+ if (*name == '/' || *name == '<') {
+ ident_log(prop_name, devname, "Cannot be started from \'/\' or \'<\'", cmdline);
return MDADM_STATUS_ERROR;
}
@@ -284,11 +284,6 @@ static mdadm_status_t _ident_set_name(struct mddev_ident *ident, const char *nam
return MDADM_STATUS_ERROR;
}
- if (is_name_posix_compatible(name) == false) {
- ident_log(prop_name, name, "Not POSIX compatible", cmdline);
- return MDADM_STATUS_ERROR;
- }
-
snprintf(ident->name, MD_NAME_MAX + 1, "%s", name);
return MDADM_STATUS_SUCCESS;
}
diff --git a/lib.c b/lib.c
index 2b09293c..95e3511f 100644
--- a/lib.c
+++ b/lib.c
@@ -454,50 +454,24 @@ void print_quoted(char *str)
putchar(q);
}
-/**
- * is_alphanum() - Check if sign is letter or digit.
- * @c: char to analyze.
- *
- * Similar to isalnum() but additional locales are excluded.
- *
- * Return: %true on success, %false otherwise.
- */
-bool is_alphanum(const char c)
-{
- if (isupper(c) || islower(c) || isdigit(c) != 0)
- return true;
- return false;
-}
-
-/**
- * is_name_posix_compatible() - Check if name is POSIX compatible.
- * @name: name to check.
- *
- * POSIX portable file name character set contains ASCII letters,
- * digits, '_', '.', and '-'. Also forbid leading '-'.
- * The length of the name cannot exceed NAME_MAX - 1 (ensure NULL ending).
- *
- * Return: %true on success, %false otherwise.
- */
-bool is_name_posix_compatible(const char * const name)
+void print_escape(char *str)
{
- assert(name);
-
- char allowed_symbols[] = "-_.";
- const char *n = name;
-
- if (!is_string_lq(name, NAME_MAX))
- return false;
-
- if (*n == '-')
- return false;
-
- while (*n != '\0') {
- if (!is_alphanum(*n) && !strchr(allowed_symbols, *n))
- return false;
- n++;
+ /* print str, but change space and tab to '_'
+ * as is suitable for device names
+ */
+ for (; *str; str++) {
+ switch (*str) {
+ case ' ':
+ case '\t':
+ putchar('_');
+ break;
+ case '/':
+ putchar('-');
+ break;
+ default:
+ putchar(*str);
+ }
}
- return true;
}
int check_env(char *name)
diff --git a/mdadm.8.in b/mdadm.8.in
index 96a4a08e..4af90c48 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -364,7 +364,7 @@ Use the Intel(R) Matrix Storage Manager metadata format. This creates a
which is managed in a similar manner to DDF, and is supported by an
option-rom on some platforms:
.IP
-.B https://www.intel.com/content/www/us/en/support/products/122484
+.B https://www.intel.com/content/www/us/en/support/products/122484/memory-and-storage/ssd-software/intel-virtual-raid-on-cpu-intel-vroc.html
.PP
.RE
@@ -932,14 +932,17 @@ option will be ignored.
.BR \-N ", " \-\-name=
Set a
.B name
-for the array. It must be
-.BR "POSIX PORTABLE NAME"
-compatible and cannot be longer than 32 chars. This is effective when creating an array
-with a v1 metadata, or an external array.
-
-If name is needed but not specified, it is taken from the basename of the device
-that is being created. See
-.BR "DEVICE NAMES"
+for the array. This is currently only effective when creating an
+array with a version-1 superblock, or an array in a DDF container.
+The name is a simple textual string that can be used to identify array
+components when assembling. If name is needed but not specified, it
+is taken from the basename of the device that is being created.
+e.g. when creating
+.I /dev/md/home
+the
+.B name
+will default to
+.IR home .
.TP
.BR \-R ", " \-\-run
@@ -1129,10 +1132,8 @@ is much safer.
.TP
.BR \-N ", " \-\-name=
-Specify the name of the array to assemble. It must be
-.BR "POSIX PORTABLE NAME"
-compatible and cannot be longer than 32 chars. This must be the name
-that was specified when creating the array. It must either match
+Specify the name of the array to assemble. This must be the name
+that was specified when creating the array. It must either match
the name stored in the superblock exactly, or it must match
with the current
.I homehost
@@ -2178,17 +2179,14 @@ Usage:
.I md-device
.BI \-\-chunk= X
.BI \-\-level= Y
+.br
.BI \-\-raid\-devices= Z
.I devices
.PP
-This usage will initialize a new md array, associate some devices with
+This usage will initialise a new md array, associate some devices with
it, and activate the array.
-.I md-device
-is a new device. This could be standard name or chosen name. For details see:
-.BR "DEVICE NAMES"
-
The named device will normally not exist when
.I "mdadm \-\-create"
is run, but will be created by
@@ -2229,6 +2227,24 @@ array. This feature can be overridden with the
.B \-\-force
option.
+When creating an array with version-1 metadata a name for the array is
+required.
+If this is not given with the
+.B \-\-name
+option,
+.I mdadm
+will choose a name based on the last component of the name of the
+device being created. So if
+.B /dev/md3
+is being created, then the name
+.B 3
+will be chosen.
+If
+.B /dev/md/home
+is being created, then the name
+.B home
+will be used.
+
When creating a partition based array, using
.I mdadm
with version-1.x metadata, the partition type should be set to
@@ -2413,10 +2429,12 @@ and
The
.B name
-option updates the subarray name in the metadata. It must be
-.BR "POSIX PORTABLE NAME"
-compatible and cannot be longer than 32 chars. If successes, new value will be respected after
-next assembly.
+option updates the subarray name in the metadata, it may not affect the
+device node name or the device node symlink until the subarray is
+re\-assembled. If updating
+.B name
+would change the UUID of an active subarray this operation is blocked,
+and the command will end in an error.
The
.B ppl
@@ -3377,10 +3395,6 @@ When
.B \-\-incremental
mode is used, this file gets a list of arrays currently being created.
-.SH POSIX PORTABLE NAME
-A valid name can only consist of characters "A-Za-z0-9.-_".
-The name cannot start with a leading "-" and cannot exceed 255 chars.
-
.SH DEVICE NAMES
.I mdadm
@@ -3402,10 +3416,6 @@ can be given, or just the suffix of the second sort of name, such as
.I home
can be given.
-In every style, raw name must be compatible with
-.BR "POSIX PORTABLE NAME"
-and has to be no longer than 32 chars.
-
When
.I mdadm
chooses device names during auto-assembly or incremental assembly, it
diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in
index 787e51e9..032b8010 100644
--- a/mdadm.conf.5.in
+++ b/mdadm.conf.5.in
@@ -710,6 +710,10 @@ ARRAY /dev/md/home UUID=9187a482:5dde19d9:eea3cc4a:d646ab8b
.br
auto=part
.br
+# The name of this array contains a space.
+.br
+ARRAY /dev/md9 name='Data Storage'
+.sp
POLICY domain=domain1 metadata=imsm path=pci-0000:00:1f.2-scsi-*
.br
action=spare
diff --git a/mdadm.h b/mdadm.h
index 1f28b3e7..3b3168d4 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1623,7 +1623,6 @@ extern int check_raid(int fd, char *name);
extern int check_partitions(int fd, char *dname,
unsigned long long freesize,
unsigned long long size);
-extern bool is_name_posix_compatible(const char *path);
extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev);
extern int stat_is_blkdev(char *devname, dev_t *rdev);
@@ -1664,6 +1663,7 @@ extern int conf_get_monitor_delay(void);
extern char *conf_line(FILE *file);
extern char *conf_word(FILE *file, int allow_key);
extern void print_quoted(char *str);
+extern void print_escape(char *str);
extern int use_udev(void);
extern void print_escape(char *str);
extern unsigned long GCD(unsigned long a, unsigned long b);
diff --git a/super-intel.c b/super-intel.c
index dbea235d..33f1469f 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -5533,37 +5533,40 @@ static void imsm_update_version_info(struct intel_super *super)
}
}
-/**
- * imsm_check_name() - check imsm naming criteria.
- * @super: &intel_super pointer, not NULL.
- * @name: name to check.
- * @verbose: verbose level.
- *
- * Name must be no longer than &MAX_RAID_SERIAL_LEN and must be unique across volumes.
- *
- * Returns: &true if @name matches, &false otherwise.
- */
-static bool imsm_is_name_allowed(struct intel_super *super, const char * const name,
- const int verbose)
+static int check_name(struct intel_super *super, char *name, int quiet)
{
struct imsm_super *mpb = super->anchor;
+ char *reason = NULL;
+ char *start = name;
+ size_t len = strlen(name);
int i;
- if (is_string_lq(name, MAX_RAID_SERIAL_LEN + 1) == false) {
- pr_vrb("imsm: Name \"%s\" is too long\n", name);
- return false;
+ if (len > 0) {
+ while (isspace(start[len - 1]))
+ start[--len] = 0;
+ while (*start && isspace(*start))
+ ++start, --len;
+ memmove(name, start, len + 1);
}
+ if (len > MAX_RAID_SERIAL_LEN)
+ reason = "must be 16 characters or less";
+ else if (len == 0)
+ reason = "must be a non-empty string";
+
for (i = 0; i < mpb->num_raid_devs; i++) {
struct imsm_dev *dev = get_imsm_dev(super, i);
if (strncmp((char *) dev->volume, name, MAX_RAID_SERIAL_LEN) == 0) {
- pr_vrb("imsm: Name \"%s\" already exists\n", name);
- return false;
+ reason = "already exists";
+ break;
}
}
- return true;
+ if (reason && !quiet)
+ pr_err("imsm volume name %s\n", reason);
+
+ return !reason;
}
static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
@@ -5658,9 +5661,8 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,
}
}
- if (imsm_is_name_allowed(super, name, 1) == false)
+ if (!check_name(super, name, 0))
return 0;
-
dv = xmalloc(sizeof(*dv));
dev = xcalloc(1, sizeof(*dev) + sizeof(__u32) * (info->raid_disks - 1));
/*
@@ -7988,7 +7990,7 @@ static int update_subarray_imsm(struct supertype *st, char *subarray,
char *ep;
int vol;
- if (imsm_is_name_allowed(super, name, 1) == false)
+ if (!check_name(super, name, 0))
return 2;
vol = strtoul(subarray, &ep, 10);
@@ -10298,8 +10300,7 @@ static void imsm_process_update(struct supertype *st,
if (a->info.container_member == target)
break;
dev = get_imsm_dev(super, u->dev_idx);
-
- if (a || !dev || imsm_is_name_allowed(super, name, 0) == false) {
+ if (a || !check_name(super, name, 1)) {
dprintf("failed to rename subarray-%d\n", target);
break;
}
--
2.49.0

View file

@ -0,0 +1,11 @@
--- a/Assemble.c~ 2025-08-13 22:05:00.416132027 -0400
+++ b/Assemble.c 2025-08-13 22:13:16.650837070 -0400
@@ -1597,8 +1597,6 @@
goto try_again;
goto out;
}
- /* just incase it was started but has no content */
- ioctl(mdfd, STOP_ARRAY, NULL);
}
if (content != &info) {

View file

@ -2,7 +2,7 @@
Name: mdadm
Version: 4.3
Release: 4%{?dist}
Release: 9%{?dist}
Summary: The mdadm program controls Linux md devices (software RAID arrays)
URL: http://www.kernel.org/pub/linux/utils/raid/mdadm/
License: GPL-2.0-or-later
@ -19,6 +19,15 @@ Source8: mdcheck
Source10: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.sign
Source11: https://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git/plain/keys/6F9E3E9D4EDEBB11.asc
# https://bugzilla.redhat.com/show_bug.cgi?id=2325906
# see: https://github.com/md-raid-utilities/mdadm/pull/165
# https://github.com/md-raid-utilities/mdadm/pull/160
# https://github.com/md-raid-utilities/mdadm/pull/159
# this is a reversion of the initial 'posix check' patch
# that causes all the trouble
Patch: 0001-Revert-mdadm-Follow-POSIX-Portable-Character-Set.patch
Patch: 0002-dont-stop-in-assemble.patch
# Fedora customization patches
Patch: mdadm-udev.patch
Patch: mdadm-2.5.2-static.patch
@ -54,7 +63,8 @@ file can be used to help with some common tasks.
%build
%make_build CXFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon raid6check raid6check.man
# CXFLAGS is NOT a typo, it's baked into the makefile, not to be confused with CXXFLAGS
%make_build CXFLAGS="%{optflags} -std=gnu17 -Wno-error=unterminated-string-initialization" LDFLAGS="$RPM_LD_FLAGS" SYSCONFDIR="%{_sysconfdir}" mdadm mdmon raid6check raid6check.man
%install
@ -62,7 +72,7 @@ file can be used to help with some common tasks.
install -Dp -m 755 %{SOURCE1} %{buildroot}%{_sbindir}/raid-check
install -Dp -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/raid-check
mkdir -p -m 710 %{buildroot}/run/%{name}
mkdir -p -m 700 %{buildroot}%{_datadir}/%{name}
mkdir -p -m 755 %{buildroot}%{_datadir}/%{name}
install -Dp -m 755 %{SOURCE8} %{buildroot}%{_datadir}/%{name}/mdcheck
# systemd
@ -123,6 +133,23 @@ install -Dm644 raid6check.man %{buildroot}/%{_mandir}/man8/raid6check.man
%changelog
* Thu Aug 14 2025 Xiao Ni <xni@redhat.com> - 4.3-9
- Don't submit stop ioctl in assemble
- Resolves bz#2388480
* Thu Jul 24 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Sun Apr 06 2025 Adam Williamson <awilliam@redhat.com> - 4.3-7
- revert 'posix' name check to fix rhbz#2325906
* Thu Jan 23 2025 Jonathan Wright <jonathan@almalinux.org> - 4.3-6
- fix FTBFS on gcc15 rhbz#2340833
- fix permissions on /usr/share/mdadm to be world-readable rhbz#2322402
* Fri Jan 17 2025 Fedora Release Engineering <releng@fedoraproject.org> - 4.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild