public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: relax ptrace mode in process_vm_readv(2)
@ 2018-03-03 20:11 Alexey Dobriyan
  2018-03-06  0:07 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2018-03-03 20:11 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, yeohc, jann

It is more natural to check for read-from-memory permissions in case of
process_vm_readv() as PTRACE_MODE_ATTACH is equivalent to write
permissions.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 mm/process_vm_access.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/process_vm_access.c
+++ b/mm/process_vm_access.c
@@ -204,7 +204,7 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
 		goto free_proc_pages;
 	}
 
-	mm = mm_access(task, PTRACE_MODE_ATTACH_REALCREDS);
+	mm = mm_access(task, vm_write ? PTRACE_MODE_ATTACH_REALCREDS : PTRACE_MODE_READ_REALCREDS);
 	if (!mm || IS_ERR(mm)) {
 		rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
 		/*

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: relax ptrace mode in process_vm_readv(2)
  2018-03-03 20:11 [PATCH] mm: relax ptrace mode in process_vm_readv(2) Alexey Dobriyan
@ 2018-03-06  0:07 ` Andrew Morton
  2018-03-06 17:44   ` Alexey Dobriyan
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2018-03-06  0:07 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, yeohc, jann

On Sat, 3 Mar 2018 23:11:16 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:

> It is more natural to check for read-from-memory permissions in case of
> process_vm_readv() as PTRACE_MODE_ATTACH is equivalent to write
> permissions.
> 
> ...
>
> --- a/mm/process_vm_access.c
> +++ b/mm/process_vm_access.c
> @@ -204,7 +204,7 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
>  		goto free_proc_pages;
>  	}
>  
> -	mm = mm_access(task, PTRACE_MODE_ATTACH_REALCREDS);
> +	mm = mm_access(task, vm_write ? PTRACE_MODE_ATTACH_REALCREDS : PTRACE_MODE_READ_REALCREDS);
>  	if (!mm || IS_ERR(mm)) {
>  		rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
>  		/*

But what is the risk of breaking existing userspace?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: relax ptrace mode in process_vm_readv(2)
  2018-03-06  0:07 ` Andrew Morton
@ 2018-03-06 17:44   ` Alexey Dobriyan
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2018-03-06 17:44 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, yeohc, jann

On Mon, Mar 05, 2018 at 04:07:10PM -0800, Andrew Morton wrote:
> On Sat, 3 Mar 2018 23:11:16 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
> 
> > It is more natural to check for read-from-memory permissions in case of
> > process_vm_readv() as PTRACE_MODE_ATTACH is equivalent to write
> > permissions.
> > 
> > ...
> >
> > --- a/mm/process_vm_access.c
> > +++ b/mm/process_vm_access.c
> > @@ -204,7 +204,7 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter,
> >  		goto free_proc_pages;
> >  	}
> >  
> > -	mm = mm_access(task, PTRACE_MODE_ATTACH_REALCREDS);
> > +	mm = mm_access(task, vm_write ? PTRACE_MODE_ATTACH_REALCREDS : PTRACE_MODE_READ_REALCREDS);
> >  	if (!mm || IS_ERR(mm)) {
> >  		rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
> >  		/*
> 
> But what is the risk of breaking existing userspace?

Permissions for write/ATTACH should be more strict than for read/READ,
so loosening them should be fine.

Unless LSM does silly things of course.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-06 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-03 20:11 [PATCH] mm: relax ptrace mode in process_vm_readv(2) Alexey Dobriyan
2018-03-06  0:07 ` Andrew Morton
2018-03-06 17:44   ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox