mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrey Vagin <avagin@openvz.org>,
	Roland McGrath <roland@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	David Howells <dhowells@redhat.com>,
	Dave Jones <davej@redhat.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Pedro Alves <palves@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3.10-rc7] Fix: kernel/ptrace.c: ptrace_peek_siginfo() missing __put_user() validation
Date: Fri, 28 Jun 2013 16:52:05 +0200	[thread overview]
Message-ID: <20130628145205.GA22344@redhat.com> (raw)
In-Reply-To: <20130628134946.GA19422@Krystal>

On 06/28, Mathieu Desnoyers wrote:
>
> This __put_user() could be used by unprivileged processes to write into
> kernel memory. The issue here is that even if copy_siginfo_to_user()
> fails, the error code is not checked before __put_user() is executed.
> Luckily, ptrace_peek_siginfo() has been added within the 3.10-rc cycle,
> so it has not hit a stable release yet.

Agreed, this looks like 3.10 material.

Acked-by: Oleg Nesterov <oleg@redhat.com>

> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> CC: Andrey Vagin <avagin@openvz.org>
> CC: Roland McGrath <roland@redhat.com>
> CC: Oleg Nesterov <oleg@redhat.com>
> CC: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> CC: David Howells <dhowells@redhat.com>
> CC: Dave Jones <davej@redhat.com>
> CC: Pavel Emelyanov <xemul@parallels.com>
> CC: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Pedro Alves <palves@redhat.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Linus Torvalds <torvalds@linux-foundation.org>
> ---
>  kernel/ptrace.c |   20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> Index: linux/kernel/ptrace.c
> ===================================================================
> --- linux.orig/kernel/ptrace.c
> +++ linux/kernel/ptrace.c
> @@ -665,20 +665,22 @@ static int ptrace_peek_siginfo(struct ta
>  		if (unlikely(is_compat_task())) {
>  			compat_siginfo_t __user *uinfo = compat_ptr(data);
>  
> -			ret = copy_siginfo_to_user32(uinfo, &info);
> -			ret |= __put_user(info.si_code, &uinfo->si_code);
> +			if (copy_siginfo_to_user32(uinfo, &info) ||
> +			    __put_user(info.si_code, &uinfo->si_code)) {
> +				ret = -EFAULT;
> +				break;
> +			}
> +
>  		} else
>  #endif
>  		{
>  			siginfo_t __user *uinfo = (siginfo_t __user *) data;
>  
> -			ret = copy_siginfo_to_user(uinfo, &info);
> -			ret |= __put_user(info.si_code, &uinfo->si_code);
> -		}
> -
> -		if (ret) {
> -			ret = -EFAULT;
> -			break;
> +			if (copy_siginfo_to_user(uinfo, &info) ||
> +			    __put_user(info.si_code, &uinfo->si_code)) {
> +				ret = -EFAULT;
> +				break;
> +			}
>  		}
>  
>  		data += sizeof(siginfo_t);
> 
> -- 
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com


  reply	other threads:[~2013-06-28 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28 13:49 Mathieu Desnoyers
2013-06-28 14:52 ` Oleg Nesterov [this message]
2013-06-29 18:29 ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130628145205.GA22344@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=davej@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=palves@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=roland@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®