.. | .. |
---|
7261 | 7261 | static int ocfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
---|
7262 | 7262 | void *fs_info) |
---|
7263 | 7263 | { |
---|
| 7264 | + struct ocfs2_security_xattr_info *si = fs_info; |
---|
7264 | 7265 | const struct xattr *xattr; |
---|
7265 | 7266 | int err = 0; |
---|
| 7267 | + |
---|
| 7268 | + if (si) { |
---|
| 7269 | + si->value = kmemdup(xattr_array->value, xattr_array->value_len, |
---|
| 7270 | + GFP_KERNEL); |
---|
| 7271 | + if (!si->value) |
---|
| 7272 | + return -ENOMEM; |
---|
| 7273 | + |
---|
| 7274 | + si->name = xattr_array->name; |
---|
| 7275 | + si->value_len = xattr_array->value_len; |
---|
| 7276 | + return 0; |
---|
| 7277 | + } |
---|
7266 | 7278 | |
---|
7267 | 7279 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
---|
7268 | 7280 | err = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, |
---|
.. | .. |
---|
7279 | 7291 | const struct qstr *qstr, |
---|
7280 | 7292 | struct ocfs2_security_xattr_info *si) |
---|
7281 | 7293 | { |
---|
| 7294 | + int ret; |
---|
| 7295 | + |
---|
7282 | 7296 | /* check whether ocfs2 support feature xattr */ |
---|
7283 | 7297 | if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) |
---|
7284 | 7298 | return -EOPNOTSUPP; |
---|
7285 | | - if (si) |
---|
7286 | | - return security_old_inode_init_security(inode, dir, qstr, |
---|
7287 | | - &si->name, &si->value, |
---|
7288 | | - &si->value_len); |
---|
| 7299 | + if (si) { |
---|
| 7300 | + ret = security_inode_init_security(inode, dir, qstr, |
---|
| 7301 | + &ocfs2_initxattrs, si); |
---|
| 7302 | + /* |
---|
| 7303 | + * security_inode_init_security() does not return -EOPNOTSUPP, |
---|
| 7304 | + * we have to check the xattr ourselves. |
---|
| 7305 | + */ |
---|
| 7306 | + if (!ret && !si->name) |
---|
| 7307 | + si->enable = 0; |
---|
| 7308 | + |
---|
| 7309 | + return ret; |
---|
| 7310 | + } |
---|
7289 | 7311 | |
---|
7290 | 7312 | return security_inode_init_security(inode, dir, qstr, |
---|
7291 | 7313 | &ocfs2_initxattrs, NULL); |
---|