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.

Merge branch 'for-2.6.36' of git://linux-nfs.org/~bfields/linux

* 'for-2.6.36' of git://linux-nfs.org/~bfields/linux:
nfsd: fix NULL dereference in nfsd_statfs()
nfsd4: fix downgrade/lock logic
nfsd4: typo fix in find_any_file
nfsd4: bad BUG() in preprocess_stateid_op

+30 -24
+15 -11
fs/nfsd/nfs4state.c
··· 2450 2450 static __be32 2451 2451 nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open) 2452 2452 { 2453 - u32 op_share_access, new_access; 2453 + u32 op_share_access = open->op_share_access & ~NFS4_SHARE_WANT_MASK; 2454 + bool new_access; 2454 2455 __be32 status; 2455 2456 2456 - set_access(&new_access, stp->st_access_bmap); 2457 - new_access = (~new_access) & open->op_share_access & ~NFS4_SHARE_WANT_MASK; 2458 - 2457 + new_access = !test_bit(op_share_access, &stp->st_access_bmap); 2459 2458 if (new_access) { 2460 - status = nfs4_get_vfs_file(rqstp, fp, cur_fh, new_access); 2459 + status = nfs4_get_vfs_file(rqstp, fp, cur_fh, op_share_access); 2461 2460 if (status) 2462 2461 return status; 2463 2462 } ··· 2469 2470 return status; 2470 2471 } 2471 2472 /* remember the open */ 2472 - op_share_access = open->op_share_access & ~NFS4_SHARE_WANT_MASK; 2473 2473 __set_bit(op_share_access, &stp->st_access_bmap); 2474 2474 __set_bit(open->op_share_deny, &stp->st_deny_bmap); 2475 2475 ··· 2981 2983 *filpp = find_readable_file(stp->st_file); 2982 2984 else 2983 2985 *filpp = find_writeable_file(stp->st_file); 2984 - BUG_ON(!*filpp); /* assured by check_openmode */ 2985 2986 } 2986 2987 } 2987 2988 status = nfs_ok; ··· 3558 3561 struct nfs4_stateowner *open_sop = NULL; 3559 3562 struct nfs4_stateowner *lock_sop = NULL; 3560 3563 struct nfs4_stateid *lock_stp; 3561 - struct file *filp; 3564 + struct nfs4_file *fp; 3565 + struct file *filp = NULL; 3562 3566 struct file_lock file_lock; 3563 3567 struct file_lock conflock; 3564 3568 __be32 status = 0; ··· 3589 3591 * lock stateid. 3590 3592 */ 3591 3593 struct nfs4_stateid *open_stp = NULL; 3592 - struct nfs4_file *fp; 3593 3594 3594 3595 status = nfserr_stale_clientid; 3595 3596 if (!nfsd4_has_session(cstate) && ··· 3631 3634 if (status) 3632 3635 goto out; 3633 3636 lock_sop = lock->lk_replay_owner; 3637 + fp = lock_stp->st_file; 3634 3638 } 3635 3639 /* lock->lk_replay_owner and lock_stp have been created or found */ 3636 3640 ··· 3646 3648 switch (lock->lk_type) { 3647 3649 case NFS4_READ_LT: 3648 3650 case NFS4_READW_LT: 3649 - filp = find_readable_file(lock_stp->st_file); 3651 + if (find_readable_file(lock_stp->st_file)) { 3652 + nfs4_get_vfs_file(rqstp, fp, &cstate->current_fh, NFS4_SHARE_ACCESS_READ); 3653 + filp = find_readable_file(lock_stp->st_file); 3654 + } 3650 3655 file_lock.fl_type = F_RDLCK; 3651 3656 cmd = F_SETLK; 3652 3657 break; 3653 3658 case NFS4_WRITE_LT: 3654 3659 case NFS4_WRITEW_LT: 3655 - filp = find_writeable_file(lock_stp->st_file); 3660 + if (find_writeable_file(lock_stp->st_file)) { 3661 + nfs4_get_vfs_file(rqstp, fp, &cstate->current_fh, NFS4_SHARE_ACCESS_WRITE); 3662 + filp = find_writeable_file(lock_stp->st_file); 3663 + } 3656 3664 file_lock.fl_type = F_WRLCK; 3657 3665 cmd = F_SETLK; 3658 3666 break;
+7 -7
fs/nfsd/state.h
··· 363 363 * at all? */ 364 364 static inline struct file *find_writeable_file(struct nfs4_file *f) 365 365 { 366 - if (f->fi_fds[O_RDWR]) 367 - return f->fi_fds[O_RDWR]; 368 - return f->fi_fds[O_WRONLY]; 366 + if (f->fi_fds[O_WRONLY]) 367 + return f->fi_fds[O_WRONLY]; 368 + return f->fi_fds[O_RDWR]; 369 369 } 370 370 371 371 static inline struct file *find_readable_file(struct nfs4_file *f) 372 372 { 373 - if (f->fi_fds[O_RDWR]) 374 - return f->fi_fds[O_RDWR]; 375 - return f->fi_fds[O_RDONLY]; 373 + if (f->fi_fds[O_RDONLY]) 374 + return f->fi_fds[O_RDONLY]; 375 + return f->fi_fds[O_RDWR]; 376 376 } 377 377 378 378 static inline struct file *find_any_file(struct nfs4_file *f) 379 379 { 380 380 if (f->fi_fds[O_RDWR]) 381 381 return f->fi_fds[O_RDWR]; 382 - else if (f->fi_fds[O_RDWR]) 382 + else if (f->fi_fds[O_WRONLY]) 383 383 return f->fi_fds[O_WRONLY]; 384 384 else 385 385 return f->fi_fds[O_RDONLY];
+8 -6
fs/nfsd/vfs.c
··· 2033 2033 __be32 2034 2034 nfsd_statfs(struct svc_rqst *rqstp, struct svc_fh *fhp, struct kstatfs *stat, int access) 2035 2035 { 2036 - struct path path = { 2037 - .mnt = fhp->fh_export->ex_path.mnt, 2038 - .dentry = fhp->fh_dentry, 2039 - }; 2040 2036 __be32 err; 2041 2037 2042 2038 err = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP | access); 2043 - if (!err && vfs_statfs(&path, stat)) 2044 - err = nfserr_io; 2039 + if (!err) { 2040 + struct path path = { 2041 + .mnt = fhp->fh_export->ex_path.mnt, 2042 + .dentry = fhp->fh_dentry, 2043 + }; 2044 + if (vfs_statfs(&path, stat)) 2045 + err = nfserr_io; 2046 + } 2045 2047 return err; 2046 2048 } 2047 2049