linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] LSM changes for 2.5.38
@ 2002-09-26 20:25 Greg KH
  2002-09-26 20:26 ` Greg KH
  0 siblings, 1 reply; 28+ messages in thread
From: Greg KH @ 2002-09-26 20:25 UTC (permalink / raw)
  To: linux-kernel, linux-security-module

Hi,

Here are some patches against the latest 2.5 BK tree that add some
further LSM hooks and documentation to the tree.  There is also one
minor change to fs/inode.c to allow security modules more information
about newly created inodes.

These changesets can be found at bk://lsm.bkbits.net/linus-2.5 and I'll
be attaching the individual patches as responses to this email for those
who don't want to mess with bitkeeper.

If anyone has any questions or comments on these patches, please let us
know.  Otherwise I'll be sending them off to Linus in a few days.

thanks,

greg k-h


 Documentation/DocBook/Makefile        |    2 
 Documentation/DocBook/kernel-api.tmpl |    5 
 Documentation/DocBook/lsm.tmpl        |  285 +++++++++++++++++++++++++++++++++
 arch/i386/kernel/ioport.c             |   14 +
 arch/ia64/ia32/sys_ia32.c             |    7 
 fs/inode.c                            |    2 
 include/linux/ipc.h                   |    1 
 include/linux/msg.h                   |    1 
 include/linux/security.h              |  291 ++++++++++++++++++++++++++++++++++
 ipc/msg.c                             |   57 ++++++
 ipc/sem.c                             |   43 ++++-
 ipc/shm.c                             |   55 ++++++
 ipc/util.c                            |    3 
 kernel/printk.c                       |    4 
 kernel/sys.c                          |   35 ++--
 kernel/sysctl.c                       |    5 
 kernel/time.c                         |    6 
 mm/oom_kill.c                         |    6 
 mm/swapfile.c                         |   10 +
 security/capability.c                 |  210 ++++++++++++++++++++++++
 security/dummy.c                      |  210 ++++++++++++++++++++++++
 21 files changed, 1227 insertions(+), 25 deletions(-)
-----

ChangeSet@1.615, 2002-09-26 13:13:36-07:00, greg@kroah.com
  LSM: added the LSM documentation to the tree.

 Documentation/DocBook/Makefile        |    2 
 Documentation/DocBook/kernel-api.tmpl |    5 
 Documentation/DocBook/lsm.tmpl        |  285 ++++++++++++++++++++++++++++++++++
 3 files changed, 291 insertions(+), 1 deletion(-)
------

ChangeSet@1.614, 2002-09-26 13:05:47-07:00, sds@tislabs.com
  [PATCH] LSM: inode.c init modification
  
  On Thu, 19 Sep 2002, Greg KH wrote:
  
  > Yes, and explaining the fine points of inode_init() and
  > inode_alloc_security() and why they are different, might be a bit tough.
  >
  > {sigh}, well if there's no other way (and I can't think of one right
  > now), but I really don't like it...
  
  Here's a patch that attempt to support the same functionality without
  inserting hooks into filesystem-specific code.  This patch permits the
  security module to perform initialization of the inode security state
  based on the superblock information, enabling SELinux to initialize
  pipe, devpts, and shm inodes without relying on inode_precondition to
  catch them on first use.
  
  This is achieved simply by moving the initialization of inode->i_sb
  before the call to inode_alloc_security, enabling the
  inode_alloc_security hook function to perform the allocation and
  initialization for such inodes.  No new hooks are required.

 fs/inode.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
------

ChangeSet@1.613, 2002-09-26 11:56:46-07:00, sds@tislabs.com
  [PATCH] LSM: misc hooks addition
  
  The patch below (relative to the LSM IPC hooks patch) adds the LSM hooks
  for miscellaneous system operations (module_*, sethostname, setdomainname,
  reboot, ioperm/iopl, sysctl, swapon/swapoff, syslog, settime).  It also
  replaces the hardcoded capability tests in the OOM killer code with
  appropriate calls to the LSM capable hook, preserving the original behavior
  as long as the capabilities module is enabled.

 arch/i386/kernel/ioport.c |   14 +++++-
 arch/ia64/ia32/sys_ia32.c |    7 +++
 include/linux/security.h  |  106 ++++++++++++++++++++++++++++++++++++++++++++++
 kernel/printk.c           |    4 +
 kernel/sys.c              |   35 ++++++++++-----
 kernel/sysctl.c           |    5 ++
 kernel/time.c             |    6 ++
 mm/oom_kill.c             |    6 +-
 mm/swapfile.c             |   10 ++++
 security/capability.c     |   79 ++++++++++++++++++++++++++++++++++
 security/dummy.c          |   79 ++++++++++++++++++++++++++++++++++
 11 files changed, 337 insertions(+), 14 deletions(-)
------

ChangeSet@1.612, 2002-09-26 11:56:14-07:00, sds@tislabs.com
  [PATCH] LSM: SysV IPC hooks addition
  
  The patch below adds the LSM hooks for System V IPC to the 2.5.38 kernel.

 include/linux/ipc.h      |    1 
 include/linux/msg.h      |    1 
 include/linux/security.h |  185 +++++++++++++++++++++++++++++++++++++++++++++++
 ipc/msg.c                |   57 +++++++++++++-
 ipc/sem.c                |   43 ++++++++++
 ipc/shm.c                |   55 +++++++++++++
 ipc/util.c               |    3 
 security/capability.c    |  131 +++++++++++++++++++++++++++++++++
 security/dummy.c         |  131 +++++++++++++++++++++++++++++++++
 9 files changed, 598 insertions(+), 9 deletions(-)
------


^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: [RFC] LSM changes for 2.5.38
@ 2002-09-27  4:32 Christoph Hellwig
  2002-09-26 22:51 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Christoph Hellwig @ 2002-09-27  4:32 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linux-security-module


>  /* Set EXTENT bits starting at BASE in BITMAP to value TURN_ON. */
>  static void set_bitmap(unsigned long *bitmap, short base, short extent, int new_value)
> @@ -62,7 +63,12 @@
>  		return -EINVAL;
>  	if (turn_on && !capable(CAP_SYS_RAWIO))
>  		return -EPERM;
> -
> + 
> + 	ret = security_ops->ioperm(from, num, turn_on);
> + 	if (ret) {
> + 		return ret;
> + 	}
> + 

Sorry, but this is bullshit (like most of the lsm changes).  Either you
leave the capable in and say it's enough or you add your random hook
and remove that one.  Just adding more and more hooks without thinking
gets us exactly nowhere except to an unmaintainable codebase.

Also is there a _real_ need to pass in all the arguments?

>  			return -EPERM;
>  	}
> +	retval = security_ops->iopl(old, level);
> +	if (retval) {
> +		return retval;
> +	}
> +

again (and another few times)

> + * @module_create:
> + *	Check the permission before allocating space for a module.
> + *	@name contains the module name.
> + *	@size contains the module size.
> + *	Return 0 if permission is granted.
> + * @module_initialize:
> + * 	Check permission before initializing a module.
> + * 	@mod contains a pointer to the module being initialized.
> + *	Return 0 if permission is granted.

Umm, you can't tell me you deny someone to initialize a module he has
just created?

> + * @sethostname:
> + *	Check permission before the hostname is set to @hostname.
> + *	@hostname contains the new hostname
> + *	Return 0 if permission is granted.
> + * @setdomainname:
> + *	Check permission before the domainname is set to @domainname.
> + *	@domainname contains the new domainname
> + *	Return 0 if permission is granted.

You don't think this should maybe be just one hook?

> + * @ioperm:
> + *	Check permission before setting port input/output permissions for the
> + *	process for @num bytes starting from the port address @from to the
> + *	value @turn_on.
> + *	@from contains the starting port address.
> + *	@num contains the number of bytes starting from @from.
> + *	@turn_on contains the permissions value.
> + *	Return 0 if permission is granted.
> + * @iopl:
> + *	Check permission before changing the I/O privilege level of the current
> + *	process from @old to @level.
> + *	@old contains the old level.
> + *	@level contains the new level.
> + *	Return 0 if permission is granted.

Dito.

> + * @sysctl:
> + *	Check permission before accessing the @table sysctl variable in the
> + *	manner specified by @op.
> + *	@table contains the ctl_table structure for the sysctl variable.
> + *	@op contains the operation (001 = search, 002 = write, 004 = read).
> + *	Return 0 if permission is granted.

Aha.  So every LS module knows about every single sysctl in the
kernel.  Common, this is silly guys (and girls if there any)!

> + * @swapon:
> + *	Check permission before enabling swapping to the file or block device
> + *	identified by @swap.
> + *	@swap contains the swap_info_struct structure for the swap file and device.
> + *	Return 0 if permission is granted.
> + * @swapoff:
> + *	Check permission before disabling swapping to the file or block device
> + *	identified by @swap.
> + *	@swap contains the swap_info_struct structure for the swap file and device.
> + *	Return 0 if permission is granted.

You might be allowed to swapon but not swapoff?

> diff -Nru a/kernel/sys.c b/kernel/sys.c
> --- a/kernel/sys.c	Thu Sep 26 13:23:55 2002
> +++ b/kernel/sys.c	Thu Sep 26 13:23:55 2002
> @@ -349,11 +349,17 @@
>  asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void * arg)
>  {
>  	char buffer[256];
> +	int retval;
>  
>  	/* We only trust the superuser with rebooting the system. */
>  	if (!capable(CAP_SYS_BOOT))
>  		return -EPERM;
>  
> +	retval = security_ops->reboot(cmd);
> +	if (retval) {
> +		return retval;
> +	}
> +

What's the point of cmd here?  Someone might be allowed to halt the
system but not reboot?

[don't of stubfs snipped]

> +static int cap_swapon (struct swap_info_struct *swap)
> +{
> +	return 0;
> +}
> +
> +static int cap_swapoff (struct swap_info_struct *swap)
> +{
> +	return 0;
> +}

Live would be a lot simple if an unimplemented op would behave
as returning zero..

	Christoph (not speaking for SGI, just using the fastest mailserver)

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

end of thread, other threads:[~2002-10-02 22:55 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-26 20:25 [RFC] LSM changes for 2.5.38 Greg KH
2002-09-26 20:26 ` Greg KH
2002-09-26 20:27   ` Greg KH
2002-09-26 20:28     ` Greg KH
2002-09-26 20:28       ` Greg KH
2002-09-27  4:32 Christoph Hellwig
2002-09-26 22:51 ` Greg KH
2002-09-27 16:48   ` Christoph Hellwig
2002-09-27 16:55     ` Greg KH
2002-09-27 17:01       ` Christoph Hellwig
2002-09-27 17:24         ` Greg KH
2002-09-27 12:09 ` Stephen Smalley
2002-09-27 16:34   ` Greg KH
2002-09-27 16:55   ` Christoph Hellwig
2002-09-27 18:09     ` Valdis.Kletnieks
2002-09-27 18:19       ` Christoph Hellwig
2002-09-27 18:54         ` Valdis.Kletnieks
2002-09-27 18:59           ` Christoph Hellwig
2002-09-30 14:19             ` Valdis.Kletnieks
2002-09-30 14:51               ` Alan Cox
2002-10-01 16:55               ` Christoph Hellwig
2002-10-02 17:55                 ` Valdis.Kletnieks
2002-10-02 18:39                   ` Christoph Hellwig
2002-10-02 22:55                     ` Seth Arnold
2002-10-02 23:07                       ` Alan Cox
2002-09-27 19:00     ` Stephen Smalley
2002-10-01 17:06       ` Christoph Hellwig
2002-09-30  9:08 ` Chris Wright

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).