Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1184382 > unrolled thread

[RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks

Started byMichael Ellerman <mpe@ellerman.id.au>
First post2015-07-15 09:40 +0200
Last post2015-07-16 05:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
    Re: [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks Kees Cook <keescook@chromium.org> - 2015-07-15 17:20 +0200
      Re: [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for  compat tasks Michael Ellerman <mpe@ellerman.id.au> - 2015-07-16 05:40 +0200

#1184382 — [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks

FromMichael Ellerman <mpe@ellerman.id.au>
Date2015-07-15 09:40 +0200
Subject[RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks
Message-ID<pMpsl-LG-15@gated-at.bofh.it>
SIG_SYS was added in commit a0727e8ce513 "signal, x86: add SIGSYS info
and make it synchronous."

Because we use the asm-generic struct siginfo, we got support for
SIG_SYS for free as part of that commit.

However there was no compat handling added for powerpc. That means we've
been advertising the existence of signfo._sifields._sigsys to compat
tasks, but not actually filling in the fields correctly.

Luckily it looks like no one has noticed, presumably because the only
user of SIGSYS in the kernel is seccomp filter, which we don't support
yet.

So before we enable seccomp filter, add compat handling for SIGSYS.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/compat.h             | 7 +++++++
 arch/powerpc/kernel/signal_32.c               | 5 +++++
 tools/testing/selftests/seccomp/seccomp_bpf.c | 4 ++++
 3 files changed, 16 insertions(+)

diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
index b142b8e0ed9e..4f2df589ec1d 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -174,6 +174,13 @@ typedef struct compat_siginfo {
 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
 			int _fd;
 		} _sigpoll;
+
+		/* SIGSYS */
+		struct {
+			unsigned int _call_addr; /* calling insn */
+			int _syscall;		 /* triggering system call number */
+			unsigned int _arch;	 /* AUDIT_ARCH_* of syscall */
+		} _sigsys;
 	} _sifields;
 } compat_siginfo_t;
 
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index d3a831ac0f92..77f97284124e 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -949,6 +949,11 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s)
 		err |= __put_user(s->si_overrun, &d->si_overrun);
 		err |= __put_user(s->si_int, &d->si_int);
 		break;
+	case __SI_SYS >> 16:
+		err |= __put_user(ptr_to_compat(s->si_call_addr), &d->si_call_addr);
+		err |= __put_user(s->si_syscall, &d->si_syscall);
+		err |= __put_user(s->si_arch, &d->si_arch);
+		break;
 	case __SI_RT >> 16: /* This is not generated by the kernel as of now.  */
 	case __SI_MESGQ >> 16:
 		err |= __put_user(s->si_int, &d->si_int);
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index c5abe7fd7590..b2374c131340 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -645,6 +645,10 @@ static struct siginfo TRAP_info;
 static volatile int TRAP_nr;
 static void TRAP_action(int nr, siginfo_t *info, void *void_context)
 {
+	fprintf(stderr, "in TRAP_action\n");
+	fprintf(stderr, "info->si_call_addr %p\n", info->si_call_addr);
+	fprintf(stderr, "info->si_syscall %u\n", info->si_syscall);
+	fprintf(stderr, "info->si_arch %u\n", info->si_arch);
 	memcpy(&TRAP_info, info, sizeof(TRAP_info));
 	TRAP_nr = nr;
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1184861

FromKees Cook <keescook@chromium.org>
Date2015-07-15 17:20 +0200
Message-ID<pMwDw-3bC-17@gated-at.bofh.it>
In reply to#1184382
On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> SIG_SYS was added in commit a0727e8ce513 "signal, x86: add SIGSYS info
> and make it synchronous."
>
> Because we use the asm-generic struct siginfo, we got support for
> SIG_SYS for free as part of that commit.
>
> However there was no compat handling added for powerpc. That means we've
> been advertising the existence of signfo._sifields._sigsys to compat
> tasks, but not actually filling in the fields correctly.
>
> Luckily it looks like no one has noticed, presumably because the only
> user of SIGSYS in the kernel is seccomp filter, which we don't support
> yet.
>
> So before we enable seccomp filter, add compat handling for SIGSYS.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/include/asm/compat.h             | 7 +++++++
>  arch/powerpc/kernel/signal_32.c               | 5 +++++
>  tools/testing/selftests/seccomp/seccomp_bpf.c | 4 ++++
>  3 files changed, 16 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
> index b142b8e0ed9e..4f2df589ec1d 100644
> --- a/arch/powerpc/include/asm/compat.h
> +++ b/arch/powerpc/include/asm/compat.h
> @@ -174,6 +174,13 @@ typedef struct compat_siginfo {
>                         int _band;      /* POLL_IN, POLL_OUT, POLL_MSG */
>                         int _fd;
>                 } _sigpoll;
> +
> +               /* SIGSYS */
> +               struct {
> +                       unsigned int _call_addr; /* calling insn */
> +                       int _syscall;            /* triggering system call number */
> +                       unsigned int _arch;      /* AUDIT_ARCH_* of syscall */
> +               } _sigsys;
>         } _sifields;
>  } compat_siginfo_t;
>
> diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
> index d3a831ac0f92..77f97284124e 100644
> --- a/arch/powerpc/kernel/signal_32.c
> +++ b/arch/powerpc/kernel/signal_32.c
> @@ -949,6 +949,11 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s)
>                 err |= __put_user(s->si_overrun, &d->si_overrun);
>                 err |= __put_user(s->si_int, &d->si_int);
>                 break;
> +       case __SI_SYS >> 16:
> +               err |= __put_user(ptr_to_compat(s->si_call_addr), &d->si_call_addr);
> +               err |= __put_user(s->si_syscall, &d->si_syscall);
> +               err |= __put_user(s->si_arch, &d->si_arch);
> +               break;
>         case __SI_RT >> 16: /* This is not generated by the kernel as of now.  */
>         case __SI_MESGQ >> 16:
>                 err |= __put_user(s->si_int, &d->si_int);
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index c5abe7fd7590..b2374c131340 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -645,6 +645,10 @@ static struct siginfo TRAP_info;
>  static volatile int TRAP_nr;
>  static void TRAP_action(int nr, siginfo_t *info, void *void_context)
>  {
> +       fprintf(stderr, "in TRAP_action\n");
> +       fprintf(stderr, "info->si_call_addr %p\n", info->si_call_addr);
> +       fprintf(stderr, "info->si_syscall %u\n", info->si_syscall);
> +       fprintf(stderr, "info->si_arch %u\n", info->si_arch);
>         memcpy(&TRAP_info, info, sizeof(TRAP_info));
>         TRAP_nr = nr;
>  }

