lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1542703119-20353-1-git-send-email-amhetre@nvidia.com>
Date:   Tue, 20 Nov 2018 14:08:39 +0530
From:   Ashish Mhetre <amhetre@...dia.com>
To:     <tj@...nel.org>, <linux-kernel@...r.kernel.org>
CC:     <linux-tegra@...r.kernel.org>, <vdumpa@...dia.com>,
        <Snikam@...dia.com>, Bo Yan <byan@...dia.com>,
        Ashish Mhetre <amhetre@...dia.com>
Subject: [PATCH] kernfs: Add check for NULL pointer before writing to it.

From: Bo Yan <byan@...dia.com>

The strlcpy function returns the length of source pointer when the
requested size is 0. This behavior is relied upon for sched tracing.
We can't simply return when buf is 0, but we have to protect against the
scenario when buf is 0 and requested size is non-zero, in which case the
strlcpy would lead to illegal memory access.
This issue is reported by coverity as strlcpy might end up using a NULL
buffer and non-zero buf_length value.
To avoid this, add check and return -EINVAL in this case.

Signed-off-by: Bo Yan <byan@...dia.com>
Signed-off-by: Ashish Mhetre <amhetre@...dia.com>
---
 fs/kernfs/dir.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 4ca0b5c..76c85a5 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -129,6 +129,9 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to,
 	size_t depth_from, depth_to, len = 0;
 	int i, j;
 
+	if (WARN_ON(!buf && buflen > 0))
+		return -EINVAL;
+
 	if (!kn_to)
 		return strlcpy(buf, "(null)", buflen);
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