xattr.c (fa3cacf544636b2dc48cfb2f277a2071f14d66a2) | xattr.c (195c52bdd5d5ecfdabf5a7c6159efe299e534f84) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * 4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved. 5 * 6 */ 7 8#include <linux/blkdev.h> --- 96 unchanged lines hidden (view full) --- 105 size = le32_to_cpu((*info)->size); 106 if (size > ni->mi.sbi->ea_max_size) 107 return -EFBIG; 108 109 if (attr_size(attr_ea) > ni->mi.sbi->ea_max_size) 110 return -EFBIG; 111 112 /* Allocate memory for packed Ea */ | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * 4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved. 5 * 6 */ 7 8#include <linux/blkdev.h> --- 96 unchanged lines hidden (view full) --- 105 size = le32_to_cpu((*info)->size); 106 if (size > ni->mi.sbi->ea_max_size) 107 return -EFBIG; 108 109 if (attr_size(attr_ea) > ni->mi.sbi->ea_max_size) 110 return -EFBIG; 111 112 /* Allocate memory for packed Ea */ |
113 ea_p = ntfs_malloc(size + add_bytes); | 113 ea_p = kmalloc(size + add_bytes, GFP_NOFS); |
114 if (!ea_p) 115 return -ENOMEM; 116 117 if (attr_ea->non_res) { 118 struct runs_tree run; 119 120 run_init(&run); 121 --- 15 unchanged lines hidden (view full) --- 137 memcpy(ea_p, p, size); 138 } 139 140 memset(Add2Ptr(ea_p, size), 0, add_bytes); 141 *ea = ea_p; 142 return 0; 143 144out: | 114 if (!ea_p) 115 return -ENOMEM; 116 117 if (attr_ea->non_res) { 118 struct runs_tree run; 119 120 run_init(&run); 121 --- 15 unchanged lines hidden (view full) --- 137 memcpy(ea_p, p, size); 138 } 139 140 memset(Add2Ptr(ea_p, size), 0, add_bytes); 141 *ea = ea_p; 142 return 0; 143 144out: |
145 ntfs_free(ea_p); | 145 kfree(ea_p); |
146 *ea = NULL; 147 return err; 148} 149 150/* 151 * ntfs_list_ea 152 * 153 * copy a list of xattrs names into the buffer --- 34 unchanged lines hidden (view full) --- 188 memcpy(buffer + ret, ea->name, ea->name_len); 189 buffer[ret + ea->name_len] = 0; 190 } 191 192 ret += ea->name_len + 1; 193 } 194 195out: | 146 *ea = NULL; 147 return err; 148} 149 150/* 151 * ntfs_list_ea 152 * 153 * copy a list of xattrs names into the buffer --- 34 unchanged lines hidden (view full) --- 188 memcpy(buffer + ret, ea->name, ea->name_len); 189 buffer[ret + ea->name_len] = 0; 190 } 191 192 ret += ea->name_len + 1; 193 } 194 195out: |
196 ntfs_free(ea_all); | 196 kfree(ea_all); |
197 return err ? err : ret; 198} 199 200static int ntfs_get_ea(struct inode *inode, const char *name, size_t name_len, 201 void *buffer, size_t size, size_t *required) 202{ 203 struct ntfs_inode *ni = ntfs_i(inode); 204 const struct EA_INFO *info; --- 41 unchanged lines hidden (view full) --- 246 *required = len; 247 goto out; 248 } 249 250 memcpy(buffer, ea->name + ea->name_len + 1, len); 251 err = 0; 252 253out: | 197 return err ? err : ret; 198} 199 200static int ntfs_get_ea(struct inode *inode, const char *name, size_t name_len, 201 void *buffer, size_t size, size_t *required) 202{ 203 struct ntfs_inode *ni = ntfs_i(inode); 204 const struct EA_INFO *info; --- 41 unchanged lines hidden (view full) --- 246 *required = len; 247 goto out; 248 } 249 250 memcpy(buffer, ea->name + ea->name_len + 1, len); 251 err = 0; 252 253out: |
254 ntfs_free(ea_all); | 254 kfree(ea_all); |
255 if (!required) 256 ni_unlock(ni); 257 258 return err ? err : len; 259} 260 261static noinline int ntfs_set_ea(struct inode *inode, const char *name, 262 size_t name_len, const void *value, --- 84 unchanged lines hidden (view full) --- 347 } 348 } else { 349 if (flags & XATTR_REPLACE) { 350 err = -ENODATA; 351 goto out; 352 } 353 354 if (!ea_all) { | 255 if (!required) 256 ni_unlock(ni); 257 258 return err ? err : len; 259} 260 261static noinline int ntfs_set_ea(struct inode *inode, const char *name, 262 size_t name_len, const void *value, --- 84 unchanged lines hidden (view full) --- 347 } 348 } else { 349 if (flags & XATTR_REPLACE) { 350 err = -ENODATA; 351 goto out; 352 } 353 354 if (!ea_all) { |
355 ea_all = ntfs_zalloc(add); | 355 ea_all = kzalloc(add, GFP_NOFS); |
356 if (!ea_all) { 357 err = -ENOMEM; 358 goto out; 359 } 360 } 361 } 362 363 /* append new xattr */ --- 105 unchanged lines hidden (view full) --- 469 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; 470 mark_inode_dirty(&ni->vfs_inode); 471 472out: 473 if (!locked) 474 ni_unlock(ni); 475 476 run_close(&ea_run); | 356 if (!ea_all) { 357 err = -ENOMEM; 358 goto out; 359 } 360 } 361 } 362 363 /* append new xattr */ --- 105 unchanged lines hidden (view full) --- 469 ni->ni_flags |= NI_FLAG_UPDATE_PARENT; 470 mark_inode_dirty(&ni->vfs_inode); 471 472out: 473 if (!locked) 474 ni_unlock(ni); 475 476 run_close(&ea_run); |
477 ntfs_free(ea_all); | 477 kfree(ea_all); |
478 479 return err; 480} 481 482#ifdef CONFIG_NTFS3_FS_POSIX_ACL 483static inline void ntfs_posix_acl_release(struct posix_acl *acl) 484{ 485 if (acl && refcount_dec_and_test(&acl->a_refcount)) --- 108 unchanged lines hidden (view full) --- 594 return -EINVAL; 595 } 596 597 if (!acl) { 598 size = 0; 599 value = NULL; 600 } else { 601 size = posix_acl_xattr_size(acl->a_count); | 478 479 return err; 480} 481 482#ifdef CONFIG_NTFS3_FS_POSIX_ACL 483static inline void ntfs_posix_acl_release(struct posix_acl *acl) 484{ 485 if (acl && refcount_dec_and_test(&acl->a_refcount)) --- 108 unchanged lines hidden (view full) --- 594 return -EINVAL; 595 } 596 597 if (!acl) { 598 size = 0; 599 value = NULL; 600 } else { 601 size = posix_acl_xattr_size(acl->a_count); |
602 value = ntfs_malloc(size); | 602 value = kmalloc(size, GFP_NOFS); |
603 if (!value) 604 return -ENOMEM; 605 606 err = posix_acl_to_xattr(mnt_userns, acl, value, size); 607 if (err < 0) 608 goto out; 609 } 610 611 err = ntfs_set_ea(inode, name, name_len, value, size, 612 acl ? 0 : XATTR_REPLACE, locked); 613 if (!err) 614 set_cached_acl(inode, type, acl); 615 616out: | 603 if (!value) 604 return -ENOMEM; 605 606 err = posix_acl_to_xattr(mnt_userns, acl, value, size); 607 if (err < 0) 608 goto out; 609 } 610 611 err = ntfs_set_ea(inode, name, name_len, value, size, 612 acl ? 0 : XATTR_REPLACE, locked); 613 if (!err) 614 set_cached_acl(inode, type, acl); 615 616out: |
617 ntfs_free(value); | 617 kfree(value); |
618 619 return err; 620} 621 622/* 623 * ntfs_set_acl 624 * 625 * inode_operations::set_acl --- 249 unchanged lines hidden (view full) --- 875 if (!buffer) { 876 err = sd_size; 877 } else if (size < sd_size) { 878 err = -ENODATA; 879 } else { 880 err = sd_size; 881 memcpy(buffer, sd, sd_size); 882 } | 618 619 return err; 620} 621 622/* 623 * ntfs_set_acl 624 * 625 * inode_operations::set_acl --- 249 unchanged lines hidden (view full) --- 875 if (!buffer) { 876 err = sd_size; 877 } else if (size < sd_size) { 878 err = -ENODATA; 879 } else { 880 err = sd_size; 881 memcpy(buffer, sd, sd_size); 882 } |
883 ntfs_free(sd); | 883 kfree(sd); |
884 goto out; 885 } 886 887#ifdef CONFIG_NTFS3_FS_POSIX_ACL 888 if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 && 889 !memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS, 890 sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) || 891 (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 && --- 237 unchanged lines hidden --- | 884 goto out; 885 } 886 887#ifdef CONFIG_NTFS3_FS_POSIX_ACL 888 if ((name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 && 889 !memcmp(name, XATTR_NAME_POSIX_ACL_ACCESS, 890 sizeof(XATTR_NAME_POSIX_ACL_ACCESS))) || 891 (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 && --- 237 unchanged lines hidden --- |