Home page logo
/

bugtraq logo Bugtraq mailing list archives

NetBSD Security Advisory 2001-008: Processes can gain "Supervisor" privileges on sh3.
From: security-officer () netbsd org
Date: Wed, 30 May 2001 16:26:52 +1000


-----BEGIN PGP SIGNED MESSAGE-----

                 NetBSD Security Advisory 2001-008
                 =================================

Topic:          Processes can gain "Supervisor" privileges on sh3.
Version:        All versions of NetBSD, on the sh3 platform only.
Severity:       Local users may execute code with supervisor privileges.
Fixed:          NetBSD-current:    May 16, 2001
                NetBSD-1.5 branch: May 27, 2001

Abstract
========

Missing validation of user-supplied arguments to a system call can
allow user applications on the sh3 platform to execute code with
supervisor privileges, bypassing normal system protections.

This problem is only present on the sh3 platform, which includes the
dreamcast, evbsh3, hpcsh and mmeye ports.


Technical Details
=================

The Hitachi Super-H architecture includes the Status Register, a
processor register which provides status information such as the
true/false condition bit, and which also controls properties among
which is the processor mode (either user mode or privileged mode).
The only component of NetBSD executing in privileged mode is the
kernel; user processes are restricted to user mode and thus cannot
execute privileged processor instructions or access related resources.

As a part of the protection model, the contents of the Status Register
can be modified only when executing in privileged mode.

While reviewing code in NetBSD, it was discovered that the NetBSD
"sigreturn" system call did not do validation of user-supplied Status
Register contents; it was also discovered that the
"process_write_regs" kernel routine, which is used by the procfs and
ptrace(2) facilities, did not do appropriate validation of
user-supplied Status Register contents; in short, it's possible for a
user process to construct and pass an execution context which makes it
resume in privileged mode.


Solutions and Workarounds
=========================

Systems running NetBSD/evbsh3, NetBSD/dreamcast, NetBSD/hpcsh or
NetBSD/mmeye are vulnerable.  Although the NetBSD Project has not
distributed binary releases for these ports yet, binary snapshots
of development versions are known to be in use.

Systems running NetBSD-current dated from before May 16, 2001 should
be upgraded to NetBSD-current dated May 16, 2001 or later.

Systems running NetBSD-release-1-5 dated from before May 27, 2001
should be upgraded to NetBSD-release-1-5 dated May 27, 2001 or later.

The following patches to /sys/arch/sh3/include/psl.h,
/sys/arch/sh3/sh3/compat_13_machdep.c and /sys/arch/sh3/sh3/sh3_machdep.c
should be applied before building a new kernel.  This patch can
be applied (with offset differences) to NetBSD-1.5 or NetBSD-current
kernel sources using the patch(1) command.

Index: include/psl.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sh3/include/psl.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
- --- include/psl.h     1999/09/13 10:31:21     1.1
+++ include/psl.h       2001/05/16 12:42:38     1.2
@@ -57,8 +57,8 @@
 #define        PSL_MBO         0x00000000      /* must be one bits */
 #define        PSL_MBZ         0x8ffffc0c      /* must be zero bits */
 
- -#define PSL_USERSET    0
- -#define PSL_USERSTATIC    (PSL_BL|PSL_RB|PSL_MD|PSL_IMASK)
+#define PSL_USERSET    0
+#define PSL_USERSTATIC (PSL_BL|PSL_RB|PSL_MD|PSL_IMASK|PSL_MBO|PSL_MBZ)
 
 #ifdef _KERNEL
 #include <machine/intr.h>
Index: sh3/compat_13_machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sh3/sh3/compat_13_machdep.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
- --- sh3/compat_13_machdep.c   2000/12/22 22:58:55     1.2
+++ sh3/compat_13_machdep.c     2001/05/16 12:42:38     1.3
@@ -71,16 +71,9 @@
        /* Restore register context. */
        tf = p->p_md.md_regs;
 
- -     /*
- -      * Check for security violations.  If we're returning to
- -      * protected mode, the CPU will validate the segment registers
- -      * automatically and generate a trap on violations.  We handle
- -      * the trap, rather than doing all of the checking here.
- -      */
- -#ifdef TODO
+       /* Check for security violations.  */
        if (((context.sc_ssr ^ tf->tf_ssr) & PSL_USERSTATIC) != 0)
                return (EINVAL);
- -#endif
 
        tf->tf_ssr = context.sc_ssr;
 
Index: sh3/sh3_machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sh3/sh3/sh3_machdep.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
- --- sh3/sh3_machdep.c 2001/04/24 04:31:09     1.12
+++ sh3/sh3_machdep.c   2001/05/16 12:42:38     1.13
@@ -350,21 +350,13 @@
 
        /* Restore signal context. */
        tf = p->p_md.md_regs;
- -     {
- -             /*
- -              * Check for security violations.  If we're returning to
- -              * protected mode, the CPU will validate the segment registers
- -              * automatically and generate a trap on violations.  We handle
- -              * the trap, rather than doing all of the checking here.
- -              */
- -#ifdef TODO
- -       if (((context.sc_ssr ^ tf->tf_ssr) & PSL_USERSTATIC) != 0) {
- -         return (EINVAL);
- -       }
- -#endif
 
- -       tf->tf_ssr = context.sc_ssr;
- -     }
+       /* Check for security violations. */
+       if (((context.sc_ssr ^ tf->tf_ssr) & PSL_USERSTATIC) != 0)
+               return (EINVAL);
+
+       tf->tf_ssr = context.sc_ssr;
+
        tf->tf_r0 = context.sc_r0;
        tf->tf_r1 = context.sc_r1;
        tf->tf_r2 = context.sc_r2;


Thanks To
=========

Klaus Klein for detecting and resolving this problem.


Revision History
================

        2001-05-29      Initial Release

More Information
================

An up-to-date PGP signed copy of this release will be maintained at
  ftp://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2001-008.txt.asc

Information about NetBSD and NetBSD security can be found at
http://www.NetBSD.ORG/ and http://www.NetBSD.ORG/Security/.


Copyright 2001, The NetBSD Foundation, Inc.  All Rights Reserved.

$NetBSD: NetBSD-SA2001-008.txt,v 1.6 2001/05/29 05:58:42 lukem Exp $
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (NetBSD)
Comment: For info see http://www.gnupg.org

iQCVAwUBOxM/ij5Ru2/4N2IFAQFdxwP+J90AP+kzRCmaSrLQ1gwV1eanLLiovUEo
p/nunjBUFJRWo+05uOIBjarf7lV94AVFUkqhZnf4iPoQdmBa/VZjAUBl19XA8pFl
CLNADN7rH6w+yUPlugfNx9k8n5nn3w+vJFjuC+kyyOP5v5Ajld0QgHpvnqbgi/re
iox48ReU/Yw=
=YkBv
-----END PGP SIGNATURE-----


  By Date           By Thread  

Current thread:
  • NetBSD Security Advisory 2001-008: Processes can gain "Supervisor" privileges on sh3. security-officer (May 30)
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]