mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	NFSD: Ensure nf_inode is never dereferenced
The documenting comment for struct nf_file states: /* * A representation of a file that has been opened by knfsd. These are hashed * in the hashtable by inode pointer value. Note that this object doesn't * hold a reference to the inode by itself, so the nf_inode pointer should * never be dereferenced, only used for comparison. */ Replace the two existing dereferences to make the comment always true. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
		
							parent
							
								
									5e138c4a75
								
							
						
					
					
						commit
						427f5f83a3
					
				
					 3 changed files with 4 additions and 5 deletions
				
			
		| 
						 | 
					@ -228,12 +228,11 @@ nfsd_file_mark_put(struct nfsd_file_mark *nfm)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct nfsd_file_mark *
 | 
					static struct nfsd_file_mark *
 | 
				
			||||||
nfsd_file_mark_find_or_create(struct nfsd_file *nf)
 | 
					nfsd_file_mark_find_or_create(struct nfsd_file *nf, struct inode *inode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int			err;
 | 
						int			err;
 | 
				
			||||||
	struct fsnotify_mark	*mark;
 | 
						struct fsnotify_mark	*mark;
 | 
				
			||||||
	struct nfsd_file_mark	*nfm = NULL, *new;
 | 
						struct nfsd_file_mark	*nfm = NULL, *new;
 | 
				
			||||||
	struct inode *inode = nf->nf_inode;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
		fsnotify_group_lock(nfsd_file_fsnotify_group);
 | 
							fsnotify_group_lock(nfsd_file_fsnotify_group);
 | 
				
			||||||
| 
						 | 
					@ -1144,7 +1143,7 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
open_file:
 | 
					open_file:
 | 
				
			||||||
	trace_nfsd_file_alloc(nf);
 | 
						trace_nfsd_file_alloc(nf);
 | 
				
			||||||
	nf->nf_mark = nfsd_file_mark_find_or_create(nf);
 | 
						nf->nf_mark = nfsd_file_mark_find_or_create(nf, key.inode);
 | 
				
			||||||
	if (nf->nf_mark) {
 | 
						if (nf->nf_mark) {
 | 
				
			||||||
		if (open) {
 | 
							if (open) {
 | 
				
			||||||
			status = nfsd_open_verified(rqstp, fhp, may_flags,
 | 
								status = nfsd_open_verified(rqstp, fhp, may_flags,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ struct nfsd_file {
 | 
				
			||||||
#define NFSD_FILE_PENDING	(1)
 | 
					#define NFSD_FILE_PENDING	(1)
 | 
				
			||||||
#define NFSD_FILE_REFERENCED	(2)
 | 
					#define NFSD_FILE_REFERENCED	(2)
 | 
				
			||||||
	unsigned long		nf_flags;
 | 
						unsigned long		nf_flags;
 | 
				
			||||||
	struct inode		*nf_inode;
 | 
						struct inode		*nf_inode;	/* don't deref */
 | 
				
			||||||
	refcount_t		nf_ref;
 | 
						refcount_t		nf_ref;
 | 
				
			||||||
	unsigned char		nf_may;
 | 
						unsigned char		nf_may;
 | 
				
			||||||
	struct nfsd_file_mark	*nf_mark;
 | 
						struct nfsd_file_mark	*nf_mark;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2564,7 +2564,7 @@ static void nfs4_show_fname(struct seq_file *s, struct nfsd_file *f)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void nfs4_show_superblock(struct seq_file *s, struct nfsd_file *f)
 | 
					static void nfs4_show_superblock(struct seq_file *s, struct nfsd_file *f)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct inode *inode = f->nf_inode;
 | 
						struct inode *inode = file_inode(f->nf_file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	seq_printf(s, "superblock: \"%02x:%02x:%ld\"",
 | 
						seq_printf(s, "superblock: \"%02x:%02x:%ld\"",
 | 
				
			||||||
					MAJOR(inode->i_sb->s_dev),
 | 
										MAJOR(inode->i_sb->s_dev),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue