diff options
-rw-r--r-- | fs/jfs/jfs_xattr.h | 10 | ||||
-rw-r--r-- | fs/jfs/namei.c | 22 | ||||
-rw-r--r-- | fs/jfs/xattr.c | 36 |
3 files changed, 68 insertions, 0 deletions
diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h index 116a73ce3076..25e9990bccd1 100644 --- a/fs/jfs/jfs_xattr.h +++ b/fs/jfs/jfs_xattr.h | |||
@@ -61,4 +61,14 @@ extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t); | |||
61 | extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); | 61 | extern ssize_t jfs_listxattr(struct dentry *, char *, size_t); |
62 | extern int jfs_removexattr(struct dentry *, const char *); | 62 | extern int jfs_removexattr(struct dentry *, const char *); |
63 | 63 | ||
64 | #ifdef CONFIG_JFS_SECURITY | ||
65 | extern int jfs_init_security(tid_t, struct inode *, struct inode *); | ||
66 | #else | ||
67 | static inline int jfs_init_security(tid_t tid, struct inode *inode, | ||
68 | struct inode *dir) | ||
69 | { | ||
70 | return 0; | ||
71 | } | ||
72 | #endif | ||
73 | |||
64 | #endif /* H_JFS_XATTR */ | 74 | #endif /* H_JFS_XATTR */ |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index f23f9c2aa525..1abe7343f920 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -111,6 +111,12 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, | |||
111 | if (rc) | 111 | if (rc) |
112 | goto out3; | 112 | goto out3; |
113 | 113 | ||
114 | rc = jfs_init_security(tid, ip, dip); | ||
115 | if (rc) { | ||
116 | txAbort(tid, 0); | ||
117 | goto out3; | ||
118 | } | ||
119 | |||
114 | if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { | 120 | if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { |
115 | jfs_err("jfs_create: dtSearch returned %d", rc); | 121 | jfs_err("jfs_create: dtSearch returned %d", rc); |
116 | txAbort(tid, 0); | 122 | txAbort(tid, 0); |
@@ -239,6 +245,12 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) | |||
239 | if (rc) | 245 | if (rc) |
240 | goto out3; | 246 | goto out3; |
241 | 247 | ||
248 | rc = jfs_init_security(tid, ip, dip); | ||
249 | if (rc) { | ||
250 | txAbort(tid, 0); | ||
251 | goto out3; | ||
252 | } | ||
253 | |||
242 | if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { | 254 | if ((rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))) { |
243 | jfs_err("jfs_mkdir: dtSearch returned %d", rc); | 255 | jfs_err("jfs_mkdir: dtSearch returned %d", rc); |
244 | txAbort(tid, 0); | 256 | txAbort(tid, 0); |
@@ -906,6 +918,10 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, | |||
906 | down(&JFS_IP(dip)->commit_sem); | 918 | down(&JFS_IP(dip)->commit_sem); |
907 | down(&JFS_IP(ip)->commit_sem); | 919 | down(&JFS_IP(ip)->commit_sem); |
908 | 920 | ||
921 | rc = jfs_init_security(tid, ip, dip); | ||
922 | if (rc) | ||
923 | goto out3; | ||
924 | |||
909 | tblk = tid_to_tblock(tid); | 925 | tblk = tid_to_tblock(tid); |
910 | tblk->xflag |= COMMIT_CREATE; | 926 | tblk->xflag |= COMMIT_CREATE; |
911 | tblk->ino = ip->i_ino; | 927 | tblk->ino = ip->i_ino; |
@@ -1349,6 +1365,12 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, | |||
1349 | if (rc) | 1365 | if (rc) |
1350 | goto out3; | 1366 | goto out3; |
1351 | 1367 | ||
1368 | rc = jfs_init_security(tid, ip, dir); | ||
1369 | if (rc) { | ||
1370 | txAbort(tid, 0); | ||
1371 | goto out3; | ||
1372 | } | ||
1373 | |||
1352 | if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { | 1374 | if ((rc = dtSearch(dir, &dname, &ino, &btstack, JFS_CREATE))) { |
1353 | txAbort(tid, 0); | 1375 | txAbort(tid, 0); |
1354 | goto out3; | 1376 | goto out3; |
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index 35674b2a0e6c..23aa5066b5a4 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/xattr.h> | 21 | #include <linux/xattr.h> |
22 | #include <linux/posix_acl_xattr.h> | 22 | #include <linux/posix_acl_xattr.h> |
23 | #include <linux/quotaops.h> | 23 | #include <linux/quotaops.h> |
24 | #include <linux/security.h> | ||
24 | #include "jfs_incore.h" | 25 | #include "jfs_incore.h" |
25 | #include "jfs_superblock.h" | 26 | #include "jfs_superblock.h" |
26 | #include "jfs_dmap.h" | 27 | #include "jfs_dmap.h" |
@@ -1148,3 +1149,38 @@ int jfs_removexattr(struct dentry *dentry, const char *name) | |||
1148 | 1149 | ||
1149 | return rc; | 1150 | return rc; |
1150 | } | 1151 | } |
1152 | |||
1153 | #ifdef CONFIG_JFS_SECURITY | ||
1154 | int jfs_init_security(tid_t tid, struct inode *inode, struct inode *dir) | ||
1155 | { | ||
1156 | int rc; | ||
1157 | size_t len; | ||
1158 | void *value; | ||
1159 | char *suffix; | ||
1160 | char *name; | ||
1161 | |||
1162 | rc = security_inode_init_security(inode, dir, &suffix, &value, &len); | ||
1163 | if (rc) { | ||
1164 | if (rc == -EOPNOTSUPP) | ||
1165 | return 0; | ||
1166 | return rc; | ||
1167 | } | ||
1168 | name = kmalloc(XATTR_SECURITY_PREFIX_LEN + 1 + strlen(suffix), | ||
1169 | GFP_NOFS); | ||
1170 | if (!name) { | ||
1171 | rc = -ENOMEM; | ||
1172 | goto kmalloc_failed; | ||
1173 | } | ||
1174 | strcpy(name, XATTR_SECURITY_PREFIX); | ||
1175 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); | ||
1176 | |||
1177 | rc = __jfs_setxattr(tid, inode, name, value, len, 0); | ||
1178 | |||
1179 | kfree(name); | ||
1180 | kmalloc_failed: | ||
1181 | kfree(suffix); | ||
1182 | kfree(value); | ||
1183 | |||
1184 | return rc; | ||
1185 | } | ||
1186 | #endif | ||