[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <52d75d0621851492e1c2cfd1c27ffa6315146fa6.1444302968.git.sergei@s15v.net>
Date: Thu, 8 Oct 2015 14:32:06 +0300
From: Sergei Zviagintsev <sergei@...v.net>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Mack <daniel@...que.org>,
David Herrmann <dh.herrmann@...glemail.com>,
Djalal Harouni <tixxdz@...ndz.org>
Cc: linux-kernel@...r.kernel.org, Sergei Zviagintsev <sergei@...v.net>
Subject: [PATCH 37/44] kdbus: Fix error path in kdbus_meta_proc_collect_cgroup()
Current code checks return value of task_cgroup_path(), which can be
NULL if provided buffer isn't long enough to store path there, but
alters mp->valid in case of error, producing inconsistency. Return
-ENAMETOOLONG if task_cgroup_path() fails.
Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
---
ipc/kdbus/metadata.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
index b8d094d9fb56..f4f2b1af81a7 100644
--- a/ipc/kdbus/metadata.c
+++ b/ipc/kdbus/metadata.c
@@ -269,12 +269,15 @@ static int kdbus_meta_proc_collect_cgroup(struct kdbus_meta_proc *mp)
return -ENOMEM;
s = task_cgroup_path(current, page, PAGE_SIZE);
- if (s) {
- mp->cgroup = kstrdup(s, GFP_KERNEL);
- if (!mp->cgroup) {
- free_page((unsigned long)page);
- return -ENOMEM;
- }
+ if (!s) {
+ free_page((unsigned long)page);
+ return -ENAMETOOLONG;
+ }
+
+ mp->cgroup = kstrdup(s, GFP_KERNEL);
+ if (!mp->cgroup) {
+ free_page((unsigned long)page);
+ return -ENOMEM;
}
free_page((unsigned long)page);
--
1.8.3.1
--
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