linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pty: make ptmx file ops read-only after init
@ 2016-09-08 22:35 Kees Cook
  2016-09-14  7:59 ` Jiri Slaby
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2016-09-08 22:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-kernel, kernel-hardening

The ptmx_fops structure is only changed during init, so mark it as such.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/tty/pty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 51e0d32883ba..a23fa5ed1d67 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -800,7 +800,7 @@ out_free_file:
 	return retval;
 }
 
-static struct file_operations ptmx_fops;
+static struct file_operations ptmx_fops __ro_after_init;
 
 static void __init unix98_pty_init(void)
 {
-- 
2.7.4


-- 
Kees Cook
Nexus Security

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

* Re: [PATCH] pty: make ptmx file ops read-only after init
  2016-09-08 22:35 [PATCH] pty: make ptmx file ops read-only after init Kees Cook
@ 2016-09-14  7:59 ` Jiri Slaby
  2016-09-14 14:04   ` One Thousand Gnomes
  0 siblings, 1 reply; 5+ messages in thread
From: Jiri Slaby @ 2016-09-14  7:59 UTC (permalink / raw)
  To: Kees Cook, Greg Kroah-Hartman; +Cc: kernel-hardening, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 767 bytes --]

On 09/09/2016, 12:35 AM, Kees Cook wrote:
> The ptmx_fops structure is only changed during init, so mark it as such.

Right, but I am missing what is the benefit? You would have to elaborate
here...

> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  drivers/tty/pty.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
> index 51e0d32883ba..a23fa5ed1d67 100644
> --- a/drivers/tty/pty.c
> +++ b/drivers/tty/pty.c
> @@ -800,7 +800,7 @@ out_free_file:
>  	return retval;
>  }
>  
> -static struct file_operations ptmx_fops;
> +static struct file_operations ptmx_fops __ro_after_init;
>  
>  static void __init unix98_pty_init(void)
>  {
> 

thanks,
-- 
js
suse labs


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 825 bytes --]

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

* Re: [PATCH] pty: make ptmx file ops read-only after init
  2016-09-14  7:59 ` Jiri Slaby
@ 2016-09-14 14:04   ` One Thousand Gnomes
  2016-09-14 16:17     ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: One Thousand Gnomes @ 2016-09-14 14:04 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Kees Cook, Greg Kroah-Hartman, kernel-hardening, linux-kernel

On Wed, 14 Sep 2016 09:59:42 +0200
Jiri Slaby <jslaby@suse.cz> wrote:

> On 09/09/2016, 12:35 AM, Kees Cook wrote:
> > The ptmx_fops structure is only changed during init, so mark it as such.  
> 
> Right, but I am missing what is the benefit? You would have to elaborate
> here...

The pages end up marked read only even to the kernel (and in future could
even be marked read only forever when in kvm if we get suitable virtual
machine extensions). That makes it much harder to patch those vectors
when making security attacks.

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

* Re: [PATCH] pty: make ptmx file ops read-only after init
  2016-09-14 14:04   ` One Thousand Gnomes
@ 2016-09-14 16:17     ` Kees Cook
  2016-09-21  9:40       ` Jiri Slaby
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2016-09-14 16:17 UTC (permalink / raw)
  To: One Thousand Gnomes
  Cc: Jiri Slaby, Greg Kroah-Hartman, kernel-hardening, LKML

On Wed, Sep 14, 2016 at 7:04 AM, One Thousand Gnomes
<gnomes@lxorguk.ukuu.org.uk> wrote:
> On Wed, 14 Sep 2016 09:59:42 +0200
> Jiri Slaby <jslaby@suse.cz> wrote:
>
>> On 09/09/2016, 12:35 AM, Kees Cook wrote:
>> > The ptmx_fops structure is only changed during init, so mark it as such.
>>
>> Right, but I am missing what is the benefit? You would have to elaborate
>> here...
>
> The pages end up marked read only even to the kernel (and in future could
> even be marked read only forever when in kvm if we get suitable virtual
> machine extensions). That makes it much harder to patch those vectors
> when making security attacks.

Correct, this is a continuing effort to reduce the internal attack
surface of the kernel, where one of the most common exploitation
methods is overwriting function pointers.

Some examples of attacks and mitigations are here:
http://kernsec.org/wiki/index.php/Exploit_Methods/Function_pointer_overwrite

While this patch isn't a huge change, it's still a viable candidate. I
send these as I notice them, and hope that other folks will start to
see these opportunities and send more patches too. :)

-Kees

-- 
Kees Cook
Nexus Security

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

* Re: [PATCH] pty: make ptmx file ops read-only after init
  2016-09-14 16:17     ` Kees Cook
@ 2016-09-21  9:40       ` Jiri Slaby
  0 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2016-09-21  9:40 UTC (permalink / raw)
  To: Kees Cook, One Thousand Gnomes; +Cc: Greg Kroah-Hartman, kernel-hardening, LKML

On 09/14/2016, 06:17 PM, Kees Cook wrote:
> Correct, this is a continuing effort to reduce the internal attack
> surface of the kernel, where one of the most common exploitation
> methods is overwriting function pointers.
> 
> Some examples of attacks and mitigations are here:
> http://kernsec.org/wiki/index.php/Exploit_Methods/Function_pointer_overwrite
> 
> While this patch isn't a huge change, it's still a viable candidate. I
> send these as I notice them, and hope that other folks will start to
> see these opportunities and send more patches too. :)

I didn't object to the patch. I could imagine the use case. But putting
the idea to the commit message would have made it clear.

thanks,
-- 
js
suse labs

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

end of thread, other threads:[~2016-09-21  9:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 22:35 [PATCH] pty: make ptmx file ops read-only after init Kees Cook
2016-09-14  7:59 ` Jiri Slaby
2016-09-14 14:04   ` One Thousand Gnomes
2016-09-14 16:17     ` Kees Cook
2016-09-21  9:40       ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).