Merge branch 'master' into next
authorJames Morris <jmorris@namei.org>
Thu, 6 May 2010 00:56:07 +0000 (10:56 +1000)
committerJames Morris <jmorris@namei.org>
Thu, 6 May 2010 00:56:07 +0000 (10:56 +1000)
51 files changed:
Documentation/credentials.txt
Documentation/kernel-parameters.txt
drivers/char/tpm/Kconfig
drivers/char/tpm/tpm.c
drivers/char/tpm/tpm_tis.c
fs/inode.c
fs/namespace.c
include/linux/lsm_audit.h
include/linux/security.h
kernel/acct.c
kernel/cred.c
kernel/groups.c
kernel/sys.c
scripts/selinux/genheaders/genheaders.c
security/capability.c
security/commoncap.c
security/device_cgroup.c
security/integrity/ima/Kconfig
security/integrity/ima/ima.h
security/integrity/ima/ima_audit.c
security/integrity/ima/ima_crypto.c
security/integrity/ima/ima_fs.c
security/integrity/ima/ima_iint.c
security/integrity/ima/ima_init.c
security/integrity/ima/ima_main.c
security/integrity/ima/ima_policy.c
security/integrity/ima/ima_queue.c
security/keys/key.c
security/keys/keyctl.c
security/keys/keyring.c
security/keys/permission.c
security/keys/proc.c
security/lsm_audit.c
security/min_addr.c
security/security.c
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/include/initial_sid_to_string.h
security/selinux/include/netlabel.h
security/selinux/netlabel.c
security/selinux/netlink.c
security/selinux/nlmsgtab.c
security/selinux/selinuxfs.c
security/selinux/ss/mls.c
security/selinux/ss/policydb.c
security/selinux/ss/services.c
security/smack/smack_lsm.c
security/tomoyo/common.c
security/tomoyo/domain.c
security/tomoyo/file.c
security/tomoyo/realpath.c

index df03169..a2db352 100644 (file)
@@ -408,9 +408,6 @@ This should be used inside the RCU read lock, as in the following example:
                ...
        }
 
-A function need not get RCU read lock to use __task_cred() if it is holding a
-spinlock at the time as this implicitly holds the RCU read lock.
-
 Should it be necessary to hold another task's credentials for a long period of
 time, and possibly to sleep whilst doing so, then the caller should get a
 reference on them using:
@@ -426,17 +423,16 @@ credentials, hiding the RCU magic from the caller:
        uid_t task_uid(task)            Task's real UID
        uid_t task_euid(task)           Task's effective UID
 
-If the caller is holding a spinlock or the RCU read lock at the time anyway,
-then:
+If the caller is holding the RCU read lock at the time anyway, then:
 
        __task_cred(task)->uid
        __task_cred(task)->euid
 
 should be used instead.  Similarly, if multiple aspects of a task's credentials
-need to be accessed, RCU read lock or a spinlock should be used, __task_cred()
-called, the result stored in a temporary pointer and then the credential
-aspects called from that before dropping the lock.  This prevents the
-potentially expensive RCU magic from being invoked multiple times.
+need to be accessed, RCU read lock should be used, __task_cred() called, the
+result stored in a temporary pointer and then the credential aspects called
+from that before dropping the lock.  This prevents the potentially expensive
+RCU magic from being invoked multiple times.
 
 Should some other single aspect of another task's credentials need to be
 accessed, then this can be used:
index 839b21b..db1db1e 100644 (file)
@@ -99,6 +99,7 @@ parameter is applicable:
        SWSUSP  Software suspend (hibernation) is enabled.
        SUSPEND System suspend states are enabled.
        FTRACE  Function tracing enabled.
+       TPM     TPM drivers are enabled.
        TS      Appropriate touchscreen support is enabled.
        UMS     USB Mass Storage support is enabled.
        USB     USB support is enabled.
@@ -2610,6 +2611,15 @@ and is between 256 and 4096 characters. It is defined in the file
 
        tp720=          [HW,PS2]
 
+       tpm_suspend_pcr=[HW,TPM]
+                       Format: integer pcr id
+                       Specify that at suspend time, the tpm driver
+                       should extend the specified pcr with zeros,
+                       as a workaround for some chips which fail to
+                       flush the last written pcr on TPM_SaveState.
+                       This will guarantee that all the other pcrs
+                       are saved.
+
        trace_buf_size=nn[KMG]
                        [FTRACE] will set tracing buffer size.
 
index f5fc64f..bfc2c26 100644 (file)
@@ -17,20 +17,28 @@ menuconfig TCG_TPM
          obtained at: <http://sourceforge.net/projects/trousers>.  To 
          compile this driver as a module, choose M here; the module 
          will be called tpm. If unsure, say N.
-         Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI
-         and CONFIG_PNPACPI.
+         Note: For more TPM drivers and BIOS LOG access enable
+         CONFIG_PNP, CONFIG_ACPI and CONFIG_PNPACPI.
 
 if TCG_TPM
 
 config TCG_TIS
        tristate "TPM Interface Specification 1.2 Interface"
-       depends on PNP
        ---help---
          If you have a TPM security chip that is compliant with the
          TCG TIS 1.2 TPM specification say Yes and it will be accessible
          from within Linux.  To compile this driver as a module, choose
          M here; the module will be called tpm_tis.
 
+config TCG_BIOS_LOG
+       bool "TPM bios mesurement log"
+       depends on X86
+       select ACPI
+       ---help---
+         ACPI is required for access to bios measurements lists and therefore
+         to validate the PCR[0] value. So say Yes in case you want this
+         feature and, consequently, ACPI will be enabled.
+
 config TCG_NSC
        tristate "National Semiconductor TPM Interface"
        ---help---
index 068c816..05ad4a1 100644 (file)
@@ -1068,6 +1068,27 @@ void tpm_remove_hardware(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(tpm_remove_hardware);
 
+#define TPM_ORD_SAVESTATE cpu_to_be32(152)
+#define SAVESTATE_RESULT_SIZE 10
+
+static struct tpm_input_header savestate_header = {
+       .tag = TPM_TAG_RQU_COMMAND,
+       .length = cpu_to_be32(10),
+       .ordinal = TPM_ORD_SAVESTATE
+};
+
+/* Bug workaround - some TPM's don't flush the most
+ * recently changed pcr on suspend, so force the flush
+ * with an extend to the selected _unused_ non-volatile pcr.
+ */
+static int tpm_suspend_pcr;
+static int __init tpm_suspend_setup(char *str)
+{
+       get_option(&str, &tpm_suspend_pcr);
+       return 1;
+}
+__setup("tpm_suspend_pcr=", tpm_suspend_setup);
+
 /*
  * We are about to suspend. Save the TPM state
  * so that it can be restored.
@@ -1075,17 +1096,29 @@ EXPORT_SYMBOL_GPL(tpm_remove_hardware);
 int tpm_pm_suspend(struct device *dev, pm_message_t pm_state)
 {
        struct tpm_chip *chip = dev_get_drvdata(dev);
-       u8 savestate[] = {
-               0, 193,         /* TPM_TAG_RQU_COMMAND */
-               0, 0, 0, 10,    /* blob length (in bytes) */
-               0, 0, 0, 152    /* TPM_ORD_SaveState */
-       };
+       struct tpm_cmd_t cmd;
+       int rc;
+
+       u8 dummy_hash[TPM_DIGEST_SIZE] = { 0 };
 
        if (chip == NULL)
                return -ENODEV;
 
-       tpm_transmit(chip, savestate, sizeof(savestate));
-       return 0;
+       /* for buggy tpm, flush pcrs with extend to selected dummy */
+       if (tpm_suspend_pcr) {
+               cmd.header.in = pcrextend_header;
+               cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(tpm_suspend_pcr);
+               memcpy(cmd.params.pcrextend_in.hash, dummy_hash,
+                      TPM_DIGEST_SIZE);
+               rc = transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE,
+                                 "extending dummy pcr before suspend");
+       }
+
+       /* now do the actual savestate */
+       cmd.header.in = savestate_header;
+       rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE,
+                         "sending savestate before suspend");
+       return rc;
 }
 EXPORT_SYMBOL_GPL(tpm_pm_suspend);
 
index 9434599..24314a9 100644 (file)
@@ -598,7 +598,7 @@ out_err:
        tpm_remove_hardware(chip->dev);
        return rc;
 }
-
+#ifdef CONFIG_PNP
 static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
                                      const struct pnp_device_id *pnp_id)
 {
@@ -663,7 +663,7 @@ static struct pnp_driver tis_pnp_driver = {
 module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id,
                    sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);
 MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
-
+#endif
 static int tpm_tis_suspend(struct platform_device *dev, pm_message_t msg)
 {
        return tpm_pm_suspend(&dev->dev, msg);
@@ -690,21 +690,21 @@ MODULE_PARM_DESC(force, "Force device probe rather than using ACPI entry");
 static int __init init_tis(void)
 {
        int rc;
+#ifdef CONFIG_PNP
+       if (!force)
+               return pnp_register_driver(&tis_pnp_driver);
+#endif
 
-       if (force) {
-               rc = platform_driver_register(&tis_drv);
-               if (rc < 0)
-                       return rc;
-               if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0)))
-                       return PTR_ERR(pdev);
-               if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) {
-                       platform_device_unregister(pdev);
-                       platform_driver_unregister(&tis_drv);
-               }
+       rc = platform_driver_register(&tis_drv);
+       if (rc < 0)
                return rc;
+       if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0)))
+               return PTR_ERR(pdev);
+       if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) {
+               platform_device_unregister(pdev);
+               platform_driver_unregister(&tis_drv);
        }
-
-       return pnp_register_driver(&tis_pnp_driver);
+       return rc;
 }
 
 static void __exit cleanup_tis(void)
@@ -728,12 +728,14 @@ static void __exit cleanup_tis(void)
                list_del(&i->list);
        }
        spin_unlock(&tis_lock);
-
-       if (force) {
-               platform_device_unregister(pdev);
-               platform_driver_unregister(&tis_drv);
-       } else
+#ifdef CONFIG_PNP
+       if (!force) {
                pnp_unregister_driver(&tis_pnp_driver);
+               return;
+       }
+#endif
+       platform_device_unregister(pdev);
+       platform_driver_unregister(&tis_drv);
 }
 
 module_init(init_tis);
index 407bf39..258ec22 100644 (file)
@@ -1205,8 +1205,6 @@ void generic_delete_inode(struct inode *inode)
        inodes_stat.nr_inodes--;
        spin_unlock(&inode_lock);
 
