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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1427165885-20823-1-git-send-email-csong84@gatech.edu>
Date:	Mon, 23 Mar 2015 22:58:05 -0400
From:	Chengyu Song <csong84@...ech.edu>
To:	bfields@...ldses.org, linux-nfs@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc:	taesoo@...ech.edu, changwoo@...ech.edu, sanidhya@...ech.edu,
	blee@...ech.edu, csong84@...ech.edu
Subject: [PATCH 1/1] nfsd: incorrect check for debugfs returns

debugfs_create_dir and debugfs_create_file may return -ENODEV when debugfs
is not configured, so the return value should be checked against ERROR_VALUE
as well, otherwise the later dereference of the dentry pointer would crash
the kernel.

Signed-off-by: Chengyu Song <csong84@...ech.edu>
---
 fs/nfsd/fault_inject.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index c16bf5a..621d065 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -132,19 +132,23 @@ int nfsd_fault_inject_init(void)
 	unsigned int i;
 	struct nfsd_fault_inject_op *op;
 	umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+	struct dentry *dent;
 
-	debug_dir = debugfs_create_dir("nfsd", NULL);
-	if (!debug_dir)
+	dent = debugfs_create_dir("nfsd", NULL);
+	if (IS_ERR_OR_NULL(dent))
 		goto fail;
+	debug_dir = dent;
 
 	for (i = 0; i < NUM_INJECT_OPS; i++) {
 		op = &inject_ops[i];
-		if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
+		dent = debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd);
+		if (IS_ERR_OR_NULL(dent))
 			goto fail;
+
 	}
 	return 0;
 
 fail:
 	nfsd_fault_inject_cleanup();
-	return -ENOMEM;
+	return dent ? PTR_ERR(dent) : -ENOMEM;
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