From: Scotty Bauer <sbauer@eng.utah.edu>
To: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com, x86@kernel.org,
wmealing@redhat.com, ak@linux.intel.com, luto@amacapital.net,
Abhiram Balasubramanian <abhiram@cs.utah.edu>
Subject: [kernel-hardening] Re: [PATCH v3 2/3] x86: SROP mitigation: implement signal cookies
Date: Tue, 8 Mar 2016 14:38:12 -0700 [thread overview]
Message-ID: <56DF4644.1060200@eng.utah.edu> (raw)
In-Reply-To: <20160308210333.7ad77a29@lxorguk.ukuu.org.uk>
On 03/08/2016 02:03 PM, One Thousand Gnomes wrote:
>> static int ia32_restore_sigcontext(struct pt_regs *regs,
>> - struct sigcontext_32 __user *sc)
>> + struct sigcontext_32 __user *sc,
>> + void __user **user_cookie)
>> {
>> unsigned int tmpflags, err = 0;
>> void __user *buf;
>> @@ -105,6 +106,16 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
>> buf = compat_ptr(tmp);
>> } get_user_catch(err);
>>
>> + /*
>> + * If there is fp state get cookie from the top of the fp state,
>> + * else get it from the top of the sig frame.
>> + */
>> +
>> + if (tmp != 0)
>> + *user_cookie = compat_ptr(tmp + fpu__getsize(1));
>> + else
>> + *user_cookie = NULL;
>
> user_cookie is is __user, so shouldn't just be poking at it without
> get/put_user ? It might fault if someone has engineered a bad stack frame.
>
> Alan
>
I guess I got a little carried away with the __user annotations. I will remove the __user annotation from this function
since what we're dereferencing isn't actually a __user pointer, its some stack memory sitting in the caller's stack frame.
see patch 2/3:
void __user *user_cookie;
vv-- Passed in here
if (ia32_restore_sigcontext(regs, &frame->sc, &user_cookie))
goto badframe;
WARNING: multiple messages have this Message-ID (diff)
From: Scotty Bauer <sbauer@eng.utah.edu>
To: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com, x86@kernel.org,
wmealing@redhat.com, ak@linux.intel.com, luto@amacapital.net,
Abhiram Balasubramanian <abhiram@cs.utah.edu>
Subject: Re: [PATCH v3 2/3] x86: SROP mitigation: implement signal cookies
Date: Tue, 8 Mar 2016 14:38:12 -0700 [thread overview]
Message-ID: <56DF4644.1060200@eng.utah.edu> (raw)
In-Reply-To: <20160308210333.7ad77a29@lxorguk.ukuu.org.uk>
On 03/08/2016 02:03 PM, One Thousand Gnomes wrote:
>> static int ia32_restore_sigcontext(struct pt_regs *regs,
>> - struct sigcontext_32 __user *sc)
>> + struct sigcontext_32 __user *sc,
>> + void __user **user_cookie)
>> {
>> unsigned int tmpflags, err = 0;
>> void __user *buf;
>> @@ -105,6 +106,16 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
>> buf = compat_ptr(tmp);
>> } get_user_catch(err);
>>
>> + /*
>> + * If there is fp state get cookie from the top of the fp state,
>> + * else get it from the top of the sig frame.
>> + */
>> +
>> + if (tmp != 0)
>> + *user_cookie = compat_ptr(tmp + fpu__getsize(1));
>> + else
>> + *user_cookie = NULL;
>
> user_cookie is is __user, so shouldn't just be poking at it without
> get/put_user ? It might fault if someone has engineered a bad stack frame.
>
> Alan
>
I guess I got a little carried away with the __user annotations. I will remove the __user annotation from this function
since what we're dereferencing isn't actually a __user pointer, its some stack memory sitting in the caller's stack frame.
see patch 2/3:
void __user *user_cookie;
vv-- Passed in here
if (ia32_restore_sigcontext(regs, &frame->sc, &user_cookie))
goto badframe;
next prev parent reply other threads:[~2016-03-08 21:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 20:47 [kernel-hardening] [PATCH v3 1/3] SROP Mitigation: Architecture independent code for signal cookies Scott Bauer
2016-03-08 20:47 ` Scott Bauer
2016-03-08 20:47 ` [kernel-hardening] [PATCH v3 2/3] x86: SROP mitigation: implement " Scott Bauer
2016-03-08 20:47 ` Scott Bauer
2016-03-08 21:03 ` [kernel-hardening] " One Thousand Gnomes
2016-03-08 21:03 ` One Thousand Gnomes
2016-03-08 21:38 ` Scotty Bauer [this message]
2016-03-08 21:38 ` Scotty Bauer
2016-03-08 20:47 ` [kernel-hardening] [PATCH v3 3/3] SROP mitigation: Add sysctl to disable SROP protection Scott Bauer
2016-03-08 20:47 ` Scott Bauer
2016-03-08 21:00 ` [kernel-hardening] " One Thousand Gnomes
2016-03-08 21:00 ` One Thousand Gnomes
2016-03-10 6:36 ` [kernel-hardening] " Kees Cook
2016-03-10 6:46 ` Andy Lutomirski
2016-03-08 20:58 ` [kernel-hardening] Re: [PATCH v3 1/3] SROP Mitigation: Architecture independent code for signal cookies Andy Lutomirski
2016-03-08 20:58 ` Andy Lutomirski
2016-03-08 21:49 ` [kernel-hardening] " Scotty Bauer
2016-03-08 21:49 ` Scotty Bauer
2016-03-08 21:57 ` [kernel-hardening] " Andy Lutomirski
2016-03-08 21:57 ` Andy Lutomirski
2016-03-08 22:06 ` [kernel-hardening] " Scotty Bauer
2016-03-08 22:06 ` Scotty Bauer
2016-03-09 22:02 ` [kernel-hardening] " Scotty Bauer
2016-03-09 22:02 ` Scotty Bauer
2016-03-08 21:04 ` [kernel-hardening] " kbuild test robot
2016-03-08 21:04 ` kbuild test robot
2016-03-09 8:32 ` [kernel-hardening] " Ingo Molnar
2016-03-09 8:32 ` Ingo Molnar
2016-03-09 22:07 ` [kernel-hardening] " Scotty Bauer
2016-03-09 22:07 ` Scotty Bauer
2016-03-09 22:22 ` [kernel-hardening] " Jonathan Corbet
2016-03-09 22:22 ` Jonathan Corbet
2016-03-10 9:43 ` [kernel-hardening] " Ingo Molnar
2016-03-10 9:43 ` Ingo Molnar
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=56DF4644.1060200@eng.utah.edu \
--to=sbauer@eng.utah.edu \
--cc=abhiram@cs.utah.edu \
--cc=ak@linux.intel.com \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=wmealing@redhat.com \
--cc=x86@kernel.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.