mdadm/0088-Detect-too-small-device-error-rather-than-underflow-.patch
Neil Brown 0a100e5103 Accepting request 841255 from home:colyli:branches:Base:System
- Update to latest mdadm which is requested by jsc#SLE-13700 from
  partners. Mostly the purpose is for latest Intel IMSM raid
  support, while some other fixes are important too.
- imsm: Correct minimal device size (jsc#SLE-13700)
  0073-imsm-Correct-minimal-device-size.patch
- Detail: show correct bitmap info for cluster raid device
  (jsc#SLE-13700)
  0074-Detail-show-correct-bitmap-info-for-cluster-raid-dev.patch
- imsm: support the Array Creation Time field in metadata
  (jsc#SLE-13700)
  0075-imsm-support-the-Array-Creation-Time-field-in-metada.patch
- imsm: show Subarray and Volume ID in --examine output
  (jsc#SLE-13700)
  0076-imsm-show-Subarray-and-Volume-ID-in-examine-output.patch
- udev: Ignore change event for imsm (jsc#SLE-13700)
  0077-udev-Ignore-change-event-for-imsm.patch
- Manage, imsm: Write metadata before add (jsc#SLE-13700)
  0078-Manage-imsm-Write-metadata-before-add.patch
- Assemble: print error message if mdadm fails assembling
  with --uuid option (jsc#SLE-13700)
  0079-Assemble-print-error-message-if-mdadm-fails-assembli.patch
- clean up meaning of small typo (jsc#SLE-13700)
  0080-clean-up-meaning-of-small-typo.patch
- Assemble.c: respect force flag (jsc#SLE-13700)
  0081-Assemble.c-respect-force-flag.patch
- mdcheck: Log when done (jsc#SLE-13700)
  0082-mdcheck-Log-when-done.patch
- Makefile: add EXTRAVERSION support (jsc#SLE-13700)
  0083-Makefile-add-EXTRAVERSION-support.patch
- uuid.c: split uuid stuffs from util.c (jsc#SLE-13700)

OBS-URL: https://build.opensuse.org/request/show/841255
OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=189
2020-10-15 23:45:51 +00:00

81 lines
2.5 KiB
Diff

From 2cf0433063203fca10d26629c9e090b51fb1d806 Mon Sep 17 00:00:00 2001
From: David Favro <dfavro@meta-dynamic.com>
Date: Sat, 23 May 2020 08:24:59 -0400
Subject: [PATCH 83/89] Detect too-small device: error rather than
underflow/crash
Commit: 2cf0433063203fca10d26629c9e090b51fb1d806
Patch-mainline: mdadm-4.1+
References: jsc#SLE-13700
For 1.x metadata, when the user requested creation of an array on
component devices that were too small even to hold the superblock,
an undetected integer wraparound (underflow) resulted in an enormous
computed size which resulted in various follow-on errors such as
floating-point exception.
This patch detects this condition, prints a reasonable diagnostic
message, and refuses to continue.
Signed-off-by: David Favro <dfavro@meta-dynamic.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
super1.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/super1.c b/super1.c
index e0d80be..7664883 100644
--- a/super1.c
+++ b/super1.c
@@ -2753,6 +2753,7 @@ static int validate_geometry1(struct supertype *st, int level,
unsigned long long ldsize, devsize;
int bmspace;
unsigned long long headroom;
+ unsigned long long overhead;
int fd;
if (level == LEVEL_CONTAINER) {
@@ -2785,10 +2786,6 @@ static int validate_geometry1(struct supertype *st, int level,
close(fd);
devsize = ldsize >> 9;
- if (devsize < 24) {
- *freesize = 0;
- return 0;
- }
/* creating: allow suitable space for bitmap or PPL */
if (consistency_policy == CONSISTENCY_POLICY_PPL)
@@ -2829,15 +2826,27 @@ static int validate_geometry1(struct supertype *st, int level,
case 0: /* metadata at end. Round down and subtract space to reserve */
devsize = (devsize & ~(4ULL*2-1));
/* space for metadata, bblog, bitmap/ppl */
- devsize -= 8*2 + 8 + bmspace;
+ overhead = 8*2 + 8 + bmspace;
+ if (devsize < overhead) /* detect underflow */
+ goto dev_too_small_err;
+ devsize -= overhead;
break;
case 1:
case 2:
+ if (devsize < data_offset) /* detect underflow */
+ goto dev_too_small_err;
devsize -= data_offset;
break;
}
*freesize = devsize;
return 1;
+
+/* Error condition, device cannot even hold the overhead. */
+dev_too_small_err:
+ fprintf(stderr, "device %s is too small (%lluK) for "
+ "required metadata!\n", subdev, devsize>>1);
+ *freesize = 0;
+ return 0;
}
void *super1_make_v0(struct supertype *st, struct mdinfo *info, mdp_super_t *sb0)
--
2.26.2