This chunk looks like left-over debugging?

-Kees

> --
> 2.1.0
>



-- 
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1185466 — Re: [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks

FromMichael Ellerman <mpe@ellerman.id.au>
Date2015-07-16 05:40 +0200
SubjectRe: [RFC PATCH 09/12] powerpc/kernel: Add SIG_SYS support for compat tasks
Message-ID<pMIbD-30a-1@gated-at.bofh.it>
In reply to#1184861
On Wed, 2015-07-15 at 08:12 -0700, Kees Cook wrote:
> On Wed, Jul 15, 2015 at 12:37 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> > index c5abe7fd7590..b2374c131340 100644
> > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> > @@ -645,6 +645,10 @@ static struct siginfo TRAP_info;
> >  static volatile int TRAP_nr;
> >  static void TRAP_action(int nr, siginfo_t *info, void *void_context)
> >  {
> > +       fprintf(stderr, "in TRAP_action\n");
> > +       fprintf(stderr, "info->si_call_addr %p\n", info->si_call_addr);
> > +       fprintf(stderr, "info->si_syscall %u\n", info->si_syscall);
> > +       fprintf(stderr, "info->si_arch %u\n", info->si_arch);
> >         memcpy(&TRAP_info, info, sizeof(TRAP_info));
> >         TRAP_nr = nr;
> >  }
> 
> This chunk looks like left-over debugging?

Urgh yep, that's ugly. Thanks for noticing.

Will remove before merging :)

cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web