!6 ndctl:backport upstream patches to fix some potential problems
From: @liuzhiqiang26 Reviewed-by: @wubo009,@lixiaokeng Signed-off-by: @wubo009
This commit is contained in:
commit
9a67f950af
@ -0,0 +1,32 @@
|
||||
From b0d9cad81f2e811608b898922643f655043361aa Mon Sep 17 00:00:00 2001
|
||||
From: Vishal Verma <vishal.l.verma@intel.com>
|
||||
Date: Tue, 21 Jul 2020 23:17:27 -0600
|
||||
Subject: [PATCH 1/2] ndctl/namespace: fix a resource leak in
|
||||
file_write_infoblock()
|
||||
|
||||
Static analysis showed that we might leak 'fd' in the given function.
|
||||
Fix the error path to close(fd) if 'fd >= 0' rather than just 'fd > 0'.
|
||||
|
||||
Fixes: 7787807bcffe ("ndctl/namespace: Add write-infoblock command")
|
||||
Cc: Dan Williams <dan.j.williams@intel.com>
|
||||
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
||||
---
|
||||
ndctl/namespace.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
|
||||
index 0550580..17e67c9 100644
|
||||
--- a/ndctl/namespace.c
|
||||
+++ b/ndctl/namespace.c
|
||||
@@ -1977,7 +1977,7 @@ static int file_write_infoblock(const char *path)
|
||||
|
||||
free(buf);
|
||||
out:
|
||||
- if (fd > 0 && fd != STDOUT_FILENO)
|
||||
+ if (fd >= 0 && fd != STDOUT_FILENO)
|
||||
close(fd);
|
||||
return rc;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
33
0002-libndctl-fix-a-potential-buffer-overflow.patch
Normal file
33
0002-libndctl-fix-a-potential-buffer-overflow.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From 2f99e11812e6a4d9814bfc8ef038ca845db5394c Mon Sep 17 00:00:00 2001
|
||||
From: Vishal Verma <vishal.l.verma@intel.com>
|
||||
Date: Thu, 1 Oct 2020 11:10:00 -0600
|
||||
Subject: [PATCH 2/2] libndctl: fix a potential buffer overflow
|
||||
|
||||
Static analysis points out that the 'buf' in ndctl_dimm_is_active was
|
||||
inappropriately sized. We already have 'SYSFS_ATTR_SIZE' for such
|
||||
buffers, and it looks like this was just an oversight.
|
||||
|
||||
Fixes: 0a4509d7de2f ("ndctl: enumerate interleave sets")
|
||||
Cc: Dan Williams <dan.j.williams@intel.com>
|
||||
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
||||
---
|
||||
ndctl/lib/libndctl.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
|
||||
index ee737cb..5b276a7 100644
|
||||
--- a/ndctl/lib/libndctl.c
|
||||
+++ b/ndctl/lib/libndctl.c
|
||||
@@ -3292,8 +3292,8 @@ NDCTL_EXPORT int ndctl_dimm_is_active(struct ndctl_dimm *dimm)
|
||||
{
|
||||
struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(dimm);
|
||||
char *path = dimm->dimm_buf;
|
||||
+ char buf[SYSFS_ATTR_SIZE];
|
||||
int len = dimm->buf_len;
|
||||
- char buf[20];
|
||||
|
||||
if (snprintf(path, len, "%s/state", dimm->dimm_path) >= len) {
|
||||
err(ctx, "%s: buffer too small!\n",
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
10
ndctl.spec
10
ndctl.spec
@ -1,12 +1,15 @@
|
||||
Name: ndctl
|
||||
Version: 68
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: Manage "libnvdimm" subsystem devices (Non-volatile Memory)
|
||||
License: GPLv2
|
||||
Group: System Environment/Base
|
||||
Url: https://github.com/pmem/ndctl
|
||||
Source0: https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
||||
|
||||
Patch1: 0001-ndctl-namespace-fix-a-resource-leak-in-file_write_in.patch
|
||||
Patch2: 0002-libndctl-fix-a-potential-buffer-overflow.patch
|
||||
|
||||
Requires: ndctl-libs%{?_isa} = %{version}-%{release}
|
||||
Requires: daxctl-libs%{?_isa} = %{version}-%{release}
|
||||
BuildRequires: autoconf
|
||||
@ -87,7 +90,7 @@ control API for these devices.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q ndctl-%{version}
|
||||
%autosetup -Sgit -n ndctl-%{version}
|
||||
|
||||
%build
|
||||
echo %{version} > version
|
||||
@ -152,6 +155,9 @@ make check
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Oct 30 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 68-2
|
||||
- backport upstream patches to fix some potential problems
|
||||
|
||||
* Thu Jun 04 2020 lingsheng <lingsheng@huawei.com> - 68-1
|
||||
- update version 68
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user