From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] signal: Introduce COMPAT_SIGMINSTKSZ for use in compat_sys_sigaltstack
Date: Wed, 25 Jul 2018 17:37:26 +0100 [thread overview]
Message-ID: <20180725163726.GE6866@arm.com> (raw)
In-Reply-To: <20180725155427.GR4240@e103592.cambridge.arm.com>
On Wed, Jul 25, 2018 at 04:54:27PM +0100, Dave Martin wrote:
> On Wed, Jul 25, 2018 at 02:45:11PM +0100, Will Deacon wrote:
> > @@ -3476,7 +3478,8 @@ int restore_altstack(const stack_t __user *uss)
> > stack_t new;
> > if (copy_from_user(&new, uss, sizeof(stack_t)))
> > return -EFAULT;
> > - (void)do_sigaltstack(&new, NULL, current_user_stack_pointer());
> > + (void)do_sigaltstack(&new, NULL, current_user_stack_pointer(),
> > + MINSIGSTKSZ);
>
> Why can't this fail?
>
> If this fails here we silently go wrong, but...
>
> > /* squash all but EFAULT for now */
> > return 0;
> > }
> > @@ -3510,7 +3513,8 @@ static int do_compat_sigaltstack(const compat_stack_t __user *uss_ptr,
> > uss.ss_size = uss32.ss_size;
> > }
> > ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss,
> > - compat_user_stack_pointer());
> > + compat_user_stack_pointer(),
> > + COMPAT_MINSIGSTKSZ);
>
> If this fails on arm64, we seem to SEGV (see compat_sys_rt_sigreturn()).
>
> This patch doesn't introduce this inconsistency, this might be a good
> opportunity to clean it up.
I don't think there's an inconsistency here -- both restore_altstack and
compat_restore_altstack suppress all non--EFAULT errors (remember that uoss
is NULL in both cases, so the copy_from_user() immediately before the
do_sigaltstack() call for the native path is all we care about). I think the
behaviour is: on a sigreturn, if you set the altstack to be an unmapped
address then you get a SEGV, otherwise if you make it invalid in some other
way (e.g. too small) then it's ignored and the old altstack remains intact.
Will
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Dave Martin <Dave.Martin@arm.com>
Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, oleg@redhat.com,
linux@dominikbrodowski.net, viro@zeniv.linux.org.uk,
akpm@linux-foundation.org, steve.mcintyre@arm.com,
linux-arm-kernel@lists.infradead.org, ebiederm@xmission.com
Subject: Re: [PATCH 1/2] signal: Introduce COMPAT_SIGMINSTKSZ for use in compat_sys_sigaltstack
Date: Wed, 25 Jul 2018 17:37:26 +0100 [thread overview]
Message-ID: <20180725163726.GE6866@arm.com> (raw)
In-Reply-To: <20180725155427.GR4240@e103592.cambridge.arm.com>
On Wed, Jul 25, 2018 at 04:54:27PM +0100, Dave Martin wrote:
> On Wed, Jul 25, 2018 at 02:45:11PM +0100, Will Deacon wrote:
> > @@ -3476,7 +3478,8 @@ int restore_altstack(const stack_t __user *uss)
> > stack_t new;
> > if (copy_from_user(&new, uss, sizeof(stack_t)))
> > return -EFAULT;
> > - (void)do_sigaltstack(&new, NULL, current_user_stack_pointer());
> > + (void)do_sigaltstack(&new, NULL, current_user_stack_pointer(),
> > + MINSIGSTKSZ);
>
> Why can't this fail?
>
> If this fails here we silently go wrong, but...
>
> > /* squash all but EFAULT for now */
> > return 0;
> > }
> > @@ -3510,7 +3513,8 @@ static int do_compat_sigaltstack(const compat_stack_t __user *uss_ptr,
> > uss.ss_size = uss32.ss_size;
> > }
> > ret = do_sigaltstack(uss_ptr ? &uss : NULL, &uoss,
> > - compat_user_stack_pointer());
> > + compat_user_stack_pointer(),
> > + COMPAT_MINSIGSTKSZ);
>
> If this fails on arm64, we seem to SEGV (see compat_sys_rt_sigreturn()).
>
> This patch doesn't introduce this inconsistency, this might be a good
> opportunity to clean it up.
I don't think there's an inconsistency here -- both restore_altstack and
compat_restore_altstack suppress all non--EFAULT errors (remember that uoss
is NULL in both cases, so the copy_from_user() immediately before the
do_sigaltstack() call for the native path is all we care about). I think the
behaviour is: on a sigreturn, if you set the altstack to be an unmapped
address then you get a SEGV, otherwise if you make it invalid in some other
way (e.g. too small) then it's ignored and the old altstack remains intact.
Will
next prev parent reply other threads:[~2018-07-25 16:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 13:45 [PATCH 0/2] Don't use SIGMINSTKSZ when enforcing alternative signal stack size for compat tasks Will Deacon
2018-07-25 13:45 ` Will Deacon
2018-07-25 13:45 ` [PATCH 1/2] signal: Introduce COMPAT_SIGMINSTKSZ for use in compat_sys_sigaltstack Will Deacon
2018-07-25 13:45 ` Will Deacon
2018-07-25 15:54 ` Dave Martin
2018-07-25 15:54 ` Dave Martin
2018-07-25 16:37 ` Will Deacon [this message]
2018-07-25 16:37 ` Will Deacon
2018-07-26 10:44 ` Dave Martin
2018-07-26 10:44 ` Dave Martin
2018-07-25 13:45 ` [PATCH 2/2] arm64: compat: Provide definition for COMPAT_SIGMINSTKSZ Will Deacon
2018-07-25 13:45 ` Will Deacon
2018-07-25 15:55 ` Dave Martin
2018-07-25 15:55 ` Dave Martin
2019-07-29 20:23 ` [PATCH 0/2] Don't use SIGMINSTKSZ when enforcing alternative signal stack size for compat tasks Aurelien Jarno
2019-07-29 20:23 ` Aurelien Jarno
2019-07-30 9:27 ` Will Deacon
2019-07-30 9:27 ` Will Deacon
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=20180725163726.GE6866@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 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.