All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: Linda Knippers <linda.knippers@hp.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
	James Antill <jantill@redhat.com>,
	redhat-lspp <redhat-lspp@redhat.com>,
	SE Linux <selinux@tycho.nsa.gov>
Subject: Re: [redhat-lspp] Re: [PATCH 2/3] Re: MLS enforcing PTYs, sshd,	and newrole
Date: Thu, 04 Jan 2007 17:19:02 -0500	[thread overview]
Message-ID: <459D7D56.1070503@redhat.com> (raw)
In-Reply-To: <459D784C.4090806@hp.com>

Linda Knippers wrote:
> Daniel J Walsh wrote:
>   
>> We still have a problem on MLS machines, in that newrole can be used to
>> pass data via pseudo terminals.
>>
>> script
>> newrole -l SystemHigh
>> cat TopSecret.doc
>> ^d
>> ^d
>> cat typescript
>>
>> I propose we add this patch to newrole to check if we are on a pseudo
>> terminal and then fail if user is using -l.
>>
>> Basically this patch checks the major number of the stdin, stdout,
>> stderr for a number in the pseudo number range,  If yes the pseudo
>> terminal, if not continue.  Not pretty but it solves the problem.  I
>> could not figure out another way to check if you are on a pseudo terminal.
>> Comments?
>>
>>
>> diff --exclude-from=exclude --exclude POTFILES.in --exclude='*.po'
>> --exclude='*.pot' -N -u -r nsapolicycoreutils/newrole/newrole.c
>> policycoreutils-1.33.7/newrole/newrole.c
>> --- nsapolicycoreutils/newrole/newrole.c        2006-11-29
>> 17:11:18.000000000 -0500
>> +++ policycoreutils-1.33.7/newrole/newrole.c    2007-01-04
>> 16:24:47.000000000 -0500
>> @@ -67,6 +67,7 @@
>> #include <selinux/get_context_list.h>  /* for SELINUX_DEFAULTUSER */
>> #include <signal.h>
>> #include <unistd.h>            /* for getuid(), exit(), getopt() */
>> +#include <sys/stat.h>
>> #ifdef USE_AUDIT
>> #include <libaudit.h>
>> #endif
>> @@ -93,6 +94,19 @@
>>
>> extern char **environ;
>>
>> +static int check_isapty(int fd) {
>> +       struct stat buf;
>> +       if ((isatty(fd)) && (fstat(fd, &buf) == 0)) {
>> +               int dev=major(buf.st_rdev);
>> +               if (dev >  135 && dev < 144) {
>>     
>
> Where do these numbers come from?  Is UNIX98_PTY_SLAVE_MAJOR in
> /usr/include/linux/major.h useful?  That's what the value is on
> my system.  There's also PTY_SLAVE_MAJOR (value of 3) in that
> file, but on my system that's the major for real ttys.
>
>   
>> +                       return 1;
>> +               } else {
>> +                       return 0;
>> +               }
>> +       }
>> +       return 0;
>> +}
>> +                                      /**
>>  * Construct from the current range and specified desired level a resulting
>>  * range. If the specified level is a range, return that. If it is not,
>> then
>> @@ -733,6 +747,7 @@
>>                                        security_context_t *new_context,
>>                                        int *preserve_environment)
>> {
>> +       int i;                  /* index for open file descriptors */
>>        int flag_index;         /* flag index in argv[] */
>>        int clflag;             /* holds codes for command line flags */
>>        char *role_s = NULL;    /* role spec'd by user in argv[] */
>> @@ -793,6 +808,13 @@
>>                                        "specified\n"));
>>                                return -1;
>>                        }
>> +                       for (i=0; i < 3; i++) {
>> +                               if (check_isapty(i)) {
>> +                                       fprintf(stderr, "Error: you are
>> not allowed to change levels on pseudo terminals\n");
>> +                                       return -1;
>> +                               }
>> +                       }
>> +
>>                        level_s = optarg;
>>                        break;
>>                default:
>>
>>
>> -- 
>> This message was distributed to subscribers of the selinux mailing list.
>> If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov
>> with
>> the words "unsubscribe selinux" without quotes as the message.
>>     
devices.txt in kernel documentation.

> 2176 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2176>	136-143 char	Unix98 PTY slaves
> 2177 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2177>			  0 = /dev/pts/0	First Unix98 pseudo-TTY
> 2178 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2178>			  1 = /dev/pts/1	Second Unix98 pesudo-TTY
> 2179 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2179>			    ...
> 2180 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2180>	
> 2181 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2181>			These device nodes are automatically generated with
> 2182 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2182>			the proper permissions and modes by mounting the
> 2183 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2183>			devpts filesystem onto /dev/pts with the appropriate
> 2184 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2184>			mount options (distribution dependent, however, on
> 2185 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2185>			*most* distributions the appropriate options are
> 2186 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2186>			"mode=0620,gid=<gid of the "tty" group>".)
> 2187 <http://www.mjmwired.net/kernel/Documentation/devices.txt#2187>	


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2007-01-04 22:19 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-12  7:33 MLS enforcing PTYs, sshd, and newrole Klaus Weidner
2006-10-12 10:25 ` Russell Coker
2006-10-12 14:48   ` Klaus Weidner
2006-10-12 15:16     ` Michael C Thompson
2006-10-12 16:54     ` [redhat-lspp] " Casey Schaufler
2006-10-12 15:37   ` Casey Schaufler
2006-10-19 13:21     ` [redhat-lspp] " Daniel J Walsh
2006-10-19 13:30       ` Stephen Smalley
2006-10-19 14:06         ` Daniel J Walsh
2006-10-19 14:32           ` Stephen Smalley
2006-10-21  4:37           ` Casey Schaufler
2006-10-23 16:14         ` James Antill
2006-10-23 16:39           ` Casey Schaufler
2006-10-23 16:45             ` Paul Moore
2006-10-23 18:41               ` Casey Schaufler
2006-10-24 20:37           ` James Antill
2006-10-25  0:19             ` George C. Wilson
2006-10-25 11:48             ` Stephen Smalley
2006-10-25 12:22               ` Stephen Smalley
2006-10-25 13:50                 ` James Antill
2006-10-25 13:59                   ` Stephen Smalley
2006-10-25 19:15                     ` James Antill
2006-10-25 19:24                       ` Stephen Smalley
     [not found]                         ` <1161970810.29689.88.camel@code.and.org>
     [not found]                           ` <1161974293.1306.167.camel@moss-spartans.epoch.ncsc.mil>
2006-10-30 20:03                             ` [PATCH 1/3] " James Antill
2006-10-30 20:16                               ` [PATCH 2/3] " James Antill
2006-10-30 20:22                                 ` [PATCH 3/3] " James Antill
2006-10-31 14:23                                 ` [PATCH 2/3] " Stephen Smalley
2006-10-31 14:24                                   ` Stephen Smalley
2006-10-31 15:00                                     ` James Antill
2006-10-31 15:11                                       ` Stephen Smalley
2006-10-31 16:04                                         ` James Antill
2006-10-31 16:21                                           ` Stephen Smalley
2006-10-31 18:33                                             ` James Antill
2006-11-01 12:36                                               ` Stephen Smalley
2007-01-04 21:34                                                 ` [redhat-lspp] " Daniel J Walsh
2007-01-04 21:57                                                   ` Linda Knippers
2007-01-04 22:19                                                     ` Daniel J Walsh [this message]
2007-01-04 23:19                                                       ` Linda Knippers
2007-01-05  1:07                                                         ` Klaus Weidner
2007-01-05  3:05                                                           ` Joshua Brindle
2007-01-05  3:33                                                             ` Klaus Weidner
2007-01-05  3:35                                                               ` Joshua Brindle
2007-01-05  4:01                                                                 ` Klaus Weidner
2007-01-05 15:56                                                                   ` Stephen Smalley
2007-01-05 16:23                                                                     ` Daniel J Walsh
2007-01-05 16:24                                                                     ` Daniel J Walsh
2007-01-05 17:05                                                                       ` Daniel J Walsh
2007-01-05 18:34                                                                         ` Stephen Smalley
2007-01-05 18:43                                                                       ` Stephen Smalley
2007-01-05 15:55                                                                 ` Stephen Smalley
2007-01-04 22:13                                                   ` Casey Schaufler
2007-01-04 22:20                                                     ` Daniel J Walsh
2006-10-31 14:20                               ` [PATCH 1/3] " Stephen Smalley
2006-10-25 21:36                       ` [redhat-lspp] " Stephen Smalley
2006-10-26 14:09                         ` Daniel J Walsh
2006-10-19 13:32       ` Steve Grubb
2006-10-19 13:39         ` Stephen Smalley
2006-10-20  7:00       ` Russell Coker
2006-10-27 15:36         ` Valdis.Kletnieks
2006-10-27 23:04           ` Russell Coker
2006-10-31 14:29             ` Stephen Smalley

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=459D7D56.1070503@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=jantill@redhat.com \
    --cc=linda.knippers@hp.com \
    --cc=redhat-lspp@redhat.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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.