summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* imsm: get bus from VMD driver directoryMariusz Tkaczyk2024-08-301-11/+77
| | | | | | | | | | | | | | | Enumeration of VMD child devices is started early, kernel is not waiting for VMD enumeration to finish. It causes that: /sys/bus/pci/drivers/vmd/{dev}/domain/device link might be not yet ready. With PCI gen5 devices we can observe that mdadm is failing to start IMSM raid arrays because of that. In that case, it needs to find bus path manually. Look for bus device in VMD driver directory if realpath() failed with ENOENT. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: add read OROM form ACPI UEFI tablesBlazej Kucman2024-08-131-25/+299
| | | | | | | | | | | | | | | | | | | | | | | OROM - IMSM hardware capabilities EFI vars depends on userspace, they need to be mounted to be accessible. Sporadic problems have been observed with availability at an early assemble stage. It is not possible to fully synchronize EFI vars mounts with udev rules processing. For the reason above, read of IMSM OROM from ACPI tables as secondary option is added. This method will be used for SATA and VMD family controllers. ACPI tables are generated by sysfs, earlier in the boot process, before the stage of RAID assembly. The way of loading OROM via EFI vars is retained, ACPI tables will be a backup way. Two paths will be maintained, because IMSM hardware capabilities are necessary for RAID assembly during booting, so access to them must be provided. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
* mdadm: sysfs.c fix coverity issuesNigel Croxon2024-08-131-1/+3
| | | | | | | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event fixed_size_dest: You might overrun the 32-character fixed-size string "mdi->sys_name" by copying "devnm" without checking the length * Event fixed_size_dest: You might overrun the 50-character fixed-size string "sra->text_version" by copying "buf + 9" without checking the length. * Event string_overflow: You might overrun the 32-character destination string "dev->sys_name" by writing 256 characters from "de->d_name". Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: util.c fix coverity issuesNigel Croxon2024-08-131-16/+25
| | | | | | | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event check_return: Calling "open" without checking return value * Event check_return: Calling "lseek(fd, sector_size, 0)" without checking return value. * Event leaked_handle: Handle variable "fd" going out of scope leaks the handle. * Event leaked_storage: Variable "dir" going out of scope leaks the storage it points to. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "st->devnm" by copying "_devnm" without checking the length. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "container" by copying "dev" without checking the length. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* md.4: replace wrong wordNicolas Roeser2024-08-131-1/+1
| | | | | | There is a wrong word in the md(4) man page, this commit corrects it. Signed-off-by: Nicolas Roeser <nicolas.roeser@alumni.uni-ulm.de>
* mdstat: fix list detach issuesMariusz Tkaczyk2024-08-061-2/+4
| | | | | | | | | | | | Move ent = ent->next; to while. It was outside the loop so if there are more than 2 elements and we are looking for 3rd element it causes infinite loop.. Fix el->next zeroing. It causes segfault in mdstat_free(). Theses issues were not visible in my testing because I had only 2 MD devices. Fixes: 4b3644ab4ce6 ("mdstat: Rework mdstat external arrays handling") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Grow_reshape: set only component_size for size growKinga Stefaniuk2024-08-061-12/+7
| | | | | | | | | | | | Component_size couldn't be set using ioctl when new drive size is big (e.g. 5TB). Command value is bigger than 32 bits and error is reported - it is known ioctl limitation. Remove updating array properties using ioctl, use sysfs instead. Sysfs was introduced in 3.10, so now it is old enough to be safely used. Array_size in sysfs should be set for every size change for external metadata, when grow is performed without errors. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* CI: add new gcc 14Kinga Stefaniuk2024-08-061-7/+11
| | | | | | | | | Add new released gcc to compilation test during GH action. Change runner to Ubuntu 24.04 which supports gcc versions up to 14. Previously ubuntu-latest was used (22.04) which didn't support gcc 13 and 14. Add verification if correct gcc was installed during test. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* super-intel: add define for migr_stateKinga Stefaniuk2024-08-061-7/+9
| | | | | | | Represent migr_state with the define, which helps in code readability. Add new values for Normal and Migration states. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* super-intel: fix compilation errorKinga Stefaniuk2024-08-061-0/+6
| | | | | | | | | | | | | | | | | Fix compilation error: super-intel.c: In function ‘end_migration’: super-intel.c:4360:29: error: writing 2 bytes into a region of size 0 [-Werror=stringop-overflow=] 4360 | dev->vol.migr_state = 0; | ~~~~~~~~~~~~~~~~~~~~^~~ cc1: note: destination object is likely at address zero cc1: all warnings being treated as errors make: *** [Makefile:232: super-intel.o] Error 1 reported, when GCC 14 is used. Return when dev is NULL, to avoid it. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* super-gpt.c: Fix check_return issue in load_gpt()Anna Sztukowska2024-08-051-2/+4
| | | | | | | Fix check_return issue in load_gpt() reported by SAST analysis in super-gpt.c. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
* policy.c: Fix check_return issue in Write_rules()Anna Sztukowska2024-08-051-16/+9
| | | | | | | | Refactor Write_rules() in policy.c to eliminate check_return issue found by SAST analysis. Create udev rules file directly using rule_name instead of creating temporary file and renaming it. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
* mdadm/super1: fix coverity issue RESOURCE_LEAKXiao Ni2024-08-051-0/+3
| | | | | | | Fix resource leak problems in super1.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: fix coverity issue EVALUATION_ORDERXiao Ni2024-08-051-2/+5
| | | | | | | Fix evaluation order problems in super1.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: fix coverity issue DEADCODEXiao Ni2024-08-051-2/+0
| | | | | | | optimal_space is at most 2046. So space can't be larger than UINT16_MAX. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super1: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-4/+16
| | | | | | | It needs to check return value when functions return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/super0: fix coverity issue CHECKED_RETURN and EVALUATION_ORDERXiao Ni2024-08-051-3/+7
| | | | | | | | Fix coverity problems in super0. It needs to check return value when functions return value. And fix EVALUATION_ORDER problems in super0.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/mdstat: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-3/+9
| | | | | | | It needs to check return values when functions return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/mdopen: fix coverity issue STRING_OVERFLOWXiao Ni2024-08-051-1/+1
| | | | | | | Fix string overflow problems in mdopen.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/mdopen: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-1/+5
| | | | | | | It needs to check return values when functions return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/mdmon: fix coverity issue RESOURCE_LEAKXiao Ni2024-08-051-3/+6
| | | | | | | Fix resource leak problem in mdmon.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/mdmon: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-2/+9
| | | | | | | It needs to check return values when functions have return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Incremental: fix coverity issues.Xiao Ni2024-08-051-10/+10
| | | | | | | | There are two issues PW.PARAMETER_HIDDEN (declaration hides parameter 'devname') and INTEGER_OVERFLOW. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: fix coverity issue STRING_OVERFLOWXiao Ni2024-08-051-1/+1
| | | | | | | Fix string overflow problems in Grow.c Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: fix coverity issue RESOURCE_LEAKXiao Ni2024-08-051-11/+31
| | | | | | | Fix some resource leak problems. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/Grow: fix coverity issue CHECKED_RETURNXiao Ni2024-08-051-7/+36
| | | | | | | It needs to check return value when functions have return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: refactor chunk size printBlazej Kucman2024-07-311-43/+49
| | | | | | | | - add imsm_chunk_ops struct for better code readability, - move chunk size mapping to string into array, - add function to print supported chunk sizes by IMSM controller. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
* mdadm: msg.c fix coverity issuesNigel Croxon2024-07-301-1/+8
| | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event check_return: Calling "fcntl(sfd, 4, fl)" without checking return value. This library function may fail and return an error code. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: managemon.c fix coverity issuesNigel Croxon2024-07-301-5/+10
| | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event check_return: Calling "fcntl(fd, 4, fl)" without checking return value. This library function may fail and return an error code. * Event check_after_deref: Null-checking "new" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdstat: Rework mdstat external arrays handlingMariusz Tkaczyk2024-07-3012-124/+167
| | | | | | | | | | | | To avoid repeating mdstat_read() in IncrementalRemove(), new function mdstat_find_by_member_name() has been proposed. With that, IncrementalRemove() handles own copy of mdstat content and there is no need to repeat reading for external stop. Additionally, It proposed few helper to avoid repeating mdstat_ent->metadata_version checks across code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* review.yml: fix typo in DEBIAN compiler flagKinga Stefaniuk2024-07-301-1/+1
| | | | | | Fix typo in -DEBIAN flag in review.yml file. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* Makefile: add more compiler flagsKinga Stefaniuk2024-07-301-1/+22
| | | | | | | | | | | It is essential to avoid vulnerabilities in code as much as possible using safe compilation flags. It is easier if they are added to the Makefile and applied during compilation. Add new gcc flags and make them configurable, because they may not be supported for some compilers. Set FORTIFY_SOURCE with the highest supported value for platform. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* super0: use define for char array in examine_super0Kinga Stefaniuk2024-07-302-1/+4
| | | | | | | | | Using nb with 11 length may cause format-truncation errors, because it was possible to use snprintf with 12 length input and write it to 11 length output. Added new define and use it to avoid this error. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* drive_encryption: Fix ata passthrough12 verifyBlazej Kucman2024-07-241-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Based on documentation SCSI Primary Commands - 4 (SPC-4) only first 7 bits of first byte in sense data are used to store response code. The current verification uses all 8 bits for comparison of response code. Incorrect verification may make impossible to use SATA disks with IMSM, because IMSM requires verification of the encryption state before use. There was issue in kernel libata [1]. This issue hides bug in mdadm because last bit was not set. Example output with affected mdadm: Port3 : /dev/sde (BTPR212503EK120LGN) mdadm: Failed ata passthrough12 ioctl. Device: /dev/sde. mdadm: Failed to get drive encryption information The fix is use the first 7 bits of Byte 0, to compare with the expected values. [1] https://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git/commit/?id=38dab832c3f4 Fixes: df38df3052c3 ("Add reading SATA encryption information") Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
* Detail: fix --detail --export for uuid_zeroKinga Stefaniuk2024-07-241-1/+1
| | | | | | | | | | | | | | Mentioned commit (see Fixes) causes that devices with UUID equal to uuid_zero was not recognized properly. For few devices the first one was taken always, and the same information was printed. It caused regression, when few containers were created, symlinks were generated only for the first one. Add checking if uuid is uuid_zero and, if yes, use devname to differentiate devices. Fixes: 60c19530dd7c ("Detail: remove duplicated code") Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* CI: fetch all of the changes in repositoryKinga Stefaniuk2024-07-241-3/+1
| | | | | | | | GH action is using checkout plugin, which takes fetch-depth as a parameter to specify number of commits to fetch. Setting it to 0 to fetch all of the history of all branches and tags. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* mdadm: do not allow leading dot in MD device nameMariusz Tkaczyk2024-07-191-34/+41
| | | | | | | | | | Do not allow to use '.' on first place for named MD device. Having leading dot might be confusing, MD device cannot be hidden. It also removes possibility to create md device with name '.'. Additionally, code optimalizations are done. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: lib.c fix coverity issuesNigel Croxon2024-07-161-2/+2
| | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event fixed_size_dest: You might overrun the 32-character fixed-size string "devnm" by copying "cp + 1" without checking the length. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "devnm" by copying "cp" without checking the length. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: Query.c fix coverity issuesNigel Croxon2024-07-161-1/+3
| | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event leaked_storage: Variable "sra" going out of scope leaks the storage it points to. * Event uninit_use_in_call: Using uninitialized value "larray_size" when calling "human_size_brief". Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: Monitor.c fix coverity issuesNigel Croxon2024-07-161-4/+8
| | | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event check_return: Calling "fcntl(fd, 2, 1)" without checking return value. This library function may fail and return an error code. * Dereferencing "sl", which is known to be "NULL". * Event fixed_size_dest: You might overrun the 32-character fixed-size string "devnm" by copying "tmp" without checking the length. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* imsm: add indent for encryption detailsMariusz Tkaczyk2024-07-161-1/+1
| | | | | | Improve readability of the output. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Manage: fix is_remove_safe()Mariusz Tkaczyk2024-07-161-1/+1
| | | | | | | Fix for to make --set-faulty working. Fixes: 1b4b73fd535a ("mdadm: Manage.c fix coverity issues") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Manage.c fix coverity issuesNigel Croxon2024-07-101-78/+71
| | | | | | | | | | | | | | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Event parameter_hidden: declaration hides parameter "dv". * Event leaked_storage: Variable "mdi" going out of scope leaks the storage it points to. * Event overwrite_var: Overwriting "mdi" in "mdi = mdi->devs" leaks the storage that "mdi" points to. * Event leaked_handle: Handle variable "lfd" going out of scope leaks the handle. * Event leaked_handle: Returning without closing handle "fd" leaks it. * Event fixed_size_dest: You might overrun the 32-character fixed-sizei string "devnm" by copying the return value of "fd2devnm" without checking the length. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "nm" by copying "nmp" without checking the length. * Event fixed_size_dest: You might overrun the 32-character fixed-size string "devnm" by copying the return value of "fd2devnm" without checking the length. * Event assigned_value: Assigning value "-1" to "tfd" here, but that stored value is overwritten before it can be used. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mapfile.c: Fix STRING_OVERFLOW issueAnna Sztukowska2024-07-101-3/+3
| | | | | | | Fix STRING_OVERFLOW issue found by SAST analysis in map_add() and map_update() in mapfile.c. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
* mdadm/clustermd_tests: adjust test cases to support md module changesHeming Zhao2024-07-104-5/+7
| | | | | | | | | | Since kernel commit db5e653d7c9f ("md: delay choosing sync action to md_start_sync()") delays the start of the sync action, clustermd array sync/resync jobs can happen on any leg of the array. This commit adjusts the test cases to follow the new kernel layer behavior. Signed-off-by: Heming Zhao <heming.zhao@suse.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm/clustermd_tests: add some APIs in func.sh to support running the tests ↵Heming Zhao2024-07-101-0/+60
| | | | | | | | | | without errors clustermd_tests/func.sh lacks some APIs to run, this patch makes clustermd_tests runnable from the test suite. Signed-off-by: Heming Zhao <heming.zhao@suse.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: super-ddf.c fix coverity issuesNigel Croxon2024-07-091-57/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixing the following coding errors the coverity tools found: * Calling "lseek64" without checking return value. This library function may fail and return an error code. * Overrunning array "anchor->pad2" of 3 bytes by passing it to a function which accesses it at byte offset 398 using argument "399UL". * Event leaked_storage: Variable "sra" going out of scope leaks the storage it points to. * Event leaked_storage: Variable "super" going out of scope leaks the storage it points to. * Event leaked_handle: Handle variable "dfd" going out of scope leaks the handle. * Event leaked_storage: Variable "dl1" going out of scope leaks the storage it points to * Event leaked_handle: Handle variable "cfd" going out of scope leaks the handle. * Variable "avail" going out of scope leaks the storage it points to. * Passing unterminated string "super->anchor.revision" to "fprintf", which expects a null-terminated string. * You might overrun the 32-character fixed-size string "st->container_devnm" by copying the return value of "fd2devnm" without checking the length. * Event fixed_size_dest: You might overrun the 33-character fixed-size string "dev->name" by copying "(*d).devname" without checking the length. * Event uninit_use_in_call: Using uninitialized value "info.array.raid_disks" when calling "getinfo_super_ddf" V2: clean up validate_geometry_ddf() routine with Mariusz Tkaczyk recommendations. V3: clean up spaces with Blazej Kucman recommendations. V4: clean up recommended by Mariusz Tkaczyk. V5: clean up recommended by Mariusz Tkaczyk. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: Create.c fix coverity issuesNigel Croxon2024-07-051-3/+3
| | | | | | | | | | | | * Event negative_returns: "fd" is passed to a parameter that cannot be negative. Which is set to -1 to start. * Event open_fn: Returning handle opened by "open_dev_excl". * Event var_assign: Assigning: "container_fd" = handle returned from "open_dev_excl(st->container_devnm)" * Event leaked_handle: Handle variable "container_fd" going out of scope leaks the handle Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: Build.c fix coverity issuesNigel Croxon2024-07-031-6/+6
| | | | | | | Event leaked_handle: Handle variable "bitmap_fd" going out of scope leaks the handle. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* config.c: Fix memory leak in load_containers()Anna Sztukowska2024-07-031-0/+1
| | | | | | | Fix memory leak in load_containers() in config.c reported by SAST analysis. Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>