From patchwork Tue Jul 20 10:51:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Conklin X-Patchwork-Id: 59301 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id C30C5B6EF7 for ; Tue, 20 Jul 2010 20:51:56 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1ObAQQ-00082X-Cn; Tue, 20 Jul 2010 11:51:50 +0100 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1ObAQE-0007z0-2s for kernel-team@lists.ubuntu.com; Tue, 20 Jul 2010 11:51:38 +0100 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1ObAQE-0004dB-0N for ; Tue, 20 Jul 2010 11:51:38 +0100 Received: from [193.85.232.179] (helo=canonical.com) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1ObAQD-0002ov-Tq for kernel-team@lists.ubuntu.com; Tue, 20 Jul 2010 11:51:37 +0100 From: Steve Conklin To: kernel-team@lists.ubuntu.com Subject: [Lucid SRU 3/5] ptrace: Fix ptrace_regset() comments and diagnose errors specifically Date: Tue, 20 Jul 2010 12:51:33 +0200 Message-Id: <1279623095-7773-4-git-send-email-sconklin@canonical.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1279623095-7773-1-git-send-email-sconklin@canonical.com> References: <1279623095-7773-1-git-send-email-sconklin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Suresh Siddha BugLink: http://bugs.launchpad.net/bugs/607653 Return -EINVAL for the bad size and for unrecognized NT_* type in ptrace_regset() instead of -EIO. Also update the comments for this ptrace interface with more clarifications. Requested-by: Roland McGrath Requested-by: Oleg Nesterov Signed-off-by: Suresh Siddha LKML-Reference: <20100222225240.397523600@sbs-t61.sc.intel.com> Acked-by: Roland McGrath Signed-off-by: H. Peter Anvin From upstream commit c6a0dd7ec6fb2d4927979ed4dc562fc5c122d826 Signed-off-by: Steve Conklin --- include/linux/ptrace.h | 5 +++++ kernel/ptrace.c | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 65290f3..b8e8230 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -30,6 +30,11 @@ /* * Generic ptrace interface that exports the architecture specific regsets * using the corresponding NT_* types (which are also used in the core dump). + * Please note that the NT_PRSTATUS note type in a core dump contains a full + * 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the + * elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the + * other user_regset flavors, the user_regset layout and the ELF core dump note + * payload are exactly the same layout. * * This interface usage is as follows: * struct iovec iov = { buf, len}; diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 13b4554..42ad8ae 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -537,7 +537,7 @@ static int ptrace_regset(struct task_struct *task, int req, unsigned int type, int regset_no; if (!regset || (kiov->iov_len % regset->size) != 0) - return -EIO; + return -EINVAL; regset_no = regset - view->regsets; kiov->iov_len = min(kiov->iov_len,