Patchwork [Lucid,SRU,3/5] ptrace: Fix ptrace_regset() comments and diagnose errors specifically

login
register
mail settings
Submitter Steve Conklin
Date July 20, 2010, 10:51 a.m.
Message ID <1279623095-7773-4-git-send-email-sconklin@canonical.com>
Download mbox | patch
Permalink /patch/59301/
State Rejected
Headers show

Comments

Steve Conklin - July 20, 2010, 10:51 a.m.
From: Suresh Siddha <suresh.b.siddha@intel.com>

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 <roland@redhat.com>
Requested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20100222225240.397523600@sbs-t61.sc.intel.com>
Acked-by: Roland McGrath <roland@redhat.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
From upstream commit c6a0dd7ec6fb2d4927979ed4dc562fc5c122d826
Signed-off-by: Steve Conklin <sconklin@canonical.com>
---
 include/linux/ptrace.h |    5 +++++
 kernel/ptrace.c        |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

Patch

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,