hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/ocfs2/xattr.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 * vim: noexpandtab sw=8 ts=8 sts=0:
34 *
....@@ -8,15 +9,6 @@
89 * CREDITS:
910 * Lots of code in this file is copy from linux/fs/ext3/xattr.c.
1011 * 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.
2012 */
2113
2214 #include <linux/capability.h>
....@@ -1219,7 +1211,7 @@
12191211 struct ocfs2_xattr_value_root *xv;
12201212 size_t size;
12211213 int ret = -ENODATA, name_offset, name_len, i;
1222
- int uninitialized_var(block_off);
1214
+ int block_off;
12231215
12241216 xs->bucket = ocfs2_xattr_bucket_new(inode);
12251217 if (!xs->bucket) {
....@@ -7250,7 +7242,8 @@
72507242 */
72517243 static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
72527244 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)
72547247 {
72557248 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY,
72567249 name, buffer, size);
....@@ -7268,8 +7261,20 @@
72687261 static int ocfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
72697262 void *fs_info)
72707263 {
7264
+ struct ocfs2_security_xattr_info *si = fs_info;
72717265 const struct xattr *xattr;
72727266 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
+ }
72737278
72747279 for (xattr = xattr_array; xattr->name != NULL; xattr++) {
72757280 err = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY,
....@@ -7286,13 +7291,23 @@
72867291 const struct qstr *qstr,
72877292 struct ocfs2_security_xattr_info *si)
72887293 {
7294
+ int ret;
7295
+
72897296 /* check whether ocfs2 support feature xattr */
72907297 if (!ocfs2_supports_xattr(OCFS2_SB(dir->i_sb)))
72917298 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
+ }
72967311
72977312 return security_inode_init_security(inode, dir, qstr,
72987313 &ocfs2_initxattrs, NULL);
....@@ -7322,7 +7337,8 @@
73227337 */
73237338 static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
73247339 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)
73267342 {
73277343 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED,
73287344 name, buffer, size);
....@@ -7348,7 +7364,8 @@
73487364 */
73497365 static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
73507366 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)
73527369 {
73537370 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
73547371