[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <3ab8431c366af86bd6cefb9852495b67fbb89b3d.1444302968.git.sergei@s15v.net>
Date: Thu, 8 Oct 2015 14:31:59 +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 30/44] kdbus: Cleanup kdbus_meta_proc_mask()
- Simplify if-statements
'proc < KDBUS_META_PROC_NORMAL' test only makes sense when we call
kdbus_proc_permission(). Include it into 'prv_pid != req_pid' branch,
remove redundant assignment of `proc' var and reduce its scope.
- Drop redundant binary operation
In 'proc < KDBUS_META_PROC_NORMAL' case we firstly do
'wanted &= ~flags' and then 'wanted & flags' in the return statement,
which is the same as 'wanted & 0'. Return 0 instead.
- Cosmetic cleanup of the return statement.
Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
---
ipc/kdbus/metadata.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/ipc/kdbus/metadata.c b/ipc/kdbus/metadata.c
index 61215a078359..b8d094d9fb56 100644
--- a/ipc/kdbus/metadata.c
+++ b/ipc/kdbus/metadata.c
@@ -1224,7 +1224,6 @@ static u64 kdbus_meta_proc_mask(struct pid *prv_pid,
u64 wanted)
{
struct pid_namespace *prv_ns, *req_ns;
- unsigned int proc;
prv_ns = ns_of_pid(prv_pid);
req_ns = ns_of_pid(req_pid);
@@ -1243,30 +1242,23 @@ static u64 kdbus_meta_proc_mask(struct pid *prv_pid,
* provider and requestor are the same. If not, we perform rather
* expensive /proc permission checks.
*/
- if (prv_pid == req_pid)
- proc = KDBUS_META_PROC_NORMAL;
- else
- proc = kdbus_proc_permission(req_ns, req_cred, prv_pid);
-
- /* you need /proc access to read standard process attributes */
- if (proc < KDBUS_META_PROC_NORMAL)
- wanted &= ~(KDBUS_ATTACH_TID_COMM |
- KDBUS_ATTACH_PID_COMM |
- KDBUS_ATTACH_SECLABEL |
- KDBUS_ATTACH_CMDLINE |
- KDBUS_ATTACH_CGROUP |
- KDBUS_ATTACH_AUDIT |
- KDBUS_ATTACH_CAPS |
- KDBUS_ATTACH_EXE);
+ if (prv_pid != req_pid) {
+ unsigned int proc = kdbus_proc_permission(req_ns, req_cred,
+ prv_pid);
+
+ /* you need /proc access to read standard process attributes */
+ if (proc < KDBUS_META_PROC_NORMAL)
+ return 0;
+ }
/* clear all non-/proc flags */
return wanted & (KDBUS_ATTACH_TID_COMM |
KDBUS_ATTACH_PID_COMM |
KDBUS_ATTACH_SECLABEL |
- KDBUS_ATTACH_CMDLINE |
- KDBUS_ATTACH_CGROUP |
- KDBUS_ATTACH_AUDIT |
- KDBUS_ATTACH_CAPS |
+ KDBUS_ATTACH_CMDLINE |
+ KDBUS_ATTACH_CGROUP |
+ KDBUS_ATTACH_AUDIT |
+ KDBUS_ATTACH_CAPS |
KDBUS_ATTACH_EXE);
}
--
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