Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

filename_...xattr(): don't consume filename reference

Callers switched to CLASS(filename_maybe_null) (in fs/xattr.c)
and CLASS(filename_complete_delayed) (in io_uring/xattr.c).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 5b9d406f e50aae1d

+12 -29
+8 -25
fs/xattr.c
··· 649 649 return error; 650 650 } 651 651 652 - /* unconditionally consumes filename */ 653 652 int filename_setxattr(int dfd, struct filename *filename, 654 653 unsigned int lookup_flags, struct kernel_xattr_ctx *ctx) 655 654 { ··· 658 659 retry: 659 660 error = filename_lookup(dfd, filename, lookup_flags, &path, NULL); 660 661 if (error) 661 - goto out; 662 + return error; 662 663 error = mnt_want_write(path.mnt); 663 664 if (!error) { 664 665 error = do_setxattr(mnt_idmap(path.mnt), path.dentry, ctx); ··· 669 670 lookup_flags |= LOOKUP_REVAL; 670 671 goto retry; 671 672 } 672 - 673 - out: 674 - putname(filename); 675 673 return error; 676 674 } 677 675 ··· 684 688 .kname = &kname, 685 689 .flags = flags, 686 690 }; 687 - struct filename *filename; 688 691 unsigned int lookup_flags = 0; 689 692 int error; 690 693 ··· 697 702 if (error) 698 703 return error; 699 704 700 - filename = getname_maybe_null(pathname, at_flags); 705 + CLASS(filename_maybe_null, filename)(pathname, at_flags); 701 706 if (!filename && dfd >= 0) { 702 707 CLASS(fd, f)(dfd); 703 708 if (fd_empty(f)) ··· 799 804 return do_getxattr(file_mnt_idmap(f), f->f_path.dentry, ctx); 800 805 } 801 806 802 - /* unconditionally consumes filename */ 803 807 ssize_t filename_getxattr(int dfd, struct filename *filename, 804 808 unsigned int lookup_flags, struct kernel_xattr_ctx *ctx) 805 809 { ··· 807 813 retry: 808 814 error = filename_lookup(dfd, filename, lookup_flags, &path, NULL); 809 815 if (error) 810 - goto out; 816 + return error; 811 817 error = do_getxattr(mnt_idmap(path.mnt), path.dentry, ctx); 812 818 path_put(&path); 813 819 if (retry_estale(error, lookup_flags)) { 814 820 lookup_flags |= LOOKUP_REVAL; 815 821 goto retry; 816 822 } 817 - out: 818 - putname(filename); 819 823 return error; 820 824 } 821 825 ··· 828 836 .kname = &kname, 829 837 .flags = 0, 830 838 }; 831 - struct filename *filename; 832 839 ssize_t error; 833 840 834 841 if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0) ··· 837 846 if (error) 838 847 return error; 839 848 840 - filename = getname_maybe_null(pathname, at_flags); 849 + CLASS(filename_maybe_null, filename)(pathname, at_flags); 841 850 if (!filename && dfd >= 0) { 842 851 CLASS(fd, f)(dfd); 843 852 if (fd_empty(f)) ··· 934 943 return listxattr(f->f_path.dentry, list, size); 935 944 } 936 945 937 - /* unconditionally consumes filename */ 938 946 static 939 947 ssize_t filename_listxattr(int dfd, struct filename *filename, 940 948 unsigned int lookup_flags, ··· 944 954 retry: 945 955 error = filename_lookup(dfd, filename, lookup_flags, &path, NULL); 946 956 if (error) 947 - goto out; 957 + return error; 948 958 error = listxattr(path.dentry, list, size); 949 959 path_put(&path); 950 960 if (retry_estale(error, lookup_flags)) { 951 961 lookup_flags |= LOOKUP_REVAL; 952 962 goto retry; 953 963 } 954 - out: 955 - putname(filename); 956 964 return error; 957 965 } 958 966 ··· 958 970 unsigned int at_flags, char __user *list, 959 971 size_t size) 960 972 { 961 - struct filename *filename; 962 973 int lookup_flags; 963 974 964 975 if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0) 965 976 return -EINVAL; 966 977 967 - filename = getname_maybe_null(pathname, at_flags); 978 + CLASS(filename_maybe_null, filename)(pathname, at_flags); 968 979 if (!filename) { 969 980 CLASS(fd, f)(dfd); 970 981 if (fd_empty(f)) ··· 1023 1036 return error; 1024 1037 } 1025 1038 1026 - /* unconditionally consumes filename */ 1027 1039 static int filename_removexattr(int dfd, struct filename *filename, 1028 1040 unsigned int lookup_flags, struct xattr_name *kname) 1029 1041 { ··· 1032 1046 retry: 1033 1047 error = filename_lookup(dfd, filename, lookup_flags, &path, NULL); 1034 1048 if (error) 1035 - goto out; 1049 + return error; 1036 1050 error = mnt_want_write(path.mnt); 1037 1051 if (!error) { 1038 1052 error = removexattr(mnt_idmap(path.mnt), path.dentry, kname->name); ··· 1043 1057 lookup_flags |= LOOKUP_REVAL; 1044 1058 goto retry; 1045 1059 } 1046 - out: 1047 - putname(filename); 1048 1060 return error; 1049 1061 } 1050 1062 ··· 1050 1066 unsigned int at_flags, const char __user *name) 1051 1067 { 1052 1068 struct xattr_name kname; 1053 - struct filename *filename; 1054 1069 unsigned int lookup_flags; 1055 1070 int error; 1056 1071 ··· 1060 1077 if (error) 1061 1078 return error; 1062 1079 1063 - filename = getname_maybe_null(pathname, at_flags); 1080 + CLASS(filename_maybe_null, filename)(pathname, at_flags); 1064 1081 if (!filename) { 1065 1082 CLASS(fd, f)(dfd); 1066 1083 if (fd_empty(f))
+4 -4
io_uring/xattr.c
··· 109 109 int io_getxattr(struct io_kiocb *req, unsigned int issue_flags) 110 110 { 111 111 struct io_xattr *ix = io_kiocb_to_cmd(req, struct io_xattr); 112 + CLASS(filename_complete_delayed, name)(&ix->filename); 112 113 int ret; 113 114 114 115 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); 115 116 116 - ret = filename_getxattr(AT_FDCWD, complete_getname(&ix->filename), 117 - LOOKUP_FOLLOW, &ix->ctx); 117 + ret = filename_getxattr(AT_FDCWD, name, LOOKUP_FOLLOW, &ix->ctx); 118 118 io_xattr_finish(req, ret); 119 119 return IOU_COMPLETE; 120 120 } ··· 186 186 int io_setxattr(struct io_kiocb *req, unsigned int issue_flags) 187 187 { 188 188 struct io_xattr *ix = io_kiocb_to_cmd(req, struct io_xattr); 189 + CLASS(filename_complete_delayed, name)(&ix->filename); 189 190 int ret; 190 191 191 192 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); 192 193 193 - ret = filename_setxattr(AT_FDCWD, complete_getname(&ix->filename), 194 - LOOKUP_FOLLOW, &ix->ctx); 194 + ret = filename_setxattr(AT_FDCWD, name, LOOKUP_FOLLOW, &ix->ctx); 195 195 io_xattr_finish(req, ret); 196 196 return IOU_COMPLETE; 197 197 }