[PATCH 4/4 v2] mm: use access_remote_vm() in get_cmdline()

From: Yang Shi
Date: Mon Feb 26 2018 - 19:26:20 EST


get_cmdline() is using access_process_vm() which increases mm reference
count, but the mm reference count has been increased before calling
access_process_vm() and it is kept across get_cmdline(). It sounds
unnecessary to get mm reference count increased twice, so replace
access_process_vm() to access_remote_vm() which requires caller increase
mm reference count.

Signed-off-by: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx>
---
mm/util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/util.c b/mm/util.c
index c125050..9b40637 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -732,7 +732,7 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
if (len > buflen)
len = buflen;

- res = access_process_vm(task, arg_start, buffer, len, FOLL_FORCE);
+ res = access_remote_vm(mm, arg_start, buffer, len, FOLL_FORCE);

/*
* If the nul at the end of args has been overwritten, then
@@ -746,7 +746,7 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen)
len = env_end - env_start;
if (len > buflen - res)
len = buflen - res;
- res += access_process_vm(task, env_start,
+ res += access_remote_vm(mm, env_start,
buffer+res, len,
FOLL_FORCE);
res = strnlen(buffer, res);
--
1.8.3.1