-       security_inode_delete(inode);
-
        if (op->delete_inode) {
                void (*delete)(struct inode *) = op->delete_inode;
                /* Filesystems implementing their own
index 8174c8a..c36785a 100644 (file)
@@ -628,7 +628,6 @@ repeat:
                mnt->mnt_pinned = 0;
                spin_unlock(&vfsmount_lock);
                acct_auto_close_mnt(mnt);
-               security_sb_umount_close(mnt);
                goto repeat;
        }
 }
@@ -1117,8 +1116,6 @@ static int do_umount(struct vfsmount *mnt, int flags)
                retval = 0;
        }
        spin_unlock(&vfsmount_lock);
-       if (retval)
-               security_sb_umount_busy(mnt);
        up_write(&namespace_sem);
        release_mounts(&umount_list);
        return retval;
@@ -1435,17 +1432,10 @@ static int graft_tree(struct vfsmount *mnt, struct path *path)
        if (IS_DEADDIR(path->dentry->d_inode))
                goto out_unlock;
 
-       err = security_sb_check_sb(mnt, path);
-       if (err)
-               goto out_unlock;
-
-       err = -ENOENT;
        if (!d_unlinked(path->dentry))
                err = attach_recursive_mnt(mnt, path, NULL);
 out_unlock:
        mutex_unlock(&path->dentry->d_inode->i_mutex);
-       if (!err)
-               security_sb_post_addmount(mnt, path);
        return err;
 }
 
@@ -1581,8 +1571,6 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
        }
        up_write(&sb->s_umount);
        if (!err) {
-               security_sb_post_remount(path->mnt, flags, data);
-
                spin_lock(&vfsmount_lock);
                touch_mnt_namespace(path->mnt->mnt_ns);
                spin_unlock(&vfsmount_lock);
@@ -2277,7 +2265,6 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
        touch_mnt_namespace(current->nsproxy->mnt_ns);
        spin_unlock(&vfsmount_lock);
        chroot_fs_refs(&root, &new);
-       security_sb_post_pivotroot(&root, &new);
        error = 0;
        path_put(&root_parent);
        path_put(&parent_path);
index f78f83d..6907251 100644 (file)
@@ -33,7 +33,7 @@ struct common_audit_data {
 #define LSM_AUDIT_DATA_IPC     4
 #define LSM_AUDIT_DATA_TASK    5
 #define LSM_AUDIT_DATA_KEY     6
-#define LSM_AUDIT_NO_AUDIT     7
+#define LSM_AUDIT_DATA_NONE    7
 #define LSM_AUDIT_DATA_KMOD    8
        struct task_struct *tsk;
        union   {
index 3158dd9..0c88191 100644 (file)
@@ -267,49 +267,16 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     @orig the original mount data copied from userspace.
  *     @copy copied data which will be passed to the security module.
  *     Returns 0 if the copy was successful.
- * @sb_check_sb:
- *     Check permission before the device with superblock @mnt->sb is mounted
- *     on the mount point named by @nd.
- *     @mnt contains the vfsmount for device being mounted.
- *     @path contains the path for the mount point.
- *     Return 0 if permission is granted.
  * @sb_umount:
  *     Check permission before the @mnt file system is unmounted.
  *     @mnt contains the mounted file system.
  *     @flags contains the unmount flags, e.g. MNT_FORCE.
  *     Return 0 if permission is granted.
- * @sb_umount_close:
- *     Close any files in the @mnt mounted filesystem that are held open by
- *     the security module.  This hook is called during an umount operation
- *     prior to checking whether the filesystem is still busy.
- *     @mnt contains the mounted filesystem.
- * @sb_umount_busy:
- *     Handle a failed umount of the @mnt mounted filesystem, e.g.  re-opening
- *     any files that were closed by umount_close.  This hook is called during
- *     an umount operation if the umount fails after a call to the
- *     umount_close hook.
- *     @mnt contains the mounted filesystem.
- * @sb_post_remount:
- *     Update the security module's state when a filesystem is remounted.
- *     This hook is only called if the remount was successful.
- *     @mnt contains the mounted file system.
- *     @flags contains the new filesystem flags.
- *     @data contains the filesystem-specific data.
- * @sb_post_addmount:
- *     Update the security module's state when a filesystem is mounted.
- *     This hook is called any time a mount is successfully grafetd to
- *     the tree.
- *     @mnt contains the mounted filesystem.
- *     @mountpoint contains the path for the mount point.
  * @sb_pivotroot:
  *     Check permission before pivoting the root filesystem.
  *     @old_path contains the path for the new location of the current root (put_old).
  *     @new_path contains the path for the new root (new_root).
  *     Return 0 if permission is granted.
- * @sb_post_pivotroot:
- *     Update module state after a successful pivot.
- *     @old_path contains the path for the old root.
- *     @new_path contains the path for the new root.
  * @sb_set_mnt_opts:
  *     Set the security relevant mount options used for a superblock
  *     @sb the superblock to set security mount options for
@@ -511,12 +478,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     @mnt is the vfsmount where the dentry was looked up
  *     @dentry contains the dentry structure for the file.
  *     Return 0 if permission is granted.
- * @inode_delete:
- *     @inode contains the inode structure for deleted inode.
- *     This hook is called when a deleted inode is released (i.e. an inode
- *     with no hard links has its use count drop to zero).  A security module
- *     can use this hook to release any persistent label associated with the
- *     inode.
  * @inode_setxattr:
  *     Check permission before setting the extended attributes
  *     @value identified by @name for @dentry.
@@ -691,10 +652,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     @old points to the original credentials.
  *     @gfp indicates the atomicity of any memory allocations.
  *     Prepare a new set of credentials by copying the data from the old set.
- * @cred_commit:
- *     @new points to the new credentials.
- *     @old points to the original credentials.
- *     Install a new set of credentials.
  * @cred_transfer:
  *     @new points to the new credentials.
  *     @old points to the original credentials.
@@ -717,18 +674,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     userspace to load a kernel module with the given name.
  *     @kmod_name name of the module requested by the kernel
  *     Return 0 if successful.
- * @task_setuid:
- *     Check permission before setting one or more of the user identity
- *     attributes of the current process.  The @flags parameter indicates
- *     which of the set*uid system calls invoked this hook and how to
- *     interpret the @id0, @id1, and @id2 parameters.  See the LSM_SETID
- *     definitions at the beginning of this file for the @flags values and
- *     their meanings.
- *     @id0 contains a uid.
- *     @id1 contains a uid.
- *     @id2 contains a uid.
- *     @flags contains one of the LSM_SETID_* values.
- *     Return 0 if permission is granted.
  * @task_fix_setuid:
  *     Update the module's state after setting one or more of the user
  *     identity attributes of the current process.  The @flags parameter
@@ -738,18 +683,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     @old is the set of credentials that are being replaces
  *     @flags contains one of the LSM_SETID_* values.
  *     Return 0 on success.
- * @task_setgid:
- *     Check permission before setting one or more of the group identity
- *     attributes of the current process.  The @flags parameter indicates
- *     which of the set*gid system calls invoked this hook and how to
- *     interpret the @id0, @id1, and @id2 parameters.  See the LSM_SETID
- *     definitions at the beginning of this file for the @flags values and
- *     their meanings.
- *     @id0 contains a gid.
- *     @id1 contains a gid.
- *     @id2 contains a gid.
- *     @flags contains one of the LSM_SETID_* values.
- *     Return 0 if permission is granted.
  * @task_setpgid:
  *     Check permission before setting the process group identifier of the
  *     process @p to @pgid.
@@ -771,11 +704,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     @p contains the task_struct for the process and place is into @secid.
  *     In case of failure, @secid will be set to zero.
  *
- * @task_setgroups:
- *     Check permission before setting the supplementary group set of the
- *     current process.
- *     @group_info contains the new group information.
- *     Return 0 if permission is granted.
  * @task_setnice:
  *     Check permission before setting the nice value of @p to @nice.
  *     @p contains the task_struct of process.
@@ -1139,13 +1067,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     Return the length of the string (including terminating NUL) or -ve if
  *      an error.
  *     May also return 0 (and a NULL buffer pointer) if there is no label.
- * @key_session_to_parent:
- *     Forcibly assign the session keyring from a process to its parent
- *     process.
- *     @cred: Pointer to process's credentials
- *     @parent_cred: Pointer to parent process's credentials
- *     @keyring: Proposed new session keyring
- *     Return 0 if permission is granted, -ve error otherwise.
  *
  * Security hooks affecting all System V IPC operations.
  *
@@ -1333,13 +1254,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  *     @cap contains the capability <include/linux/capability.h>.
  *     @audit: Whether to write an audit message or not
  *     Return 0 if the capability is granted for @tsk.
- * @acct:
- *     Check permission before enabling or disabling process accounting.  If
- *     accounting is being enabled, then @file refers to the open file used to
- *     store accounting records.  If accounting is being disabled, then @file
- *     is NULL.
- *     @file contains the file structure for the accounting file (may be NULL).
- *     Return 0 if permission is granted.
  * @sysctl:
  *     Check permission before accessing the @table sysctl variable in the
  *     manner specified by @op.
@@ -1462,7 +1376,6 @@ struct security_operations {
                       const kernel_cap_t *permitted);
        int (*capable) (struct task_struct *tsk, const struct cred *cred,
                        int cap, int audit);
-       int (*acct) (struct file *file);
        int (*sysctl) (struct ctl_table *table, int op);
        int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
        int (*quota_on) (struct dentry *dentry);
@@ -1484,18 +1397,9 @@ struct security_operations {
        int (*sb_statfs) (struct dentry *dentry);
        int (*sb_mount) (char *dev_name, struct path *path,
                         char *type, unsigned long flags, void *data);
-       int (*sb_check_sb) (struct vfsmount *mnt, struct path *path);
        int (*sb_umount) (struct vfsmount *mnt, int flags);
-       void (*sb_umount_close) (struct vfsmount *mnt);
-       void (*sb_umount_busy) (struct vfsmount *mnt);
-       void (*sb_post_remount) (struct vfsmount *mnt,
-                                unsigned long flags, void *data);
-       void (*sb_post_addmount) (struct vfsmount *mnt,
-                                 struct path *mountpoint);
        int (*sb_pivotroot) (struct path *old_path,
                             struct path *new_path);
-       void (*sb_post_pivotroot) (struct path *old_path,
-                                  struct path *new_path);
        int (*sb_set_mnt_opts) (struct super_block *sb,
                                struct security_mnt_opts *opts);
        void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
@@ -1544,7 +1448,6 @@ struct security_operations {
        int (*inode_permission) (struct inode *inode, int mask);
        int (*inode_setattr)    (struct dentry *dentry, struct iattr *attr);
        int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
-       void (*inode_delete) (struct inode *inode);
        int (*inode_setxattr) (struct dentry *dentry, const char *name,
                               const void *value, size_t size, int flags);
        void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
@@ -1585,20 +1488,16 @@ struct security_operations {
        void (*cred_free) (struct cred *cred);
        int (*cred_prepare)(struct cred *new, const struct cred *old,
                            gfp_t gfp);
-       void (*cred_commit)(struct cred *new, const struct cred *old);
        void (*cred_transfer)(struct cred *new, const struct cred *old);
        int (*kernel_act_as)(struct cred *new, u32 secid);
        int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
        int (*kernel_module_request)(char *kmod_name);
-       int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
        int (*task_fix_setuid) (struct cred *new, const struct cred *old,
                                int flags);
-       int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
        int (*task_setpgid) (struct task_struct *p, pid_t pgid);
        int (*task_getpgid) (struct task_struct *p);
        int (*task_getsid) (struct task_struct *p);
        void (*task_getsecid) (struct task_struct *p, u32 *secid);
-       int (*task_setgroups) (struct group_info *group_info);
        int (*task_setnice) (struct task_struct *p, int nice);
        int (*task_setioprio) (struct task_struct *p, int ioprio);
        int (*task_getioprio) (struct task_struct *p);
@@ -1728,9 +1627,6 @@ struct security_operations {
                               const struct cred *cred,
                               key_perm_t perm);
        int (*key_getsecurity)(struct key *key, char **_buffer);
-       int (*key_session_to_parent)(const struct cred *cred,
-                                    const struct cred *parent_cred,
-                                    struct key *key);
 #endif /* CONFIG_KEYS */
 
 #ifdef CONFIG_AUDIT
@@ -1761,7 +1657,6 @@ int security_capset(struct cred *new, const struct cred *old,
 int security_capable(int cap);
 int security_real_capable(struct task_struct *tsk, int cap);
 int security_real_capable_noaudit(struct task_struct *tsk, int cap);
-int security_acct(struct file *file);
 int security_sysctl(struct ctl_table *table, int op);
 int security_quotactl(int cmds, int type, int id, struct super_block *sb);
 int security_quota_on(struct dentry *dentry);
@@ -1783,14 +1678,8 @@ int security_sb_show_options(struct seq_file *m, struct super_block *sb);
 int security_sb_statfs(struct dentry *dentry);
 int security_sb_mount(char *dev_name, struct path *path,
                      char *type, unsigned long flags, void *data);
-int security_sb_check_sb(struct vfsmount *mnt, struct path *path);
 int security_sb_umount(struct vfsmount *mnt, int flags);
-void security_sb_umount_close(struct vfsmount *mnt);
-void security_sb_umount_busy(struct vfsmount *mnt);
-void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
-void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
 int security_sb_pivotroot(struct path *old_path, struct path *new_path);
-void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
 int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
 void security_sb_clone_mnt_opts(const struct super_block *oldsb,
                                struct super_block *newsb);
@@ -1816,7 +1705,6 @@ int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
 int security_inode_permission(struct inode *inode, int mask);
 int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
 int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
-void security_inode_delete(struct inode *inode);
 int security_inode_setxattr(struct dentry *dentry, const char *name,
                            const void *value, size_t size, int flags);
 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
@@ -1850,20 +1738,16 @@ int security_task_create(unsigned long clone_flags);
 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
 void security_cred_free(struct cred *cred);
 int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
-void security_commit_creds(struct cred *new, const struct cred *old);
 void security_transfer_creds(struct cred *new, const struct cred *old);
 int security_kernel_act_as(struct cred *new, u32 secid);
 int security_kernel_create_files_as(struct cred *new, struct inode *inode);
 int security_kernel_module_request(char *kmod_name);
-int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
 int security_task_fix_setuid(struct cred *new, const struct cred *old,
                             int flags);
-int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
 int security_task_setpgid(struct task_struct *p, pid_t pgid);
 int security_task_getpgid(struct task_struct *p);
 int security_task_getsid(struct task_struct *p);
 void security_task_getsecid(struct task_struct *p, u32 *secid);
-int security_task_setgroups(struct group_info *group_info);
 int security_task_setnice(struct task_struct *p, int nice);
 int security_task_setioprio(struct task_struct *p, int ioprio);
 int security_task_getioprio(struct task_struct *p);
@@ -1990,11 +1874,6 @@ int security_real_capable_noaudit(struct task_struct *tsk, int cap)
        return ret;
 }
 
-static inline int security_acct(struct file *file)
-{
-       return 0;
-}
-
 static inline int security_sysctl(struct ctl_table *table, int op)
 {
        return 0;
@@ -2099,41 +1978,17 @@ static inline int security_sb_mount(char *dev_name, struct path *path,
        return 0;
 }
 
-static inline int security_sb_check_sb(struct vfsmount *mnt,
-                                      struct path *path)
-{
-       return 0;
-}
-
 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
 {
        return 0;
 }
 
-static inline void security_sb_umount_close(struct vfsmount *mnt)
-{ }
-
-static inline void security_sb_umount_busy(struct vfsmount *mnt)
-{ }
-
-static inline void security_sb_post_remount(struct vfsmount *mnt,
-                                            unsigned long flags, void *data)
-{ }
-
-static inline void security_sb_post_addmount(struct vfsmount *mnt,
-                                            struct path *mountpoint)
-{ }
-
 static inline int security_sb_pivotroot(struct path *old_path,
                                        struct path *new_path)
 {
        return 0;
 }
 
-static inline void security_sb_post_pivotroot(struct path *old_path,
-                                             struct path *new_path)
-{ }
-
 static inline int security_sb_set_mnt_opts(struct super_block *sb,
                                           struct security_mnt_opts *opts)
 {
@@ -2249,9 +2104,6 @@ static inline int security_inode_getattr(struct vfsmount *mnt,
        return 0;
 }
 
-static inline void security_inode_delete(struct inode *inode)
-{ }
-
 static inline int security_inode_setxattr(struct dentry *dentry,
                const char *name, const void *value, size_t size, int flags)
 {
@@ -2398,11 +2250,6 @@ static inline int security_prepare_creds(struct cred *new,
        return 0;
 }
 
-static inline void security_commit_creds(struct cred *new,
-                                        const struct cred *old)
-{
-}
-
 static inline void security_transfer_creds(struct cred *new,
                                           const struct cred *old)
 {
@@ -2424,12 +2271,6 @@ static inline int security_kernel_module_request(char *kmod_name)
        return 0;
 }
 
-static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2,
-                                      int flags)
-{
-       return 0;
-}
-
 static inline int security_task_fix_setuid(struct cred *new,
                                           const struct cred *old,
                                           int flags)
@@ -2437,12 +2278,6 @@ static inline int security_task_fix_setuid(struct cred *new,
        return cap_task_fix_setuid(new, old, flags);
 }
 
-static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2,
-                                      int flags)
-{
-       return 0;
-}
-
 static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
 {
        return 0;
@@ -2463,11 +2298,6 @@ static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
        *secid = 0;
 }
 
-static inline int security_task_setgroups(struct group_info *group_info)
-{
-       return 0;
-}
-
 static inline int security_task_setnice(struct task_struct *p, int nice)
 {
        return cap_task_setnice(p, nice);
@@ -3064,9 +2894,6 @@ void security_key_free(struct key *key);
 int security_key_permission(key_ref_t key_ref,
                            const struct cred *cred, key_perm_t perm);
 int security_key_getsecurity(struct key *key, char **_buffer);
-int security_key_session_to_parent(const struct cred *cred,
-                                  const struct cred *parent_cred,
-                                  struct key *key);
 
 #else
 
@@ -3094,13 +2921,6 @@ static inline int security_key_getsecurity(struct key *key, char **_buffer)
        return 0;
 }
 
-static inline int security_key_session_to_parent(const struct cred *cred,
-                                                const struct cred *parent_cred,
-                                                struct key *key)
-{
-       return 0;
-}
-
 #endif
 #endif /* CONFIG_KEYS */
 
index 24f8c81..9e53bb2 100644 (file)
@@ -216,7 +216,6 @@ static int acct_on(char *name)
 {
        struct file *file;
        struct vfsmount *mnt;
-       int error;
        struct pid_namespace *ns;
        struct bsd_acct_struct *acct = NULL;
 
@@ -244,13 +243,6 @@ static int acct_on(char *name)
                }
        }
 
-       error = security_acct(file);
-       if (error) {
-               kfree(acct);
-               filp_close(file, NULL);
-               return error;
-       }
-
        spin_lock(&acct_lock);
        if (ns->bacct == NULL) {
                ns->bacct = acct;
@@ -281,7 +273,7 @@ static int acct_on(char *name)
  */
 SYSCALL_DEFINE1(acct, const char __user *, name)
 {
-       int error;
+       int error = 0;
 
        if (!capable(CAP_SYS_PACCT))
                return -EPERM;
@@ -299,13 +291,11 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
                if (acct == NULL)
                        return 0;
 
-               error = security_acct(NULL);
-               if (!error) {
-                       spin_lock(&acct_lock);
-                       acct_file_reopen(acct, NULL, NULL);
-                       spin_unlock(&acct_lock);
-               }
+               spin_lock(&acct_lock);
+               acct_file_reopen(acct, NULL, NULL);
+               spin_unlock(&acct_lock);
        }
+
        return error;
 }
 
index 62af181..31f38a9 100644 (file)
@@ -523,8 +523,6 @@ int commit_creds(struct cred *new)
 #endif
        BUG_ON(atomic_read(&new->usage) < 1);
 
-       security_commit_creds(new, old);
-
        get_cred(new); /* we will require a ref for the subj creds too */
 
        /* dumpability changes */
index 2b45b2e..53b1916 100644 (file)
@@ -164,12 +164,6 @@ int groups_search(const struct group_info *group_info, gid_t grp)
  */
 int set_groups(struct cred *new, struct group_info *group_info)
 {
-       int retval;
-
-       retval = security_task_setgroups(group_info);
-       if (retval)
-               return retval;
-
        put_group_info(new->group_info);
        groups_sort(group_info);
        get_group_info(group_info);
index 7cb426a..0d36d88 100644 (file)
@@ -492,10 +492,6 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
                return -ENOMEM;
        old = current_cred();
 
-       retval = security_task_setgid(rgid, egid, (gid_t)-1, LSM_SETID_RE);
-       if (retval)
-               goto error;
-
        retval = -EPERM;
        if (rgid != (gid_t) -1) {
                if (old->gid == rgid ||
@@ -543,10 +539,6 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
                return -ENOMEM;
        old = current_cred();
 
-       retval = security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_ID);
-       if (retval)
-               goto error;
-
        retval = -EPERM;
        if (capable(CAP_SETGID))
                new->gid = new->egid = new->sgid = new->fsgid = gid;
@@ -610,10 +602,6 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
                return -ENOMEM;
        old = current_cred();
 
-       retval = security_task_setuid(ruid, euid, (uid_t)-1, LSM_SETID_RE);
-       if (retval)
-               goto error;
-
        retval = -EPERM;
        if (ruid != (uid_t) -1) {
                new->uid = ruid;
@@ -675,10 +663,6 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
                return -ENOMEM;
        old = current_cred();
 
-       retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
-       if (retval)
-               goto error;
-
        retval = -EPERM;
        if (capable(CAP_SETUID)) {
                new->suid = new->uid = uid;
@@ -719,9 +703,6 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
        if (!new)
                return -ENOMEM;
 
-       retval = security_task_setuid(ruid, euid, suid, LSM_SETID_RES);
-       if (retval)
-               goto error;
        old = current_cred();
 
        retval = -EPERM;
@@ -788,10 +769,6 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
                return -ENOMEM;
        old = current_cred();
 
-       retval = security_task_setgid(rgid, egid, sgid, LSM_SETID_RES);
-       if (retval)
-               goto error;
-
        retval = -EPERM;
        if (!capable(CAP_SETGID)) {
                if (rgid != (gid_t) -1 && rgid != old->gid &&
@@ -851,9 +828,6 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
        old = current_cred();
        old_fsuid = old->fsuid;
 
-       if (security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS) < 0)
-               goto error;
-
        if (uid == old->uid  || uid == old->euid  ||
            uid == old->suid || uid == old->fsuid ||
            capable(CAP_SETUID)) {
@@ -864,7 +838,6 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
                }
        }
 
-error:
        abort_creds(new);
        return old_fsuid;
 
@@ -888,9 +861,6 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
        old = current_cred();
        old_fsgid = old->fsgid;
 
-       if (security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_FS))
-               goto error;
-
        if (gid == old->gid  || gid == old->egid  ||
            gid == old->sgid || gid == old->fsgid ||
            capable(CAP_SETGID)) {
@@ -900,7 +870,6 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
                }
        }
 
-error:
        abort_creds(new);
        return old_fsgid;
 
index 2462696..58a12c2 100644 (file)
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
        fprintf(fout, "\n");
 
        for (i = 1; i < isids_len; i++) {
-               char *s = initial_sid_to_string[i];
+               const char *s = initial_sid_to_string[i];
                fprintf(fout, "#define SECINITSID_%s", s);
                for (j = 0; j < max(1, 40 - strlen(s)); j++)
                        fprintf(fout, " ");
index 4875142..7f093d5 100644 (file)
 
 #include <linux/security.h>
 
-static int cap_acct(struct file *file)
-{
-       return 0;
-}
-
 static int cap_sysctl(ctl_table *table, int op)
 {
        return 0;
@@ -80,42 +75,16 @@ static int cap_sb_mount(char *dev_name, struct path *path, char *type,
        return 0;
 }
 
-static int cap_sb_check_sb(struct vfsmount *mnt, struct path *path)
-{
-       return 0;
-}
-
 static int cap_sb_umount(struct vfsmount *mnt, int flags)
 {
        return 0;
 }
 
-static void cap_sb_umount_close(struct vfsmount *mnt)
-{
-}
-
-static void cap_sb_umount_busy(struct vfsmount *mnt)
-{
-}
-
-static void cap_sb_post_remount(struct vfsmount *mnt, unsigned long flags,
-                               void *data)
-{
-}
-
-static void cap_sb_post_addmount(struct vfsmount *mnt, struct path *path)
-{
-}
-
 static int cap_sb_pivotroot(struct path *old_path, struct path *new_path)
 {
        return 0;
 }
 
-static void cap_sb_post_pivotroot(struct path *old_path, struct path *new_path)
-{
-}
-
 static int cap_sb_set_mnt_opts(struct super_block *sb,
                               struct security_mnt_opts *opts)
 {
@@ -221,10 +190,6 @@ static int cap_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
        return 0;
 }
 
-static void cap_inode_delete(struct inode *ino)
-{
-}
-
 static void cap_inode_post_setxattr(struct dentry *dentry, const char *name,
                                    const void *value, size_t size, int flags)
 {
@@ -403,10 +368,6 @@ static int cap_cred_prepare(struct cred *new, const struct cred *old, gfp_t gfp)
        return 0;
 }
 
-static void cap_cred_commit(struct cred *new, const struct cred *old)
-{
-}
-
 static void cap_cred_transfer(struct cred *new, const struct cred *old)
 {
 }
@@ -426,16 +387,6 @@ static int cap_kernel_module_request(char *kmod_name)
        return 0;
 }
 
-static int cap_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags)
-{
-       return 0;
-}
-
-static int cap_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags)
-{
-       return 0;
-}
-
 static int cap_task_setpgid(struct task_struct *p, pid_t pgid)
 {
        return 0;
@@ -456,11 +407,6 @@ static void cap_task_getsecid(struct task_struct *p, u32 *secid)
        *secid = 0;
 }
 
-static int cap_task_setgroups(struct group_info *group_info)
-{
-       return 0;
-}
-
 static int cap_task_getioprio(struct task_struct *p)
 {
        return 0;
@@ -875,13 +821,6 @@ static int cap_key_getsecurity(struct key *key, char **_buffer)
        return 0;
 }
 
-static int cap_key_session_to_parent(const struct cred *cred,
-                                    const struct cred *parent_cred,
-                                    struct key *key)
-{
-       return 0;
-}
-
 #endif /* CONFIG_KEYS */
 
 #ifdef CONFIG_AUDIT
@@ -921,7 +860,6 @@ void security_fixup_ops(struct security_operations *ops)
        set_to_cap_if_null(ops, ptrace_traceme);
        set_to_cap_if_null(ops, capget);
        set_to_cap_if_null(ops, capset);
-       set_to_cap_if_null(ops, acct);
        set_to_cap_if_null(ops, capable);
        set_to_cap_if_null(ops, quotactl);
        set_to_cap_if_null(ops, quota_on);
@@ -941,14 +879,8 @@ void security_fixup_ops(struct security_operations *ops)
        set_to_cap_if_null(ops, sb_show_options);
        set_to_cap_if_null(ops, sb_statfs);
        set_to_cap_if_null(ops, sb_mount);
-       set_to_cap_if_null(ops, sb_check_sb);
        set_to_cap_if_null(ops, sb_umount);
-       set_to_cap_if_null(ops, sb_umount_close);
-       set_to_cap_if_null(ops, sb_umount_busy);
-       set_to_cap_if_null(ops, sb_post_remount);
-       set_to_cap_if_null(ops, sb_post_addmount);
        set_to_cap_if_null(ops, sb_pivotroot);
-       set_to_cap_if_null(ops, sb_post_pivotroot);
        set_to_cap_if_null(ops, sb_set_mnt_opts);
        set_to_cap_if_null(ops, sb_clone_mnt_opts);
        set_to_cap_if_null(ops, sb_parse_opts_str);
@@ -968,7 +900,6 @@ void security_fixup_ops(struct security_operations *ops)
        set_to_cap_if_null(ops, inode_permission);
        set_to_cap_if_null(ops, inode_setattr);
        set_to_cap_if_null(ops, inode_getattr);
-       set_to_cap_if_null(ops, inode_delete);
        set_to_cap_if_null(ops, inode_setxattr);
        set_to_cap_if_null(ops, inode_post_setxattr);
        set_to_cap_if_null(ops, inode_getxattr);
@@ -1009,19 +940,15 @@ void security_fixup_ops(struct security_operations *ops)
        set_to_cap_if_null(ops, cred_alloc_blank);
        set_to_cap_if_null(ops, cred_free);
        set_to_cap_if_null(ops, cred_prepare);
-       set_to_cap_if_null(ops, cred_commit);
        set_to_cap_if_null(ops, cred_transfer);
        set_to_cap_if_null(ops, kernel_act_as);
        set_to_cap_if_null(ops, kernel_create_files_as);
        set_to_cap_if_null(ops, kernel_module_request);
-       set_to_cap_if_null(ops, task_setuid);
        set_to_cap_if_null(ops, task_fix_setuid);
-       set_to_cap_if_null(ops, task_setgid);
        set_to_cap_if_null(ops, task_setpgid);
        set_to_cap_if_null(ops, task_getpgid);
        set_to_cap_if_null(ops, task_getsid);
        set_to_cap_if_null(ops, task_getsecid);
-       set_to_cap_if_null(ops, task_setgroups);
        set_to_cap_if_null(ops, task_setnice);
        set_to_cap_if_null(ops, task_setioprio);
        set_to_cap_if_null(ops, task_getioprio);
@@ -1113,7 +1040,6 @@ void security_fixup_ops(struct security_operations *ops)
        set_to_cap_if_null(ops, key_free);
        set_to_cap_if_null(ops, key_permission);
        set_to_cap_if_null(ops, key_getsecurity);
-       set_to_cap_if_null(ops, key_session_to_parent);
 #endif /* CONFIG_KEYS */
 #ifdef CONFIG_AUDIT
        set_to_cap_if_null(ops, audit_rule_init);
index 6166973..4e01599 100644 (file)
@@ -570,7 +570,7 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
        }
 
        if (!strncmp(name, XATTR_SECURITY_PREFIX,
-                    sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
+                    sizeof(XATTR_SECURITY_PREFIX) - 1) &&
            !capable(CAP_SYS_ADMIN))
                return -EPERM;
        return 0;
@@ -596,7 +596,7 @@ int cap_inode_removexattr(struct dentry *dentry, const char *name)
        }
 
        if (!strncmp(name, XATTR_SECURITY_PREFIX,
-                    sizeof(XATTR_SECURITY_PREFIX) - 1)  &&
+                    sizeof(XATTR_SECURITY_PREFIX) - 1) &&
            !capable(CAP_SYS_ADMIN))
                return -EPERM;
        return 0;
