All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: Fix syscall return code when ptrace or audit is active
@ 2008-06-30 14:08 Chris Lalancette
  2008-06-30 15:12 ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Lalancette @ 2008-06-30 14:08 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

Attached is a simple patch to fix the return value from the 64-bit kernel when
you call with a bad system call number with tracing enabled (for either ptrace
or audit).  What should happen is that the user process gets a -ENOSYS return
call from the syscall; what actually happens (only in the 64-bit kernel) is that
you get back the system call number.  The 32-bit kernel does not suffer from
this bug, and the pv-ops implementation in the upstream Linux kernel also does
not have this bug.  The attached patch makes the tracesys path look the same as
it does in upstream Linux, and ensures that we return -ENOSYS on this path.

Signed-off-by: Chris Lalancette <clalance@redhat.com>

[-- Attachment #2: linux-2.6.18-xen-syscall-negative.patch --]
[-- Type: text/x-patch, Size: 632 bytes --]

diff -r b29a06ba7a5f arch/x86_64/kernel/entry-xen.S
--- a/arch/x86_64/kernel/entry-xen.S	Fri Jun 27 16:07:56 2008 +0100
+++ b/arch/x86_64/kernel/entry-xen.S	Mon Jun 30 15:23:56 2008 +0200
@@ -334,12 +334,11 @@ tracesys:
 	LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
 	RESTORE_REST
 	cmpq $__NR_syscall_max,%rax
-	ja  1f
+	ja  int_ret_from_sys_call
 	movq %r10,%rcx	/* fixup for C */
 	call *sys_call_table(,%rax,8)
-1:	movq %rax,RAX-ARGOFFSET(%rsp)
+	movq %rax,RAX-ARGOFFSET(%rsp)
 	/* Use IRET because user could have changed frame */
-	jmp int_ret_from_sys_call
 	CFI_ENDPROC
 END(system_call)
 		

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: [PATCH]: Fix syscall return code when ptrace or audit is active
  2008-06-30 14:08 [PATCH]: Fix syscall return code when ptrace or audit is active Chris Lalancette
@ 2008-06-30 15:12 ` Keir Fraser
  2008-06-30 15:20   ` Chris Lalancette
  0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2008-06-30 15:12 UTC (permalink / raw)
  To: Chris Lalancette, xen-devel@lists.xensource.com

On 30/6/08 15:08, "Chris Lalancette" <clalance@redhat.com> wrote:

> Attached is a simple patch to fix the return value from the 64-bit kernel when
> you call with a bad system call number with tracing enabled (for either ptrace
> or audit).  What should happen is that the user process gets a -ENOSYS return
> call from the syscall; what actually happens (only in the 64-bit kernel) is
> that
> you get back the system call number.  The 32-bit kernel does not suffer from
> this bug, and the pv-ops implementation in the upstream Linux kernel also does
> not have this bug.  The attached patch makes the tracesys path look the same
> as
> it does in upstream Linux, and ensures that we return -ENOSYS on this path.

Thanks. The removal of 'jmp int_ret_from_sys_call' is not part of the
bugfix, and also I think the code is clearer if we keep it. So I've applied
all of this patch except the removal of that jmp.

 -- Keir

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

* Re: [PATCH]: Fix syscall return code when ptrace or audit is active
  2008-06-30 15:12 ` Keir Fraser
@ 2008-06-30 15:20   ` Chris Lalancette
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Lalancette @ 2008-06-30 15:20 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel@lists.xensource.com

Keir Fraser wrote:
> 
> Thanks. The removal of 'jmp int_ret_from_sys_call' is not part of the
> bugfix, and also I think the code is clearer if we keep it. So I've applied
> all of this patch except the removal of that jmp.

Oh yes, of course.  Upstream is just letting it fall through.  That's fine.  Thanks!

Chris Lalancette

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

end of thread, other threads:[~2008-06-30 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-30 14:08 [PATCH]: Fix syscall return code when ptrace or audit is active Chris Lalancette
2008-06-30 15:12 ` Keir Fraser
2008-06-30 15:20   ` Chris Lalancette

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.