.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
3 | 4 | * |
---|
.. | .. |
---|
8 | 9 | * CREDITS: |
---|
9 | 10 | * Lots of code in this file is copy from linux/fs/ext3/xattr.c. |
---|
10 | 11 | * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or |
---|
13 | | - * modify it under the terms of the GNU General Public |
---|
14 | | - * License version 2 as published by the Free Software Foundation. |
---|
15 | | - * |
---|
16 | | - * This program is distributed in the hope that it will be useful, |
---|
17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | | - * General Public License for more details. |
---|
20 | 12 | */ |
---|
21 | 13 | |
---|
22 | 14 | #include <linux/capability.h> |
---|
.. | .. |
---|
1219 | 1211 | struct ocfs2_xattr_value_root *xv; |
---|
1220 | 1212 | size_t size; |
---|
1221 | 1213 | int ret = -ENODATA, name_offset, name_len, i; |
---|
1222 | | - int uninitialized_var(block_off); |
---|
| 1214 | + int block_off; |
---|
1223 | 1215 | |
---|
1224 | 1216 | xs->bucket = ocfs2_xattr_bucket_new(inode); |
---|
1225 | 1217 | if (!xs->bucket) { |
---|
.. | .. |
---|
7250 | 7242 | */ |
---|
7251 | 7243 | static int ocfs2_xattr_security_get(const struct xattr_handler *handler, |
---|
7252 | 7244 | struct dentry *unused, struct inode *inode, |
---|
7253 | | - const char *name, void *buffer, size_t size) |
---|
| 7245 | + const char *name, void *buffer, size_t size, |
---|
| 7246 | + int flags) |
---|
7254 | 7247 | { |
---|
7255 | 7248 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, |
---|
7256 | 7249 | name, buffer, size); |
---|
.. | .. |
---|
7268 | 7261 | static int ocfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, |
---|
7269 | 7262 | void *fs_info) |
---|
7270 | 7263 | { |
---|
| 7264 | + struct ocfs2_security_xattr_info *si = fs_info; |
---|
7271 | 7265 | const struct xattr *xattr; |
---|
7272 | 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 | + } |
---|
7273 | 7278 | |
---|
7274 | 7279 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { |
---|
7275 | 7280 | err = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, |
---|
.. | .. |
---|
7286 | 7291 | const struct qstr *qstr, |
---|
7287 | 7292 | struct ocfs2_security_xattr_info *si) |
---|
7288 | 7293 | { |
---|
| 7294 | + int ret; |
---|
| 7295 | + |
---|
7289 | 7296 | /* check whether ocfs2 support feature xattr */ |
---|
7290 | 7297 | if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb))) |
---|
7291 | 7298 | return -EOPNOTSUPP; |
---|
7292 | | - if (si) |
---|
7293 | | - return security_old_inode_init_security(inode, dir, qstr, |
---|
7294 | | - &si->name, &si->value, |
---|
7295 | | - &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 | + } |
---|
7296 | 7311 | |
---|
7297 | 7312 | return security_inode_init_security(inode, dir, qstr, |
---|
7298 | 7313 | &ocfs2_initxattrs, NULL); |
---|
.. | .. |
---|
7322 | 7337 | */ |
---|
7323 | 7338 | static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler, |
---|
7324 | 7339 | struct dentry *unused, struct inode *inode, |
---|
7325 | | - const char *name, void *buffer, size_t size) |
---|
| 7340 | + const char *name, void *buffer, size_t size, |
---|
| 7341 | + int flags) |
---|
7326 | 7342 | { |
---|
7327 | 7343 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, |
---|
7328 | 7344 | name, buffer, size); |
---|
.. | .. |
---|
7348 | 7364 | */ |
---|
7349 | 7365 | static int ocfs2_xattr_user_get(const struct xattr_handler *handler, |
---|
7350 | 7366 | struct dentry *unused, struct inode *inode, |
---|
7351 | | - const char *name, void *buffer, size_t size) |
---|
| 7367 | + const char *name, void *buffer, size_t size, |
---|
| 7368 | + int flags) |
---|
7352 | 7369 | { |
---|
7353 | 7370 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
---|
7354 | 7371 | |
---|