@@ -931,7 +931,7 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages)
  * @addr: address attempting to be mapped
  * @addr_only: unused
  *
- * If the process is attempting to map memory below mmap_min_addr they need
+ * If the process is attempting to map memory below dac_mmap_min_addr they need
  * CAP_SYS_RAWIO.  The other parameters to this function are unused by the
  * capability security module.  Returns 0 if this mapping should be allowed
  * -EPERM if not.
index f77c604..8d9c48f 100644 (file)
@@ -470,7 +470,7 @@ struct cgroup_subsys devices_subsys = {
        .name = "devices",
        .can_attach = devcgroup_can_attach,
        .create = devcgroup_create,
-       .destroy  = devcgroup_destroy,
+       .destroy = devcgroup_destroy,
        .populate = devcgroup_populate,
        .subsys_id = devices_subsys_id,
 };
index 3d7846d..b6ecfd4 100644 (file)
@@ -2,15 +2,14 @@
 #
 config IMA
        bool "Integrity Measurement Architecture(IMA)"
-       depends on ACPI
        depends on SECURITY
        select SECURITYFS
        select CRYPTO
        select CRYPTO_HMAC
        select CRYPTO_MD5
        select CRYPTO_SHA1
-       select TCG_TPM
-       select TCG_TIS
+       select TCG_TPM if !S390
+       select TCG_TIS if TCG_TPM
        help
          The Trusted Computing Group(TCG) runtime Integrity
          Measurement Architecture(IMA) maintains a list of hash
index 47fb65d..16d100d 100644 (file)
@@ -135,7 +135,7 @@ enum ima_hooks { FILE_CHECK = 1, FILE_MMAP, BPRM_CHECK };
 int ima_match_policy(struct inode *inode, enum ima_hooks func, int mask);
 void ima_init_policy(void);
 void ima_update_policy(void);
-int ima_parse_add_rule(char *);
+ssize_t ima_parse_add_rule(char *);
 void ima_delete_rules(void);
 
 /* LSM based policy rules require audit */
index 5af7634..c5c5a72 100644 (file)
@@ -41,7 +41,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
                return;
 
        ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno);
-       audit_log_format(ab, "integrity: pid=%d uid=%u auid=%u ses=%u",
+       audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",
                         current->pid, current_cred()->uid,
                         audit_get_loginuid(current),
                         audit_get_sessionid(current));
index 952e513..9b3ade7 100644 (file)
@@ -27,7 +27,7 @@ static int init_desc(struct hash_desc *desc)
 
        desc->tfm = crypto_alloc_hash(ima_hash, 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(desc->tfm)) {
-               pr_info("failed to load %s transform: %ld\n",
+               pr_info("IMA: failed to load %s transform: %ld\n",
                        ima_hash, PTR_ERR(desc->tfm));
                rc = PTR_ERR(desc->tfm);
                return rc;
@@ -112,7 +112,7 @@ static void __init ima_pcrread(int idx, u8 *pcr)
                return;
 
        if (tpm_pcr_read(TPM_ANY_NUM, idx, pcr) != 0)
-               pr_err("Error Communicating to TPM chip\n");
+               pr_err("IMA: Error Communicating to TPM chip\n");
 }
 
 /*
index 07cb9c3..8fe736a 100644 (file)
@@ -244,32 +244,34 @@ static const struct file_operations ima_ascii_measurements_ops = {
 static ssize_t ima_write_policy(struct file *file, const char __user *buf,
                                size_t datalen, loff_t *ppos)
 {
-       char *data;
-       int rc;
+       char *data = NULL;
+       ssize_t result;
 
        if (datalen >= PAGE_SIZE)
-               return -ENOMEM;
-       if (*ppos != 0) {
-               /* No partial writes. */
-               return -EINVAL;
-       }
+               datalen = PAGE_SIZE - 1;
+
+       /* No partial writes. */
+       result = -EINVAL;
+       if (*ppos != 0)
+               goto out;
+
+       result = -ENOMEM;
        data = kmalloc(datalen + 1, GFP_KERNEL);
        if (!data)
-               return -ENOMEM;
+               goto out;
 
-       if (copy_from_user(data, buf, datalen)) {
-               kfree(data);
-               return -EFAULT;
-       }
        *(data + datalen) = '\0';
-       rc = ima_parse_add_rule(data);
-       if (rc < 0) {
-               datalen = -EINVAL;
-               valid_policy = 0;
-       }
 
+       result = -EFAULT;
+       if (copy_from_user(data, buf, datalen))
+               goto out;
+
+       result = ima_parse_add_rule(data);
+out:
+       if (result < 0)
+               valid_policy = 0;
        kfree(data);
-       return datalen;
+       return result;
 }
 
 static struct dentry *ima_dir;
index 2c744d4..2dc2d65 100644 (file)
@@ -80,17 +80,17 @@ void iint_free(struct kref *kref)
        iint->version = 0;
        iint->flags = 0UL;
        if (iint->readcount != 0) {
-               printk(KERN_INFO "%s: readcount: %ld\n", __FUNCTION__,
+               printk(KERN_INFO "%s: readcount: %ld\n", __func__,
                       iint->readcount);
                iint->readcount = 0;
        }
        if (iint->writecount != 0) {
-               printk(KERN_INFO "%s: writecount: %ld\n", __FUNCTION__,
+               printk(KERN_INFO "%s: writecount: %ld\n", __func__,
                       iint->writecount);
                iint->writecount = 0;
        }
        if (iint->opencount != 0) {
-               printk(KERN_INFO "%s: opencount: %ld\n", __FUNCTION__,
+               printk(KERN_INFO "%s: opencount: %ld\n", __func__,
                       iint->opencount);
                iint->opencount = 0;
        }
index b1bcb70..17f1f06 100644 (file)
@@ -83,7 +83,7 @@ int __init ima_init(void)
                ima_used_chip = 1;
 
        if (!ima_used_chip)
-               pr_info("No TPM chip found, activating TPM-bypass!\n");
+               pr_info("IMA: No TPM chip found, activating TPM-bypass!\n");
 
        ima_add_boot_aggregate();       /* boot aggregate must be first entry */
        ima_init_policy();
index b2c89d9..f936413 100644 (file)
@@ -195,7 +195,7 @@ static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode,
             (iint->writecount < 0)) &&
            !ima_limit_imbalance(file)) {
                printk(KERN_INFO "%s: open/free imbalance (r:%ld w:%ld o:%ld)\n",
-                      __FUNCTION__, iint->readcount, iint->writecount,
+                      __func__, iint->readcount, iint->writecount,
                       iint->opencount);
                dump_stack();
        }
index 8643a93..aef8c0a 100644 (file)
@@ -246,6 +246,9 @@ static int ima_lsm_rule_init(struct ima_measure_rule_entry *entry,
 {
        int result;
 
+       if (entry->lsm[lsm_rule].rule)
+               return -EINVAL;
+
        entry->lsm[lsm_rule].type = audit_type;
        result = security_filter_rule_init(entry->lsm[lsm_rule].type,
                                           Audit_equal, args,
@@ -253,6 +256,13 @@ static int ima_lsm_rule_init(struct ima_measure_rule_entry *entry,
        return result;
 }
 
+static void ima_log_string(struct audit_buffer *ab, char *key, char *value)
+{
+       audit_log_format(ab, "%s=", key);
+       audit_log_untrustedstring(ab, value);
+       audit_log_format(ab, " ");
+}
+
 static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
 {
        struct audit_buffer *ab;
@@ -261,28 +271,41 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
 
        ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_RULE);
 
-       entry->action = -1;
-       while ((p = strsep(&rule, " \n")) != NULL) {
+       entry->uid = -1;
+       entry->action = UNKNOWN;
+       while ((p = strsep(&rule, " \t")) != NULL) {
                substring_t args[MAX_OPT_ARGS];
                int token;
                unsigned long lnum;
 
                if (result < 0)
                        break;
-               if (!*p)
+               if ((*p == '\0') || (*p == ' ') || (*p == '\t'))
                        continue;
                token = match_token(p, policy_tokens, args);
                switch (token) {
                case Opt_measure:
-                       audit_log_format(ab, "%s ", "measure");
+                       ima_log_string(ab, "action", "measure");
+
+                       if (entry->action != UNKNOWN)
+                               result = -EINVAL;
+
                        entry->action = MEASURE;
                        break;
                case Opt_dont_measure:
-                       audit_log_format(ab, "%s ", "dont_measure");
+                       ima_log_string(ab, "action", "dont_measure");
+
+                       if (entry->action != UNKNOWN)
+                               result = -EINVAL;
+
                        entry->action = DONT_MEASURE;
                        break;
                case Opt_func:
-                       audit_log_format(ab, "func=%s ", args[0].from);
+                       ima_log_string(ab, "func", args[0].from);
+
+                       if (entry->func)
+                               result  = -EINVAL;
+
                        if (strcmp(args[0].from, "FILE_CHECK") == 0)
                                entry->func = FILE_CHECK;
                        /* PATH_CHECK is for backwards compat */
@@ -298,7 +321,11 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
                                entry->flags |= IMA_FUNC;
                        break;
                case Opt_mask:
-                       audit_log_format(ab, "mask=%s ", args[0].from);
+                       ima_log_string(ab, "mask", args[0].from);
+
+                       if (entry->mask)
+                               result = -EINVAL;
+
                        if ((strcmp(args[0].from, "MAY_EXEC")) == 0)
                                entry->mask = MAY_EXEC;
                        else if (strcmp(args[0].from, "MAY_WRITE") == 0)
@@ -313,14 +340,26 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
                                entry->flags |= IMA_MASK;
                        break;
                case Opt_fsmagic:
-                       audit_log_format(ab, "fsmagic=%s ", args[0].from);
+                       ima_log_string(ab, "fsmagic", args[0].from);
+
+                       if (entry->fsmagic) {
+                               result = -EINVAL;
+                               break;
+                       }
+
                        result = strict_strtoul(args[0].from, 16,
                                                &entry->fsmagic);
                        if (!result)
                                entry->flags |= IMA_FSMAGIC;
                        break;
                case Opt_uid:
-                       audit_log_format(ab, "uid=%s ", args[0].from);
+                       ima_log_string(ab, "uid", args[0].from);
+
+                       if (entry->uid != -1) {
+                               result = -EINVAL;
+                               break;
+                       }
+
                        result = strict_strtoul(args[0].from, 10, &lnum);
                        if (!result) {
                                entry->uid = (uid_t) lnum;
@@ -331,50 +370,51 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
                        }
                        break;
                case Opt_obj_user:
-                       audit_log_format(ab, "obj_user=%s ", args[0].from);
+                       ima_log_string(ab, "obj_user", args[0].from);
                        result = ima_lsm_rule_init(entry, args[0].from,
                                                   LSM_OBJ_USER,
                                                   AUDIT_OBJ_USER);
                        break;
                case Opt_obj_role:
-                       audit_log_format(ab, "obj_role=%s ", args[0].from);
+                       ima_log_string(ab, "obj_role", args[0].from);
                        result = ima_lsm_rule_init(entry, args[0].from,
                                                   LSM_OBJ_ROLE,
                                                   AUDIT_OBJ_ROLE);
                        break;
                case Opt_obj_type:
-                       audit_log_format(ab, "obj_type=%s ", args[0].from);
+                       ima_log_string(ab, "obj_type", args[0].from);
                        result = ima_lsm_rule_init(entry, args[0].from,
                                                   LSM_OBJ_TYPE,
                                                   AUDIT_OBJ_TYPE);
                        break;
                case Opt_subj_user:
-                       audit_log_format(ab, "subj_user=%s ", args[0].from);
+                       ima_log_string(ab, "subj_user", args[0].from);
                        result = ima_lsm_rule_init(entry, args[0].from,
                                                   LSM_SUBJ_USER,
                                                   AUDIT_SUBJ_USER);
                        break;
                case Opt_subj_role:
-                       audit_log_format(ab, "subj_role=%s ", args[0].from);
+                       ima_log_string(ab, "subj_role", args[0].from);
                        result = ima_lsm_rule_init(entry, args[0].from,
                                                   LSM_SUBJ_ROLE,
                                                   AUDIT_SUBJ_ROLE);
                        break;
                case Opt_subj_type:
-                       audit_log_format(ab, "subj_type=%s ", args[0].from);
+                       ima_log_string(ab, "subj_type", args[0].from);
                        result = ima_lsm_rule_init(entry, args[0].from,
                                                   LSM_SUBJ_TYPE,
                                                   AUDIT_SUBJ_TYPE);
                        break;
                case Opt_err:
-                       audit_log_format(ab, "UNKNOWN=%s ", p);
+                       ima_log_string(ab, "UNKNOWN", p);
+                       result = -EINVAL;
                        break;
                }
        }
-       if (entry->action == UNKNOWN)
+       if (!result && (entry->action == UNKNOWN))
                result = -EINVAL;
 
-       audit_log_format(ab, "res=%d", !result ? 0 : 1);
+       audit_log_format(ab, "res=%d", !!result);
        audit_log_end(ab);
        return result;
 }
@@ -384,13 +424,14 @@ static int ima_parse_rule(char *rule, struct ima_measure_rule_entry *entry)
  * @rule - ima measurement policy rule
  *
  * Uses a mutex to protect the policy list from multiple concurrent writers.
- * Returns 0 on success, an error code on failure.
+ * Returns the length of the rule parsed, an error code on failure
  */
-int ima_parse_add_rule(char *rule)
+ssize_t ima_parse_add_rule(char *rule)
 {
        const char *op = "update_policy";
+       char *p;
        struct ima_measure_rule_entry *entry;
-       int result = 0;
+       ssize_t result, len;
        int audit_info = 0;
 
        /* Prevent installed policy from changing */
@@ -410,18 +451,28 @@ int ima_parse_add_rule(char *rule)
 
        INIT_LIST_HEAD(&entry->list);
 
-       result = ima_parse_rule(rule, entry);
-       if (!result) {
-               mutex_lock(&ima_measure_mutex);
-               list_add_tail(&entry->list, &measure_policy_rules);
-               mutex_unlock(&ima_measure_mutex);
-       } else {
+       p = strsep(&rule, "\n");
+       len = strlen(p) + 1;
+
+       if (*p == '#') {
+               kfree(entry);
+               return len;
+       }
+
+       result = ima_parse_rule(p, entry);
+       if (result) {
                kfree(entry);
                integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
                                    NULL, op, "invalid policy", result,
                                    audit_info);
+               return result;
        }
-       return result;
+
+       mutex_lock(&ima_measure_mutex);
+       list_add_tail(&entry->list, &measure_policy_rules);
+       mutex_unlock(&ima_measure_mutex);
+
+       return len;
 }
 
 /* ima_delete_rules called to cleanup invalid policy */
index 46ba62b..8e28f04 100644 (file)
@@ -71,7 +71,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
 
        qe = kmalloc(sizeof(*qe), GFP_KERNEL);
        if (qe == NULL) {
-               pr_err("OUT OF MEMORY ERROR creating queue entry.\n");
+               pr_err("IMA: OUT OF MEMORY ERROR creating queue entry.\n");
                return -ENOMEM;
        }
        qe->entry = entry;
@@ -94,7 +94,7 @@ static int ima_pcr_extend(const u8 *hash)
 
        result = tpm_pcr_extend(TPM_ANY_NUM, CONFIG_IMA_MEASURE_PCR_IDX, hash);
        if (result != 0)
-               pr_err("Error Communicating to TPM chip\n");
+               pr_err("IMA: Error Communicating to TPM chip\n");
        return result;
 }
 
index e50d264..c70da6f 100644 (file)
@@ -355,7 +355,7 @@ EXPORT_SYMBOL(key_alloc);
  */
 int key_payload_reserve(struct key *key, size_t datalen)
 {
-       int delta = (int) datalen - key->datalen;
+       int delta = (int)datalen - key->datalen;
        int ret = 0;
 
        key_check(key);
index e9c2e7c..8f4dce1 100644 (file)
@@ -212,15 +212,15 @@ SYSCALL_DEFINE4(request_key, const char __user *, _type,
        ret = key->serial;
 
        key_put(key);
- error5:
+error5:
        key_type_put(ktype);
- error4:
+error4:
        key_ref_put(dest_ref);
- error3:
+error3:
        kfree(callout_info);
- error2:
+error2:
        kfree(description);
- error:
+error:
        return ret;
 
 } /* end sys_request_key() */
@@ -246,7 +246,7 @@ long keyctl_get_keyring_ID(key_serial_t id, int create)
 
        ret = key_ref_to_ptr(key_ref)->serial;
        key_ref_put(key_ref);
- error:
+error:
        return ret;
 
 } /* end keyctl_get_keyring_ID() */
@@ -275,7 +275,7 @@ long keyctl_join_session_keyring(const char __user *_name)
        ret = join_session_keyring(name);
        kfree(name);
 
- error:
+error:
        return ret;
 
 } /* end keyctl_join_session_keyring() */
@@ -322,9 +322,9 @@ long keyctl_update_key(key_serial_t id,
        ret = key_update(key_ref, payload, plen);
 
        key_ref_put(key_ref);
- error2:
+error2:
        kfree(payload);
- error:
+error:
        return ret;
 
 } /* end keyctl_update_key() */
@@ -356,7 +356,7 @@ long keyctl_revoke_key(key_serial_t id)
        ret = 0;
 
        key_ref_put(key_ref);
- error:
+error:
        return ret;
 
 } /* end keyctl_revoke_key() */
@@ -381,7 +381,7 @@ long keyctl_keyring_clear(key_serial_t ringid)
        ret = keyring_clear(key_ref_to_ptr(keyring_ref));
 
        key_ref_put(keyring_ref);
- error:
+error:
        return ret;
 
 } /* end keyctl_keyring_clear() */
@@ -413,9 +413,9 @@ long keyctl_keyring_link(key_serial_t id, key_serial_t ringid)
        ret = key_link(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref));
 
        key_ref_put(key_ref);
- error2:
+error2:
        key_ref_put(keyring_ref);
- error:
+error:
        return ret;
 
 } /* end keyctl_keyring_link() */
@@ -447,9 +447,9 @@ long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid)
        ret = key_unlink(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref));
 
        key_ref_put(key_ref);
- error2:
+error2:
        key_ref_put(keyring_ref);
- error:
+error:
        return ret;
 
 } /* end keyctl_keyring_unlink() */
@@ -529,9 +529,9 @@ okay:
        }
 
        kfree(tmpbuf);
- error2:
+error2:
        key_ref_put(key_ref);
- error:
+error:
        return ret;
 
 } /* end keyctl_describe_key() */
@@ -616,17 +616,17 @@ long keyctl_keyring_search(key_serial_t ringid,
 
        ret = key_ref_to_ptr(key_ref)->serial;
 
- error6:
+error6:
        key_ref_put(key_ref);
- error5:
+error5:
        key_type_put(ktype);
- error4:
+error4:
        key_ref_put(dest_ref);
- error3:
+error3:
        key_ref_put(keyring_ref);
- error2:
+error2:
        kfree(description);
- error:
+error:
        return ret;
 
 } /* end keyctl_keyring_search() */
@@ -673,7 +673,7 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
        }
 
        /* the key is probably readable - now try to read it */
- can_read_key:
+can_read_key:
        ret = key_validate(key);
        if (ret == 0) {
                ret = -EOPNOTSUPP;
@@ -686,9 +686,9 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
                }
        }
 
- error2:
+error2:
        key_put(key);
- error:
+error:
        return ret;
 
 } /* end keyctl_read_key() */
@@ -1282,26 +1282,19 @@ long keyctl_session_to_parent(void)
 
        /* the parent must have the same effective ownership and mustn't be
         * SUID/SGID */
-       if (pcred-> uid != mycred->euid ||
+       if (pcred->uid  != mycred->euid ||
            pcred->euid != mycred->euid ||
            pcred->suid != mycred->euid ||
-           pcred-> gid != mycred->egid ||
+           pcred->gid  != mycred->egid ||
            pcred->egid != mycred->egid ||
            pcred->sgid != mycred->egid)
                goto not_permitted;
 
        /* the keyrings must have the same UID */
-       if (pcred ->tgcred->session_keyring->uid != mycred->euid ||
+       if (pcred->tgcred->session_keyring->uid != mycred->euid ||
            mycred->tgcred->session_keyring->uid != mycred->euid)
                goto not_permitted;
 
-       /* the LSM must permit the replacement of the parent's keyring with the
-        * keyring from this process */
-       ret = security_key_session_to_parent(mycred, pcred,
-                                            key_ref_to_ptr(keyring_r));
-       if (ret < 0)
-               goto not_permitted;
-
        /* if there's an already pending keyring replacement, then we replace
         * that */
        oldcred = parent->replacement_session_keyring;
index dd7cd0f..2fb2bc9 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/seq_file.h>
 #include <linux/err.h>
 #include <keys/keyring-type.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include "internal.h"
 
 /*
@@ -39,7 +39,7 @@ static inline unsigned keyring_hash(const char *desc)
        unsigned bucket = 0;
 
        for (; *desc; desc++)
-               bucket += (unsigned char) *desc;
+               bucket += (unsigned char)*desc;
 
        return bucket & (KEYRING_NAME_HASH_SIZE - 1);
 }
@@ -170,12 +170,10 @@ static void keyring_describe(const struct key *keyring, struct seq_file *m)
 {
        struct keyring_list *klist;
 
-       if (keyring->description) {
+       if (keyring->description)
                seq_puts(m, keyring->description);
-       }
-       else {
+       else
                seq_puts(m, "[anon]");
-       }
 
        rcu_read_lock();
        klist = rcu_dereference(keyring->payload.subscriptions);
@@ -237,7 +235,7 @@ static long keyring_read(const struct key *keyring,
                ret = qty;
        }
 
- error:
+error:
        return ret;
 
 } /* end keyring_read() */
@@ -306,7 +304,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref,
        key_check(keyring);
 
        /* top keyring must have search permission to begin the search */
-        err = key_task_permission(keyring_ref, cred, KEY_SEARCH);
+       err = key_task_permission(keyring_ref, cred, KEY_SEARCH);
        if (err < 0) {
                key_ref = ERR_PTR(err);
                goto error;
@@ -508,7 +506,7 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref,
        rcu_read_unlock();
        return ERR_PTR(-ENOKEY);
 
- found:
+found:
        atomic_inc(&key->usage);
        rcu_read_unlock();
        return make_key_ref(key, possessed);
@@ -565,7 +563,7 @@ struct key *find_keyring_by_name(const char *name, bool skip_perm_check)
        read_unlock(&keyring_name_lock);
        keyring = ERR_PTR(-ENOKEY);
 
- error:
+error:
        return keyring;
 
 } /* end find_keyring_by_name() */
@@ -598,7 +596,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B)
        sp = 0;
 
        /* start processing a new keyring */
- descend:
+descend:
        if (test_bit(KEY_FLAG_REVOKED, &subtree->flags))
                goto not_this_keyring;
 
@@ -607,7 +605,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B)
                goto not_this_keyring;
        kix = 0;
 
- ascend:
+ascend:
        /* iterate through the remaining keys in this keyring */
        for (; kix < keylist->nkeys; kix++) {
                key = keylist->keys[kix];
@@ -633,7 +631,7 @@ static int keyring_detect_cycle(struct key *A, struct key *B)
 
        /* the keyring we're looking at was disqualified or didn't contain a
         * matching key */
- not_this_keyring:
+not_this_keyring:
        if (sp > 0) {
                /* resume the checking of a keyring higher up in the tree */
                sp--;
@@ -644,15 +642,15 @@ static int keyring_detect_cycle(struct key *A, struct key *B)
 
        ret = 0; /* no cycles detected */
 
- error:
+error:
        rcu_read_unlock();
        return ret;
 
- too_deep:
+too_deep:
        ret = -ELOOP;
        goto error;
 
- cycle_detected:
+cycle_detected:
        ret = -EDEADLK;
        goto error;
 
@@ -775,8 +773,7 @@ int __key_link(struct key *keyring, struct key *key)
                smp_wmb();
                klist->nkeys++;
                smp_wmb();
-       }
-       else {
+       } else {
                /* grow the key list */
                max = 4;
                if (klist)
index 0ed802c..2864550 100644 (file)
@@ -109,7 +109,7 @@ int key_validate(struct key *key)
                }
        }
 
- error:
+error:
        return ret;
 
 } /* end key_validate() */
index 706d63f..068b66e 100644 (file)
@@ -306,7 +306,7 @@ static void *proc_key_users_start(struct seq_file *p, loff_t *_pos)
 static void *proc_key_users_next(struct seq_file *p, void *v, loff_t *_pos)
 {
        (*_pos)++;
-       return key_user_next((struct rb_node *) v);
+       return key_user_next((struct rb_node *)v);
 }
 
 static void proc_key_users_stop(struct seq_file *p, void *v)
