Patch "file: Rename __fcheck_files to files_lookup_fd_raw" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    file: Rename __fcheck_files to files_lookup_fd_raw

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     file-rename-__fcheck_files-to-files_lookup_fd_raw.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8dafd13fcc568d3becd6291a6503b5a7a006dae9
Author: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
Date:   Thu Dec 10 12:39:54 2020 -0600

    file: Rename __fcheck_files to files_lookup_fd_raw
    
    [ Upstream commit bebf684bf330915e6c96313ad7db89a5480fc9c2 ]
    
    The function fcheck despite it's comment is poorly named
    as it has no callers that only check it's return value.
    All of fcheck's callers use the returned file descriptor.
    The same is true for fcheck_files and __fcheck_files.
    
    A new less confusing name is needed.  In addition the names
    of these functions are confusing as they do not report
    the kind of locks that are needed to be held when these
    functions are called making error prone to use them.
    
    To remedy this I am making the base functio name lookup_fd
    and will and prefixes and sufficies to indicate the rest
    of the context.
    
    Name the function (previously called __fcheck_files) that proceeds
    from a struct files_struct, looks up the struct file of a file
    descriptor, and requires it's callers to verify all of the appropriate
    locks are held files_lookup_fd_raw.
    
    The need for better names became apparent in the last round of
    discussion of this set of changes[1].
    
    [1] https://lkml.kernel.org/r/CAHk-=wj8BQbgJFLa+J0e=iT-1qpmCRTbPAJ8gd6MJQ=kbRPqyQ@xxxxxxxxxxxxxx
    Link: https://lkml.kernel.org/r/20201120231441.29911-7-ebiederm@xxxxxxxxxxxx
    Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
    [ cel: adjusted to apply to v5.10.y ]
    Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/file.c b/fs/file.c
index fea693acc065e..eb1e2b7220ac6 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -866,7 +866,7 @@ static struct file *__fget_files(struct files_struct *files, unsigned int fd,
 			file = NULL;
 		else if (!get_file_rcu_many(file, refs))
 			goto loop;
-		else if (__fcheck_files(files, fd) != file) {
+		else if (files_lookup_fd_raw(files, fd) != file) {
 			fput_many(file, refs);
 			goto loop;
 		}
@@ -933,7 +933,7 @@ static unsigned long __fget_light(unsigned int fd, fmode_t mask)
 	struct file *file;
 
 	if (atomic_read(&files->count) == 1) {
-		file = __fcheck_files(files, fd);
+		file = files_lookup_fd_raw(files, fd);
 		if (!file || unlikely(file->f_mode & mask))
 			return 0;
 		return (unsigned long)file;
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index c0ca6fb3f0f95..10e75b4c30a43 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -80,7 +80,7 @@ struct dentry;
 /*
  * The caller must ensure that fd table isn't shared or hold rcu or file lock
  */
-static inline struct file *__fcheck_files(struct files_struct *files, unsigned int fd)
+static inline struct file *files_lookup_fd_raw(struct files_struct *files, unsigned int fd)
 {
 	struct fdtable *fdt = rcu_dereference_raw(files->fdt);
 
@@ -96,7 +96,7 @@ static inline struct file *fcheck_files(struct files_struct *files, unsigned int
 	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&
 			   !lockdep_is_held(&files->file_lock),
 			   "suspicious rcu_dereference_check() usage");
-	return __fcheck_files(files, fd);
+	return files_lookup_fd_raw(files, fd);
 }
 
 /*




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux