aboutsummaryrefslogtreecommitdiffstats
path: root/security/tomoyo/tomoyo.c
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2010-05-16 21:09:15 -0400
committerJames Morris <jmorris@namei.org>2010-08-02 01:33:37 -0400
commita1f9bb6a375a8dbf7797ffbd6739c46b338a77f7 (patch)
tree44df8f05e6ad6bd7cf9ce398c99efbd7cff24c20 /security/tomoyo/tomoyo.c
parentcb0abe6a5b58499bd4bc1403f4987af9ead0642c (diff)
TOMOYO: Split file access control functions by type of parameters.
Check numeric parameters for operations that deal them (e.g. chmod/chown/ioctl). Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/tomoyo.c')
-rw-r--r--security/tomoyo/tomoyo.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index 4120f5a0e1bc..bbe00429b3f5 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -112,7 +112,8 @@ static int tomoyo_path_mkdir(struct path *parent, struct dentry *dentry,
112 int mode) 112 int mode)
113{ 113{
114 struct path path = { parent->mnt, dentry }; 114 struct path path = { parent->mnt, dentry };
115 return tomoyo_path_perm(TOMOYO_TYPE_MKDIR, &path); 115 return tomoyo_path_number_perm(TOMOYO_TYPE_MKDIR, &path,
116 mode & S_IALLUGO);
116} 117}
117 118
118static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry) 119static int tomoyo_path_rmdir(struct path *parent, struct dentry *dentry)
@@ -133,6 +134,7 @@ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
133{ 134{
134 struct path path = { parent->mnt, dentry }; 135 struct path path = { parent->mnt, dentry };
135 int type = TOMOYO_TYPE_CREATE; 136 int type = TOMOYO_TYPE_CREATE;
137 const unsigned int perm = mode & S_IALLUGO;
136 138
137 switch (mode & S_IFMT) { 139 switch (mode & S_IFMT) {
138 case S_IFCHR: 140 case S_IFCHR:
@@ -141,6 +143,12 @@ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
141 case S_IFBLK: 143 case S_IFBLK:
142 type = TOMOYO_TYPE_MKBLOCK; 144 type = TOMOYO_TYPE_MKBLOCK;
143 break; 145 break;
146 default:
147 goto no_dev;
148 }
149 return tomoyo_path_number3_perm(type, &path, perm, dev);
150 no_dev:
151 switch (mode & S_IFMT) {
144 case S_IFIFO: 152 case S_IFIFO:
145 type = TOMOYO_TYPE_MKFIFO; 153 type = TOMOYO_TYPE_MKFIFO;
146 break; 154 break;
@@ -148,7 +156,7 @@ static int tomoyo_path_mknod(struct path *parent, struct dentry *dentry,
148 type = TOMOYO_TYPE_MKSOCK; 156 type = TOMOYO_TYPE_MKSOCK;
149 break; 157 break;
150 } 158 }
151 return tomoyo_path_perm(type, &path); 159 return tomoyo_path_number_perm(type, &path, perm);
152} 160}
153 161
154static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir, 162static int tomoyo_path_link(struct dentry *old_dentry, struct path *new_dir,
@@ -189,23 +197,24 @@ static int tomoyo_dentry_open(struct file *f, const struct cred *cred)
189static int tomoyo_file_ioctl(struct file *file, unsigned int cmd, 197static int tomoyo_file_ioctl(struct file *file, unsigned int cmd,
190 unsigned long arg) 198 unsigned long arg)
191{ 199{
192 return tomoyo_path_perm(TOMOYO_TYPE_IOCTL, &file->f_path); 200 return tomoyo_path_number_perm(TOMOYO_TYPE_IOCTL, &file->f_path, cmd);
193} 201}
194 202
195static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt, 203static int tomoyo_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
196 mode_t mode) 204 mode_t mode)
197{ 205{
198 struct path path = { mnt, dentry }; 206 struct path path = { mnt, dentry };
199 return tomoyo_path_perm(TOMOYO_TYPE_CHMOD, &path); 207 return tomoyo_path_number_perm(TOMOYO_TYPE_CHMOD, &path,
208 mode & S_IALLUGO);
200} 209}
201 210
202static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid) 211static int tomoyo_path_chown(struct path *path, uid_t uid, gid_t gid)
203{ 212{
204 int error = 0; 213 int error = 0;
205 if (uid != (uid_t) -1) 214 if (uid != (uid_t) -1)
206 error = tomoyo_path_perm(TOMOYO_TYPE_CHOWN, path); 215 error = tomoyo_path_number_perm(TOMOYO_TYPE_CHOWN, path, uid);
207 if (!error && gid != (gid_t) -1) 216 if (!error && gid != (gid_t) -1)
208 error = tomoyo_path_perm(TOMOYO_TYPE_CHGRP, path); 217 error = tomoyo_path_number_perm(TOMOYO_TYPE_CHGRP, path, gid);
209 return error; 218 return error;
210} 219}
211 220