index 893365b..908aa71 100644 (file)
@@ -221,7 +221,7 @@ static void dump_common_audit_data(struct audit_buffer *ab,
        }
 
        switch (a->type) {
-       case LSM_AUDIT_NO_AUDIT:
+       case LSM_AUDIT_DATA_NONE:
                return;
        case LSM_AUDIT_DATA_IPC:
                audit_log_format(ab, " key=%d ", a->u.ipc_id);
index e86f297..f728728 100644 (file)
@@ -33,7 +33,7 @@ int mmap_min_addr_handler(struct ctl_table *table, int write,
 {
        int ret;
 
-       if (!capable(CAP_SYS_RAWIO))
+       if (write && !capable(CAP_SYS_RAWIO))
                return -EPERM;
 
        ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
index 687c6fd..8585019 100644 (file)
@@ -117,7 +117,7 @@ int __init security_module_enable(struct security_operations *ops)
  * If there is already a security module registered with the kernel,
  * an error will be returned.  Otherwise %0 is returned on success.
  */
-int register_security(struct security_operations *ops)
+int __init register_security(struct security_operations *ops)
 {
        if (verify(ops)) {
                printk(KERN_DEBUG "%s could not verify "
@@ -190,11 +190,6 @@ int security_real_capable_noaudit(struct task_struct *tsk, int cap)
        return ret;
 }
 
-int security_acct(struct file *file)
-{
-       return security_ops->acct(file);
-}
-
 int security_sysctl(struct ctl_table *table, int op)
 {
        return security_ops->sysctl(table, op);
@@ -306,46 +301,16 @@ int security_sb_mount(char *dev_name, struct path *path,
        return security_ops->sb_mount(dev_name, path, type, flags, data);
 }
 
-int security_sb_check_sb(struct vfsmount *mnt, struct path *path)
-{
-       return security_ops->sb_check_sb(mnt, path);
-}
-
 int security_sb_umount(struct vfsmount *mnt, int flags)
 {
        return security_ops->sb_umount(mnt, flags);
 }
 
-void security_sb_umount_close(struct vfsmount *mnt)
-{
-       security_ops->sb_umount_close(mnt);
-}
-
-void security_sb_umount_busy(struct vfsmount *mnt)
-{
-       security_ops->sb_umount_busy(mnt);
-}
-
-void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data)
-{
-       security_ops->sb_post_remount(mnt, flags, data);
-}
-
-void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint)
-{
-       security_ops->sb_post_addmount(mnt, mountpoint);
-}
-
 int security_sb_pivotroot(struct path *old_path, struct path *new_path)
 {
        return security_ops->sb_pivotroot(old_path, new_path);
 }
 
-void security_sb_post_pivotroot(struct path *old_path, struct path *new_path)
-{
-       security_ops->sb_post_pivotroot(old_path, new_path);
-}
-
 int security_sb_set_mnt_opts(struct super_block *sb,
                                struct security_mnt_opts *opts)
 {
@@ -580,13 +545,6 @@ int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
        return security_ops->inode_getattr(mnt, dentry);
 }
 
-void security_inode_delete(struct inode *inode)
-{
-       if (unlikely(IS_PRIVATE(inode)))
-               return;
-       security_ops->inode_delete(inode);
-}
-
 int security_inode_setxattr(struct dentry *dentry, const char *name,
                            const void *value, size_t size, int flags)
 {
@@ -749,11 +707,6 @@ int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp)
        return security_ops->cred_prepare(new, old, gfp);
 }
 
-void security_commit_creds(struct cred *new, const struct cred *old)
-{
-       security_ops->cred_commit(new, old);
-}
-
 void security_transfer_creds(struct cred *new, const struct cred *old)
 {
        security_ops->cred_transfer(new, old);
@@ -774,22 +727,12 @@ int security_kernel_module_request(char *kmod_name)
        return security_ops->kernel_module_request(kmod_name);
 }
 
-int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags)
-{
-       return security_ops->task_setuid(id0, id1, id2, flags);
-}
-
 int security_task_fix_setuid(struct cred *new, const struct cred *old,
                             int flags)
 {
        return security_ops->task_fix_setuid(new, old, flags);
 }
 
-int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags)
-{
-       return security_ops->task_setgid(id0, id1, id2, flags);
-}
-
 int security_task_setpgid(struct task_struct *p, pid_t pgid)
 {
        return security_ops->task_setpgid(p, pgid);
@@ -811,11 +754,6 @@ void security_task_getsecid(struct task_struct *p, u32 *secid)
 }
 EXPORT_SYMBOL(security_task_getsecid);
 
-int security_task_setgroups(struct group_info *group_info)
-{
-       return security_ops->task_setgroups(group_info);
-}
-
 int security_task_setnice(struct task_struct *p, int nice)
 {
        return security_ops->task_setnice(p, nice);
@@ -1319,13 +1257,6 @@ int security_key_getsecurity(struct key *key, char **_buffer)
        return security_ops->key_getsecurity(key, _buffer);
 }
 
-int security_key_session_to_parent(const struct cred *cred,
-                                  const struct cred *parent_cred,
-                                  struct key *key)
-{
-       return security_ops->key_session_to_parent(cred, parent_cred, key);
-}
-
 #endif /* CONFIG_KEYS */
 
 #ifdef CONFIG_AUDIT
index 989fef8..7f1a304 100644 (file)
@@ -499,8 +499,7 @@ void avc_audit(u32 ssid, u32 tsid,
                return;
        if (!a) {
                a = &stack_data;
-               memset(a, 0, sizeof(*a));
-               a->type = LSM_AUDIT_NO_AUDIT;
+               COMMON_AUDIT_DATA_INIT(a, NONE);
        }
        a->selinux_audit_data.tclass = tclass;
        a->selinux_audit_data.requested = requested;
index 5feecb4..a03fd74 100644 (file)
@@ -293,28 +293,28 @@ static void superblock_free_security(struct super_block *sb)
 
 static int sk_alloc_security(struct sock *sk, int family, gfp_t priority)
 {
-       struct sk_security_struct *ssec;
+       struct sk_security_struct *sksec;
 
-       ssec = kzalloc(sizeof(*ssec), priority);
-       if (!ssec)
+       sksec = kzalloc(sizeof(*sksec), priority);
+       if (!sksec)
                return -ENOMEM;
 
-       ssec->peer_sid = SECINITSID_UNLABELED;
-       ssec->sid = SECINITSID_UNLABELED;
-       sk->sk_security = ssec;
+       sksec->peer_sid = SECINITSID_UNLABELED;
+       sksec->sid = SECINITSID_UNLABELED;
+       sk->sk_security = sksec;
 
-       selinux_netlbl_sk_security_reset(ssec);
+       selinux_netlbl_sk_security_reset(sksec);
 
        return 0;
 }
 
 static void sk_free_security(struct sock *sk)
 {
-       struct sk_security_struct *ssec = sk->sk_security;
+       struct sk_security_struct *sksec = sk->sk_security;
 
        sk->sk_security = NULL;
-       selinux_netlbl_sk_security_free(ssec);
-       kfree(ssec);
+       selinux_netlbl_sk_security_free(sksec);
+       kfree(sksec);
 }
 
 /* The security server must be initialized before
@@ -323,7 +323,7 @@ extern int ss_initialized;
 
 /* The file system's label must be initialized prior to use. */
 
-static char *labeling_behaviors[6] = {
+static const char *labeling_behaviors[6] = {
        "uses xattr",
        "uses transition SIDs",
        "uses task SIDs",
@@ -2999,13 +2999,15 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
        return file_has_perm(cred, file, av);
 }
 
+static int default_noexec;
+
 static int file_map_prot_check(struct file *file, unsigned long prot, int shared)
 {
        const struct cred *cred = current_cred();
        int rc = 0;
 
-#ifndef CONFIG_PPC32
-       if ((prot & PROT_EXEC) && (!file || (!shared && (prot & PROT_WRITE)))) {
+       if (default_noexec &&
+           (prot & PROT_EXEC) && (!file || (!shared && (prot & PROT_WRITE)))) {
                /*
                 * We are making executable an anonymous mapping or a
                 * private file mapping that will also be writable.
@@ -3015,7 +3017,6 @@ static int file_map_prot_check(struct file *file, unsigned long prot, int shared
                if (rc)
                        goto error;
        }
-#endif
 
        if (file) {
                /* read access is always possible with a mapping */
@@ -3076,8 +3077,8 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
        if (selinux_checkreqprot)
                prot = reqprot;
 
-#ifndef CONFIG_PPC32
-       if ((prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
+       if (default_noexec &&
+           (prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
                int rc = 0;
                if (vma->vm_start >= vma->vm_mm->start_brk &&
                    vma->vm_end <= vma->vm_mm->brk) {
@@ -3099,7 +3100,6 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
                if (rc)
                        return rc;
        }
-#endif
 
        return file_map_prot_check(vma->vm_file, prot, vma->vm_flags&VM_SHARED);
 }
@@ -4002,7 +4002,7 @@ static int selinux_socket_unix_stream_connect(struct socket *sock,
                                              struct socket *other,
                                              struct sock *newsk)
 {
-       struct sk_security_struct *ssec;
+       struct sk_security_struct *sksec;
        struct inode_security_struct *isec;
        struct inode_security_struct *other_isec;
        struct common_audit_data ad;
@@ -4021,13 +4021,13 @@ static int selinux_socket_unix_stream_connect(struct socket *sock,
                return err;
 
        /* connecting socket */
-       ssec = sock->sk->sk_security;
-       ssec->peer_sid = other_isec->sid;
+       sksec = sock->sk->sk_security;
+       sksec->peer_sid = other_isec->sid;
 
        /* server child socket */
-       ssec = newsk->sk_security;
-       ssec->peer_sid = isec->sid;
-       err = security_sid_mls_copy(other_isec->sid, ssec->peer_sid, &ssec->sid);
+       sksec = newsk->sk_security;
+       sksec->peer_sid = isec->sid;
+       err = security_sid_mls_copy(other_isec->sid, sksec->peer_sid, &sksec->sid);
 
        return err;
 }
@@ -4190,7 +4190,7 @@ static int selinux_socket_getpeersec_stream(struct socket *sock, char __user *op
        int err = 0;
        char *scontext;
        u32 scontext_len;
-       struct sk_security_struct *ssec;
+       struct sk_security_struct *sksec;
        struct inode_security_struct *isec;
        u32 peer_sid = SECSID_NULL;
 
@@ -4198,8 +4198,8 @@ static int selinux_socket_getpeersec_stream(struct socket *sock, char __user *op
 
        if (isec->sclass == SECCLASS_UNIX_STREAM_SOCKET ||
            isec->sclass == SECCLASS_TCP_SOCKET) {
-               ssec = sock->sk->sk_security;
-               peer_sid = ssec->peer_sid;
+               sksec = sock->sk->sk_security;
+               peer_sid = sksec->peer_sid;
        }
        if (peer_sid == SECSID_NULL) {
                err = -ENOPROTOOPT;
@@ -4266,14 +4266,14 @@ static void selinux_sk_free_security(struct sock *sk)
 
 static void selinux_sk_clone_security(const struct sock *sk, struct sock *newsk)
 {
-       struct sk_security_struct *ssec = sk->sk_security;
-       struct sk_security_struct *newssec = newsk->sk_security;
+       struct sk_security_struct *sksec = sk->sk_security;
+       struct sk_security_struct *newsksec = newsk->sk_security;
 
-       newssec->sid = ssec->sid;
-       newssec->peer_sid = ssec->peer_sid;
-       newssec->sclass = ssec->sclass;
+       newsksec->sid = sksec->sid;
+       newsksec->peer_sid = sksec->peer_sid;
+       newsksec->sclass = sksec->sclass;
 
-       selinux_netlbl_sk_security_reset(newssec);
+       selinux_netlbl_sk_security_reset(newsksec);
 }
 
 static void selinux_sk_getsecid(struct sock *sk, u32 *secid)
@@ -5662,6 +5662,8 @@ static __init int selinux_init(void)
        /* Set the security state for the initial task. */
        cred_init_security();
 
+       default_noexec = !(VM_DATA_DEFAULT_FLAGS & VM_EXEC);
+
        sel_inode_cache = kmem_cache_create("selinux_inode_security",
                                            sizeof(struct inode_security_struct),
                                            0, SLAB_PANIC, NULL);
index d4fac82..a59b64e 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is automatically generated.  Do not edit. */
-static char *initial_sid_to_string[] =
+static const char *initial_sid_to_string[] =
 {
     "null",
     "kernel",
index 8d73842..cf2f628 100644 (file)
@@ -42,8 +42,8 @@ void selinux_netlbl_cache_invalidate(void);
 
 void selinux_netlbl_err(struct sk_buff *skb, int error, int gateway);
 
-void selinux_netlbl_sk_security_free(struct sk_security_struct *ssec);
-void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec);
+void selinux_netlbl_sk_security_free(struct sk_security_struct *sksec);
+void selinux_netlbl_sk_security_reset(struct sk_security_struct *sksec);
 
 int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
                                 u16 family,
@@ -79,13 +79,13 @@ static inline void selinux_netlbl_err(struct sk_buff *skb,
 }
 
 static inline void selinux_netlbl_sk_security_free(
-                                              struct sk_security_struct *ssec)
+                                              struct sk_security_struct *sksec)
 {
        return;
 }
 
 static inline void selinux_netlbl_sk_security_reset(
-                                              struct sk_security_struct *ssec)
+                                              struct sk_security_struct *sksec)
 {
        return;
 }
index 628da72..1c2fc46 100644 (file)
@@ -132,21 +132,21 @@ void selinux_netlbl_err(struct sk_buff *skb, int error, int gateway)
 
 /**
  * selinux_netlbl_sk_security_free - Free the NetLabel fields
- * @sssec: the sk_security_struct
+ * @sksec: the sk_security_struct
  *
  * Description:
  * Free all of the memory in the NetLabel fields of a sk_security_struct.
  *
  */
-void selinux_netlbl_sk_security_free(struct sk_security_struct *ssec)
+void selinux_netlbl_sk_security_free(struct sk_security_struct *sksec)
 {
-       if (ssec->nlbl_secattr != NULL)
-               netlbl_secattr_free(ssec->nlbl_secattr);
+       if (sksec->nlbl_secattr != NULL)
+               netlbl_secattr_free(sksec->nlbl_secattr);
 }
 
 /**
  * selinux_netlbl_sk_security_reset - Reset the NetLabel fields
- * @ssec: the sk_security_struct
+ * @sksec: the sk_security_struct
  * @family: the socket family
  *
  * Description:
@@ -154,9 +154,9 @@ void selinux_netlbl_sk_security_free(struct sk_security_struct *ssec)
  * The caller is responsibile for all the NetLabel sk_security_struct locking.
  *
  */
-void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec)
+void selinux_netlbl_sk_security_reset(struct sk_security_struct *sksec)
 {
-       ssec->nlbl_state = NLBL_UNSET;
+       sksec->nlbl_state = NLBL_UNSET;
 }
 
 /**
index 0e147b6..36ac257 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/slab.h>
 #include <linux/stddef.h>
 #include <linux/kernel.h>
-#include <linux/list.h>
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/selinux_netlink.h>
index dd7cc6d..75ec0c6 100644 (file)
@@ -11,7 +11,6 @@
  */
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 #include <linux/if.h>
index cd191bb..0293843 100644 (file)
@@ -503,11 +503,11 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size)
                return length;
 
        length = -ENOMEM;
-       scon = kzalloc(size+1, GFP_KERNEL);
+       scon = kzalloc(size + 1, GFP_KERNEL);
        if (!scon)
                return length;
 
-       tcon = kzalloc(size+1, GFP_KERNEL);
+       tcon = kzalloc(size + 1, GFP_KERNEL);
        if (!tcon)
                goto out;
 
@@ -515,10 +515,10 @@ static ssize_t sel_write_access(struct file *file, char *buf, size_t size)
        if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
                goto out2;
 
-       length = security_context_to_sid(scon, strlen(scon)+1, &ssid);
+       length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
        if (length < 0)
                goto out2;
-       length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid);
+       length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
        if (length < 0)
                goto out2;
 
@@ -550,11 +550,11 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
                return length;
 
        length = -ENOMEM;
-       scon = kzalloc(size+1, GFP_KERNEL);
+       scon = kzalloc(size + 1, GFP_KERNEL);
        if (!scon)
                return length;
 
-       tcon = kzalloc(size+1, GFP_KERNEL);
+       tcon = kzalloc(size + 1, GFP_KERNEL);
        if (!tcon)
                goto out;
 
@@ -562,10 +562,10 @@ static ssize_t sel_write_create(struct file *file, char *buf, size_t size)
        if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
                goto out2;
 
-       length = security_context_to_sid(scon, strlen(scon)+1, &ssid);
+       length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
        if (length < 0)
                goto out2;
-       length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid);
+       length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
        if (length < 0)
                goto out2;
 
@@ -609,11 +609,11 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size)
                return length;
 
        length = -ENOMEM;
-       scon = kzalloc(size+1, GFP_KERNEL);
+       scon = kzalloc(size + 1, GFP_KERNEL);
        if (!scon)
                return length;
 
-       tcon = kzalloc(size+1, GFP_KERNEL);
+       tcon = kzalloc(size + 1, GFP_KERNEL);
        if (!tcon)
                goto out;
 
@@ -621,10 +621,10 @@ static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size)
        if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
                goto out2;
 
-       length = security_context_to_sid(scon, strlen(scon)+1, &ssid);
+       length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
        if (length < 0)
                goto out2;
-       length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid);
+       length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
        if (length < 0)
                goto out2;
 
@@ -666,11 +666,11 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
                return length;
 
        length = -ENOMEM;
-       con = kzalloc(size+1, GFP_KERNEL);
+       con = kzalloc(size + 1, GFP_KERNEL);
        if (!con)
                return length;
 
-       user = kzalloc(size+1, GFP_KERNEL);
+       user = kzalloc(size + 1, GFP_KERNEL);
        if (!user)
                goto out;
 
@@ -678,7 +678,7 @@ static ssize_t sel_write_user(struct file *file, char *buf, size_t size)
        if (sscanf(buf, "%s %s", con, user) != 2)
                goto out2;
 
-       length = security_context_to_sid(con, strlen(con)+1, &sid);
+       length = security_context_to_sid(con, strlen(con) + 1, &sid);
        if (length < 0)
                goto out2;
 
@@ -727,11 +727,11 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
                return length;
 
        length = -ENOMEM;
-       scon = kzalloc(size+1, GFP_KERNEL);
+       scon = kzalloc(size + 1, GFP_KERNEL);
        if (!scon)
                return length;
 
-       tcon = kzalloc(size+1, GFP_KERNEL);
+       tcon = kzalloc(size + 1, GFP_KERNEL);
        if (!tcon)
                goto out;
 
@@ -739,10 +739,10 @@ static ssize_t sel_write_member(struct file *file, char *buf, size_t size)
        if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
                goto out2;
 
-       length = security_context_to_sid(scon, strlen(scon)+1, &ssid);
+       length = security_context_to_sid(scon, strlen(scon) + 1, &ssid);
        if (length < 0)
                goto out2;
-       length = security_context_to_sid(tcon, strlen(tcon)+1, &tsid);
+       length = security_context_to_sid(tcon, strlen(tcon) + 1, &tsid);
        if (length < 0)
                goto out2;
 
@@ -1401,7 +1401,7 @@ static int sel_make_perm_files(char *objclass, int classvalue,
                }
                inode->i_fop = &sel_perm_ops;
                /* i+1 since perm values are 1-indexed */
-               inode->i_ino = sel_perm_to_ino(classvalue, i+1);
+               inode->i_ino = sel_perm_to_ino(classvalue, i + 1);
                d_add(dentry, inode);
        }
 
@@ -1489,7 +1489,7 @@ static int sel_make_classes(void)
                goto out;
 
        /* +2 since classes are 1-indexed */
-       last_class_ino = sel_class_to_ino(nclasses+2);
+       last_class_ino = sel_class_to_ino(nclasses + 2);
 
        for (i = 0; i < nclasses; i++) {
                struct dentry *class_name_dir;
@@ -1506,7 +1506,7 @@ static int sel_make_classes(void)
                        goto out1;
 
                /* i+1 since class values are 1-indexed */
-               rc = sel_make_class_dir_entries(classes[i], i+1,
+               rc = sel_make_class_dir_entries(classes[i], i + 1,
                                class_name_dir);
                if (rc)
                        goto out1;
index 372b773..b4eff7a 100644 (file)
@@ -255,7 +255,7 @@ int mls_context_to_sid(struct policydb *pol,
 
        if (!pol->mls_enabled) {
                if (def_sid != SECSID_NULL && oldc)
-                       *scontext += strlen(*scontext)+1;
+                       *scontext += strlen(*scontext) + 1;
                return 0;
        }
 
index 23c6e53..4f584fb 100644 (file)
@@ -40,7 +40,7 @@
 #define _DEBUG_HASHES
 
 #ifdef DEBUG_HASHES
-static char *symtab_name[SYM_NUM] = {
+static const char *symtab_name[SYM_NUM] = {
        "common prefixes",
        "classes",
        "roles",
@@ -156,7 +156,7 @@ static int roles_init(struct policydb *p)
                rc = -EINVAL;
                goto out_free_role;
        }
-       key = kmalloc(strlen(OBJECT_R)+1, GFP_KERNEL);
+       key = kmalloc(strlen(OBJECT_R) + 1, GFP_KERNEL);
        if (!key) {
                rc = -ENOMEM;
                goto out_free_role;
@@ -2195,7 +2195,7 @@ int policydb_read(struct policydb *p, void *fp)
                rangetr_hash_eval(p->range_tr);
        }
 
-       p->type_attr_map = kmalloc(p->p_types.nprim*sizeof(struct ebitmap), GFP_KERNEL);
+       p->type_attr_map = kmalloc(p->p_types.nprim * sizeof(struct ebitmap), GFP_KERNEL);
        if (!p->type_attr_map)
                goto bad;
 
index cf27b3e..1de60ce 100644 (file)
@@ -274,15 +274,15 @@ static int constraint_expr_eval(struct context *scontext,
                case CEXPR_AND:
                        BUG_ON(sp < 1);
                        sp--;
-                       s[sp] &= s[sp+1];
+                       s[sp] &= s[sp + 1];
                        break;
                case CEXPR_OR:
                        BUG_ON(sp < 1);
                        sp--;
-                       s[sp] |= s[sp+1];
+                       s[sp] |= s[sp + 1];
                        break;
                case CEXPR_ATTR:
-                       if (sp == (CEXPR_MAXDEPTH-1))
+                       if (sp == (CEXPR_MAXDEPTH - 1))
                                return 0;
                        switch (e->attr) {
                        case CEXPR_USER:
@@ -1216,7 +1216,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len,
        *sid = SECSID_NULL;
 
        /* Copy the string so that we can modify the copy as we parse it. */
-       scontext2 = kmalloc(scontext_len+1, gfp_flags);
+       scontext2 = kmalloc(scontext_len + 1, gfp_flags);
        if (!scontext2)
                return -ENOMEM;
        memcpy(scontext2, scontext, scontext_len);
@@ -1760,22 +1760,28 @@ int security_load_policy(void *data, size_t len)
 
        if (!ss_initialized) {
                avtab_cache_init();
-               if (policydb_read(&policydb, fp)) {
+               rc = policydb_read(&policydb, fp);
+               if (rc) {
                        avtab_cache_destroy();
-                       return -EINVAL;
+                       return rc;
                }
-               if (selinux_set_mapping(&policydb, secclass_map,
-                                       &current_mapping,
-                                       &current_mapping_size)) {
+
+               rc = selinux_set_mapping(&policydb, secclass_map,
+                                        &current_mapping,
+                                        &current_mapping_size);
+               if (rc) {
                        policydb_destroy(&policydb);
                        avtab_cache_destroy();
-                       return -EINVAL;
+                       return rc;
                }
-               if (policydb_load_isids(&policydb, &sidtab)) {
+
+               rc = policydb_load_isids(&policydb, &sidtab);
+               if (rc) {
                        policydb_destroy(&policydb);
                        avtab_cache_destroy();
-                       return -EINVAL;
+                       return rc;
                }
+
                security_load_policycaps();
                ss_initialized = 1;
                seqno = ++latest_granting;
@@ -1791,8 +1797,9 @@ int security_load_policy(void *data, size_t len)
        sidtab_hash_eval(&sidtab, "sids");
 #endif
 
-       if (policydb_read(&newpolicydb, fp))
-               return -EINVAL;
+       rc = policydb_read(&newpolicydb, fp);
+       if (rc)
+               return rc;
 
        /* If switching between different policy types, log MLS status */
        if (policydb.mls_enabled && !newpolicydb.mls_enabled)
@@ -1807,8 +1814,8 @@ int security_load_policy(void *data, size_t len)
                return rc;
        }
 
-       if (selinux_set_mapping(&newpolicydb, secclass_map,
-                               &map, &map_size))
+       rc = selinux_set_mapping(&newpolicydb, secclass_map, &map, &map_size);
+       if (rc)
                goto err;
 
        rc = security_preserve_bools(&newpolicydb);
@@ -1819,10 +1826,10 @@ int security_load_policy(void *data, size_t len)
 
        /* Clone the SID table. */
        sidtab_shutdown(&sidtab);
-       if (sidtab_map(&sidtab, clone_sid, &newsidtab)) {
-               rc = -ENOMEM;
+
+       rc = sidtab_map(&sidtab, clone_sid, &newsidtab);
+       if (rc)
                goto err;
-       }
 
        /*
         * Convert the internal representations of contexts
@@ -2101,9 +2108,9 @@ int security_get_user_sids(u32 fromsid,
 
        ebitmap_for_each_positive_bit(&user->roles, rnode, i) {
                role = policydb.role_val_to_struct[i];
-               usercon.role = i+1;
+               usercon.role = i + 1;
                ebitmap_for_each_positive_bit(&role->types, tnode, j) {
-                       usercon.type = j+1;
+                       usercon.type = j + 1;
 
                        if (mls_setup_user_range(fromcon, user, &usercon))
                                continue;
index fdfeaa2..0f2fc48 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/pagemap.h>
 #include <linux/mount.h>
 #include <linux/stat.h>
-#include <linux/ext2_fs.h>
 #include <linux/kd.h>
 #include <asm/ioctls.h>
 #include <linux/ip.h>
@@ -1119,15 +1118,6 @@ static int smack_cred_prepare(struct cred *new, const struct cred *old,
 }
 
 /**
- * smack_cred_commit - commit new credentials
- * @new: the new credentials
- * @old: the original credentials
- */
-static void smack_cred_commit(struct cred *new, const struct cred *old)
-{
-}
-
-/**
  * smack_cred_transfer - Transfer the old credentials to the new credentials
  * @new: the new credentials
  * @old: the original credentials
@@ -3121,7 +3111,6 @@ struct security_operations smack_ops = {
        .cred_alloc_blank =             smack_cred_alloc_blank,
        .cred_free =                    smack_cred_free,
        .cred_prepare =                 smack_cred_prepare,
-       .cred_commit =                  smack_cred_commit,
        .cred_transfer =                smack_cred_transfer,
        .kernel_act_as =                smack_kernel_act_as,
        .kernel_create_files_as =       smack_kernel_create_files_as,
index 975c45d..3c86bbc 100644 (file)
@@ -884,7 +884,7 @@ static struct tomoyo_profile *tomoyo_find_or_assign_new_profile(const unsigned
        ptr = tomoyo_profile_ptr[profile];
        if (ptr)
                goto ok;
-       ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
+       ptr = kmalloc(sizeof(*ptr), GFP_NOFS);
        if (!tomoyo_memory_ok(ptr)) {
                kfree(ptr);
                ptr = NULL;
@@ -1089,7 +1089,7 @@ static int tomoyo_update_manager_entry(const char *manager,
        if (!saved_manager)
                return -ENOMEM;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_policy_manager_list, list) {
                if (ptr->manager != saved_manager)
@@ -1369,7 +1369,6 @@ static bool tomoyo_print_path_acl(struct tomoyo_io_buffer *head,
 {
        int pos;
        u8 bit;
-       const char *atmark = "";
        const char *filename;
        const u32 perm = ptr->perm | (((u32) ptr->perm_high) << 16);
 
@@ -1384,8 +1383,7 @@ static bool tomoyo_print_path_acl(struct tomoyo_io_buffer *head,
                        continue;
                msg = tomoyo_path2keyword(bit);
                pos = head->read_avail;
-               if (!tomoyo_io_printf(head, "allow_%s %s%s\n", msg,
-                                     atmark, filename))
+               if (!tomoyo_io_printf(head, "allow_%s %s\n", msg, filename))
                        goto out;
        }
        head->read_bit = 0;
@@ -1408,8 +1406,6 @@ static bool tomoyo_print_path2_acl(struct tomoyo_io_buffer *head,
                                   struct tomoyo_path2_acl *ptr)
 {
        int pos;
-       const char *atmark1 = "";
-       const char *atmark2 = "";
        const char *filename1;
        const char *filename2;
        const u8 perm = ptr->perm;
@@ -1423,8 +1419,8 @@ static bool tomoyo_print_path2_acl(struct tomoyo_io_buffer *head,
                        continue;
                msg = tomoyo_path22keyword(bit);
                pos = head->read_avail;
-               if (!tomoyo_io_printf(head, "allow_%s %s%s %s%s\n", msg,
-                                     atmark1, filename1, atmark2, filename2))
+               if (!tomoyo_io_printf(head, "allow_%s %s %s\n", msg,
+                                     filename1, filename2))
                        goto out;
        }
        head->read_bit = 0;
@@ -1886,7 +1882,7 @@ static int tomoyo_read_self_domain(struct tomoyo_io_buffer *head)
  */
 static int tomoyo_open_control(const u8 type, struct file *file)
 {
-       struct tomoyo_io_buffer *head = kzalloc(sizeof(*head), GFP_KERNEL);
+       struct tomoyo_io_buffer *head = kzalloc(sizeof(*head), GFP_NOFS);
 
        if (!head)
                return -ENOMEM;
@@ -1947,7 +1943,7 @@ static int tomoyo_open_control(const u8 type, struct file *file)
        } else {
                if (!head->readbuf_size)
                        head->readbuf_size = 4096 * 2;
-               head->read_buf = kzalloc(head->readbuf_size, GFP_KERNEL);
+               head->read_buf = kzalloc(head->readbuf_size, GFP_NOFS);
                if (!head->read_buf) {
                        kfree(head);
                        return -ENOMEM;
@@ -1961,7 +1957,7 @@ static int tomoyo_open_control(const u8 type, struct file *file)
                head->write = NULL;
        } else if (head->write) {
                head->writebuf_size = 4096 * 2;
-               head->write_buf = kzalloc(head->writebuf_size, GFP_KERNEL);
+               head->write_buf = kzalloc(head->writebuf_size, GFP_NOFS);
                if (!head->write_buf) {
                        kfree(head->read_buf);
                        kfree(head);
index acb8c39..e1edec4 100644 (file)
@@ -153,7 +153,7 @@ static int tomoyo_update_domain_initializer_entry(const char *domainname,
        if (!saved_program)
                goto out;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_domain_initializer_list, list) {
                if (ptr->is_not != is_not ||
@@ -373,7 +373,7 @@ static int tomoyo_update_domain_keeper_entry(const char *domainname,
        if (!saved_domainname)
                goto out;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_domain_keeper_list, list) {
                if (ptr->is_not != is_not ||
@@ -565,7 +565,7 @@ static int tomoyo_update_alias_entry(const char *original_name,
        if (!saved_original_name || !saved_aliased_name)
                goto out;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_alias_list, list) {
                if (ptr->original_name != saved_original_name ||
@@ -665,7 +665,7 @@ struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
        saved_domainname = tomoyo_get_name(domainname);
        if (!saved_domainname)
                return NULL;
-       entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+       entry = kzalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
                if (domain->is_deleted ||
@@ -705,7 +705,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
         * This function assumes that the size of buffer returned by
         * tomoyo_realpath() = TOMOYO_MAX_PATHNAME_LEN.
         */
-       struct tomoyo_page_buffer *tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
+       struct tomoyo_page_buffer *tmp = kzalloc(sizeof(*tmp), GFP_NOFS);
        struct tomoyo_domain_info *old_domain = tomoyo_domain();
        struct tomoyo_domain_info *domain = NULL;
        const char *old_domain_name = old_domain->domainname->name;
index 6f3fe76..0687ada 100644 (file)
@@ -100,7 +100,7 @@ static struct tomoyo_path_info *tomoyo_get_path(struct path *path)
 {
        int error;
        struct tomoyo_path_info_with_data *buf = kzalloc(sizeof(*buf),
-                                                        GFP_KERNEL);
+                                                        GFP_NOFS);
 
        if (!buf)
                return NULL;
@@ -175,7 +175,7 @@ static int tomoyo_update_globally_readable_entry(const char *filename,
        if (!saved_filename)
                return -ENOMEM;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_globally_readable_list, list) {
                if (ptr->filename != saved_filename)
@@ -322,7 +322,7 @@ static int tomoyo_update_file_pattern_entry(const char *pattern,
        if (!saved_pattern->is_patterned)
                goto out;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_pattern_list, list) {
                if (saved_pattern != ptr->pattern)
@@ -475,7 +475,7 @@ static int tomoyo_update_no_rewrite_entry(const char *pattern,
        if (!saved_pattern)
                return error;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &tomoyo_no_rewrite_list, list) {
                if (ptr->pattern != saved_pattern)
@@ -821,7 +821,7 @@ static int tomoyo_update_path_acl(const u8 type, const char *filename,
        if (!saved_filename)
                return -ENOMEM;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
                struct tomoyo_path_acl *acl =
@@ -907,7 +907,7 @@ static int tomoyo_update_path2_acl(const u8 type, const char *filename1,
        if (!saved_filename1 || !saved_filename2)
                goto out;
        if (!is_delete)
-               entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+               entry = kmalloc(sizeof(*entry), GFP_NOFS);
        mutex_lock(&tomoyo_policy_lock);
        list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
                struct tomoyo_path2_acl *acl =
index c225c65..6a51e0a 100644 (file)
@@ -139,7 +139,7 @@ int tomoyo_realpath_from_path2(struct path *path, char *newname,
  */
 char *tomoyo_realpath_from_path(struct path *path)
 {
-       char *buf = kzalloc(sizeof(struct tomoyo_page_buffer), GFP_KERNEL);
+       char *buf = kzalloc(sizeof(struct tomoyo_page_buffer), GFP_NOFS);
 
        BUILD_BUG_ON(sizeof(struct tomoyo_page_buffer)
                     <= TOMOYO_MAX_PATHNAME_LEN - 1);
@@ -270,7 +270,7 @@ const struct tomoyo_path_info *tomoyo_get_name(const char *name)
                atomic_inc(&ptr->users);
                goto out;
        }
-       ptr = kzalloc(sizeof(*ptr) + len, GFP_KERNEL);
+       ptr = kzalloc(sizeof(*ptr) + len, GFP_NOFS);
        allocated_len = ptr ? ksize(ptr) : 0;
        if (!ptr || (tomoyo_quota_for_policy &&
                     atomic_read(&tomoyo_policy_memory_size) + allocated_len