File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,24 +235,6 @@ bool proc_ns_file(const struct file *file)
235235 return file -> f_op == & ns_file_operations ;
236236}
237237
238- struct file * proc_ns_fget (int fd )
239- {
240- struct file * file ;
241-
242- file = fget (fd );
243- if (!file )
244- return ERR_PTR (- EBADF );
245-
246- if (file -> f_op != & ns_file_operations )
247- goto out_invalid ;
248-
249- return file ;
250-
251- out_invalid :
252- fput (file );
253- return ERR_PTR (- EINVAL );
254- }
255-
256238/**
257239 * ns_match() - Returns true if current namespace matches dev/ino provided.
258240 * @ns: current namespace
Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ static inline int ns_alloc_inum(struct ns_common *ns)
7272
7373#define ns_free_inum (ns ) proc_free_inum((ns)->inum)
7474
75- extern struct file * proc_ns_fget (int fd );
7675#define get_proc_ns (inode ) ((struct ns_common *)(inode)->i_private)
7776extern int ns_get_path (struct path * path , struct task_struct * task ,
7877 const struct proc_ns_operations * ns_ops );
Original file line number Diff line number Diff line change 2020#include <linux/sched/task.h>
2121#include <linux/uidgid.h>
2222#include <linux/cookie.h>
23+ #include <linux/proc_fs.h>
2324
2425#include <net/sock.h>
2526#include <net/netlink.h>
@@ -676,21 +677,19 @@ EXPORT_SYMBOL_GPL(get_net_ns);
676677
677678struct net * get_net_ns_by_fd (int fd )
678679{
679- struct file * file ;
680- struct ns_common * ns ;
681- struct net * net ;
680+ struct fd f = fdget (fd );
681+ struct net * net = ERR_PTR (- EINVAL );
682682
683- file = proc_ns_fget (fd );
684- if (IS_ERR (file ))
685- return ERR_CAST (file );
683+ if (!f .file )
684+ return ERR_PTR (- EBADF );
686685
687- ns = get_proc_ns (file_inode (file ));
688- if (ns -> ops == & netns_operations )
689- net = get_net (container_of (ns , struct net , ns ));
690- else
691- net = ERR_PTR (- EINVAL );
686+ if (proc_ns_file (f .file )) {
687+ struct ns_common * ns = get_proc_ns (file_inode (f .file ));
688+ if (ns -> ops == & netns_operations )
689+ net = get_net (container_of (ns , struct net , ns ));
690+ }
691+ fdput (f );
692692
693- fput (file );
694693 return net ;
695694}
696695EXPORT_SYMBOL_GPL (get_net_ns_by_fd );
You can’t perform that action at this time.
0 commit comments