Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame] | 1 | From 14f110f0286d38e29ef5e51d7f72e049c2f18323 Mon Sep 17 00:00:00 2001 |
| 2 | From: Logan Gunthorpe <logang@deltatee.com> |
| 3 | Date: Wed, 22 Jun 2022 14:25:08 -0600 |
| 4 | Subject: [PATCH 2/4] DDF: Fix NULL pointer dereference in |
| 5 | validate_geometry_ddf() |
| 6 | |
| 7 | A relatively recent patch added a call to validate_geometry() in |
| 8 | Manage_add() that has level=LEVEL_CONTAINER and chunk=NULL. |
| 9 | |
| 10 | This causes some ddf tests to segfault which aborts the test suite. |
| 11 | |
| 12 | To fix this, avoid dereferencing chunk when the level is |
| 13 | LEVEL_CONTAINER or LEVEL_NONE. |
| 14 | |
| 15 | Fixes: 1f5d54a06df0 ("Manage: Call validate_geometry when adding drive to external container") |
| 16 | Signed-off-by: Logan Gunthorpe <logang@deltatee.com> |
| 17 | Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> |
| 18 | Signed-off-by: Jes Sorensen <jes@trained-monkey.org> |
| 19 | |
| 20 | Upstream-Status: Backport |
| 21 | |
| 22 | Reference to upstream patch: |
| 23 | https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=2b93288a5650 |
| 24 | |
| 25 | Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> |
| 26 | --- |
| 27 | super-ddf.c | 6 +++--- |
| 28 | 1 file changed, 3 insertions(+), 3 deletions(-) |
| 29 | |
| 30 | diff --git a/super-ddf.c b/super-ddf.c |
| 31 | index 65cf727..3ef1293 100644 |
| 32 | --- a/super-ddf.c |
| 33 | +++ b/super-ddf.c |
| 34 | @@ -3369,9 +3369,6 @@ static int validate_geometry_ddf(struct supertype *st, |
| 35 | * If given BVDs, we make an SVD, changing all the GUIDs in the process. |
| 36 | */ |
| 37 | |
| 38 | - if (*chunk == UnSet) |
| 39 | - *chunk = DEFAULT_CHUNK; |
| 40 | - |
| 41 | if (level == LEVEL_NONE) |
| 42 | level = LEVEL_CONTAINER; |
| 43 | if (level == LEVEL_CONTAINER) { |
| 44 | @@ -3381,6 +3378,9 @@ static int validate_geometry_ddf(struct supertype *st, |
| 45 | freesize, verbose); |
| 46 | } |
| 47 | |
| 48 | + if (*chunk == UnSet) |
| 49 | + *chunk = DEFAULT_CHUNK; |
| 50 | + |
| 51 | if (!dev) { |
| 52 | mdu_array_info_t array = { |
| 53 | .level = level, |
| 54 | -- |
| 55 | 2.39.1 |
| 56 | |