[PATCH] cxl: Fix struct pid leak when attaching a process through kernel API

Subsystems: char and misc drivers, the rest

STALE3939d

3 messages, 3 authors, 2015-11-03 · open the first message on its own page

[PATCH] cxl: Fix struct pid leak when attaching a process through kernel API

From: Frederic Barrat <hidden>
Date: 2015-11-03 12:20:38

When the cxl driver creates a context, it stores the pid of the
calling task, and mistakenly increments the reference count of the
struct pid twice, once through get_task_pid(), once through
get_pid(). The reference count is only decremented once on detach. As
a result, a struct pid is leaked and it reduces the number of
processes that can run simultaneously by one.
The fix is to simply remove the call to get_pid().

There is a separate patch for the user API, since it goes to
different kernel versions.

Signed-off-by: Frederic Barrat <redacted>
Cc: <redacted> # 4.3+
---
 drivers/misc/cxl/api.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index 103baf0..94b6627 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -176,7 +176,6 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,
 
 	if (task) {
 		ctx->pid = get_task_pid(task, PIDTYPE_PID);
-		get_pid(ctx->pid);
 		kernel = false;
 	}
 
-- 
1.9.1

Re: [PATCH] cxl: Fix struct pid leak when attaching a process through kernel API

From: Ian Munsie <hidden>
Date: 2015-11-03 22:27:09

Acked-by: Ian Munsie <redacted>

Re: [PATCH] cxl: Fix struct pid leak when attaching a process through kernel API

From: Andrew Donnellan <hidden>
Date: 2015-11-03 22:46:45

On 03/11/15 23:20, Frederic Barrat wrote:
When the cxl driver creates a context, it stores the pid of the
calling task, and mistakenly increments the reference count of the
struct pid twice, once through get_task_pid(), once through
get_pid(). The reference count is only decremented once on detach. As
a result, a struct pid is leaked and it reduces the number of
processes that can run simultaneously by one.
The fix is to simply remove the call to get_pid().

There is a separate patch for the user API, since it goes to
different kernel versions.

Signed-off-by: Frederic Barrat <redacted>
Cc: <redacted> # 4.3+
Reviewed-by: Andrew Donnellan <redacted>

-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help