dev_name() determine whether the dev->aliases linked list is
empty before obtaining the dev name If dev->aliases linked list is empty, then directly obtain the str address of dm_str_list saved in dev_aliases.n, an unknown address will be returned, which may cause segfault. So we need to judge whether the dev->aliases linked list is empty before getting it to avoid returning unknown address. Fix issue: https://gitee.com/src-openeuler/lvm2/issues/I4RZP9 Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
This commit is contained in:
parent
0cfb6fa80f
commit
100c4fb387
@ -0,0 +1,36 @@
|
||||
From 472dd53a091e0e4b0d2db8fcd10da3f408873633 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||
Date: Sun, 30 Jan 2022 11:37:51 +0800
|
||||
Subject: [PATCH] dev_name() determine whether the dev->aliases linked list is
|
||||
empty before obtaining the dev name
|
||||
|
||||
If dev->aliases linked list is empty, then directly obtain the str
|
||||
address of dm_str_list saved in dev_aliases.n, an unknown address
|
||||
will be returned, which may cause segfault.
|
||||
|
||||
So we need to judge whether the dev->aliases linked list is empty before
|
||||
getting it to avoid returning unknown address.
|
||||
|
||||
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||
---
|
||||
lib/device/dev-cache.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
|
||||
index 33b75a9..1263820 100644
|
||||
--- a/lib/device/dev-cache.c
|
||||
+++ b/lib/device/dev-cache.c
|
||||
@@ -1703,8 +1703,8 @@ int dev_fd(struct device *dev)
|
||||
|
||||
const char *dev_name(const struct device *dev)
|
||||
{
|
||||
- return (dev && dev->aliases.n) ? dm_list_item(dev->aliases.n, struct dm_str_list)->str :
|
||||
- unknown_device_name();
|
||||
+ return (dev && dev->aliases.n && !dm_list_empty(&dev->aliases)) ?\
|
||||
+ dm_list_item(dev->aliases.n, struct dm_str_list)->str : unknown_device_name();
|
||||
}
|
||||
|
||||
bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
|
||||
Name: lvm2
|
||||
Version: 2.03.14
|
||||
Release: 2
|
||||
Release: 3
|
||||
Epoch: 8
|
||||
Summary: Tools for logical volume management
|
||||
License: GPLv2+ and LGPLv2.1 and BSD
|
||||
@ -61,6 +61,7 @@ Patch9: 0009-enhancement-syslog-more-when-use-libdevmapper-so.patch
|
||||
Patch10: 0010-enhancement-log-it-when-disk-slow.patch
|
||||
Patch11: 0011-bugfix-lvm2-fix-the-reuse-of-va_list.patch
|
||||
Patch12: 0012-13-dm-disk.rules-check-DM_NAME-before-create-symlink.patch
|
||||
Patch13: 0013-dev_name-determine-whether-the-dev-aliases-linked-li.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
@ -487,6 +488,10 @@ fi
|
||||
|
||||
|
||||
%changelog
|
||||
* Sun Jan 30 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 8.2.03.14-3
|
||||
- dev_name() determine whether the dev->aliases linked list is
|
||||
empty before obtaining the dev name
|
||||
|
||||
* Sun Jan 30 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 8.2.03.14-2
|
||||
- check DM_NAME before creating symlink in 13-dm-disk.rules
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user