Introduction
Subsystems (5)
PATCH 1/1 Introduction
Following are 4 patches for knfsd in 2.6.latest
1/ remove open_private_file. It is an ugly hack that isn't really necessary,
and causes problems.
2/ fix a minor memory leak
3/ fix a(nother) possible memory corruption with xdr encoding of
readdirplus responses.
4/ Fix minor timing issue with authentication cache flushing.
Thanks,
NeilBrown
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 Minor memory leak fix.
### Diffstat output
./net/sunrpc/svcauth_unix.c | 1 + 1 files changed, 1 insertion(+)
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +1 -0
@@ -104,6 +104,7 @@ void ip_map_put(struct cache_head *item,if (test_bit (CACHE_VALID , &item->flags) && !test_bit (CACHE_NEGATIVE , &item->flags))auth_domain_put (&im->m_client->h); +kfree (im->m_class);kfree (im); } }
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 Fix race with flushing nfsd cache.
In reply to NeilBrownTo purge an nfsd-authentication cache, we set the flush time
to later than last-refresh time in the cache and call cache_flush. The easiest way to find 'later than last-refresh' is 'now+1'. This has two problems.
1/ if the time-of-day clock has gone bacwards, some entries might not
be purged
2/ if a new entry is added in the same second as cache_purge ran, it will
get ignored.
To resolve these issues, we set the flushtime to the maximum possible time before calling cache_flush, and then set it back to the minimum time afterwards.
### Diffstat output
./net/sunrpc/cache.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +2 -1
@@ -400,9 +400,10 @@ void cache_flush(void)void cache_purge (struct cache_detail *detail) { - detail->flush_time =get_seconds ()+1 ; + detail->flush_time =LONG_MAX ; detail->nextcheck =get_seconds ();cache_flush (); + detail->flush_time =1 ; }
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 Fix two xdr-encode bugs for readdirplus reply
In reply to NeilBrownMore fall-out from the change to allow multi-page
replies to readdir requests.
### Diffstat output
./fs/nfsd/nfs3proc.c | 12 ++++++++++-- ./fs/nfsd/nfs3xdr.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-)
fs/nfsd/nfs3proc.c renamed from fs/nfsd/nfs3proc.c~current~ +10 -2
@@ -492,8 +492,16 @@ nfsd3_proc_readdirplus(struct svc_rqst * count +=PAGE_SIZE ; } resp->count = count >>2 ; -if (resp->offset) -xdr_encode_hyper (resp->offset, offset); +if (resp->offset) { +if (unlikely (resp->offset1)) { +/* we ended up with offset on a page boundary */ + *resp->offset =htonl (offset >>32 ); + *resp->offset1 =htonl (offset &0xffffffff ); + resp->offset1 =NULL ; + }else { +xdr_encode_hyper (resp->offset, offset); + } + }RETURN_STATUS (nfserr); }
fs/nfsd/nfs3xdr.c renamed from fs/nfsd/nfs3xdr.c~current~ +8 -2
@@ -762,10 +762,16 @@ nfs3svc_encode_readdirres(struct svc_rqs/* stupid readdir cookie */ memcpy (p, resp->verf,8 ); p +=2 ;xdr_ressize_check (rqstp, p); - p = resp->buffer; +if (rqstp->rq_res.head[0 ].iov_len + (2 <<2 ) >PAGE_SIZE ) +return 1 ;/*No room for trailer */ + rqstp->rq_res.page_len = (resp->count) <<2 ; + +/* add the 'tail' to the end of the 'head' page - page 0. */ + rqstp->rq_restailpage =0 ; + rqstp->rq_res.tail[0 ].iov_base = p; *p++ =0 ;/* no more entries */ *p++ =htonl (resp->common.err == nfserr_eof); - rqstp->rq_res.page_len = (resp->count +2 ) <<2 ; + rqstp->rq_res.tail[0 ].iov_len =2 <<2 ;return 1 ; }else return xdr_ressize_check (rqstp, p);
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 Get rid of open_private_file
In reply to NeilBrownThis is only used by nfsd to save one kmalloc, and the code is not always kept up-to-date with dentry_open, so just get rid of it.
### Diffstat output
./fs/exportfs/expfs.c | 15 ++++-- ./fs/file_table.c | 46 --------------------- ./fs/lockd/svc4proc.c | 2 ./fs/lockd/svclock.c | 30 ++++++------- ./fs/lockd/svcproc.c | 2 ./fs/lockd/svcsubs.c | 8 +-- ./fs/nfsd/lockd.c | 11 +---- ./fs/nfsd/nfs4state.c | 22 ++++------ ./fs/nfsd/vfs.c | 91 ++++++++++++++++++------------------------ ./include/linux/fs.h | 5 -- ./include/linux/lockd/bind.h | 2 ./include/linux/lockd/lockd.h | 4 - ./include/linux/nfsd/nfsd.h | 2 ./include/linux/nfsd/state.h | 2 14 files changed, 88 insertions(+), 154 deletions(-)
fs/exportfs/expfs.c renamed from fs/exportfs/expfs.c~current~ +9 -6
@@ -1,5 +1,6 @@#include <linux/fs.h> +#include <linux/file.h> #include <linux/module.h> #include <linux/smp_lock.h> #include <linux/namei.h>
@@ -347,7 +348,7 @@ static int get_name(struct dentry *dentr {struct inode *dir = dentry->d_inode;int error; -struct file file; +struct file *file;struct getdents_callback buffer; error = -ENOTDIR ;
@@ -359,11 +360,13 @@ static int get_name(struct dentry *dentr/* * Open the directory ... */ - error =open_private_file (&file, dentry,O_RDONLY ); -if (error) + file =dentry_open (dget (dentry),NULL ,O_RDONLY ); + error =PTR_ERR (file); +if (IS_ERR (file)) goto out; + error = -EINVAL ; -if (!file.f_op->readdir) +if (!file->f_op->readdir) goto out_close; buffer.name = name;
@@ -373,7 +376,7 @@ static int get_name(struct dentry *dentrwhile (1 ) {int old_seq = buffer.sequence; - error =vfs_readdir (&file, filldir_one, &buffer); + error =vfs_readdir (file, filldir_one, &buffer);if (error <0 )break ;
@@ -387,7 +390,7 @@ static int get_name(struct dentry *dentr } out_close: -close_private_file (&file); +fput (file); out:return error; }
fs/file_table.c renamed from fs/file_table.c~current~ +0 -46
52 lines not on this page · raw message
fs/lockd/svc4proc.c renamed from fs/lockd/svc4proc.c~current~ +1 -1
@@ -53,7 +53,7 @@ nlm4svc_retrieve_args(struct svc_rqst *r *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.fl_file = &file->f_file; + lock->fl.fl_file = file->f_file; lock->fl.fl_owner = (fl_owner_t ) host; lock->fl.fl_lmops = &nlmsvc_lock_operations; }
fs/lockd/svclock.c renamed from fs/lockd/svclock.c~current~ +15 -15
@@ -237,7 +237,7 @@ nlmsvc_delete_block(struct nlm_block *bl/* Remove block from list */ nlmsvc_remove_block (block); -posix_unblock_lock (&file->f_file, fl); +posix_unblock_lock (file->f_file, fl); block->b_granted =0 ;/* If the block is in the middle of a GRANT callback,
@@ -298,8 +298,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struint error; dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n", - file->f_file.f_dentry->d_inode->i_sb->s_id, - file->f_file.f_dentry->d_inode->i_ino, + file->f_file->f_dentry->d_inode->i_sb->s_id, + file->f_file->f_dentry->d_inode->i_ino, lock->fl.fl_type, lock->fl.fl_pid, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end,
@@ -315,8 +315,8 @@ again:/* Lock file against concurrent access */ down (&file->f_sema); -if (!(conflock =posix_test_lock (&file->f_file, &lock->fl))) { - error =posix_lock_file (&file->f_file, &lock->fl); +if (!(conflock =posix_test_lock (file->f_file, &lock->fl))) { + error =posix_lock_file (file->f_file, &lock->fl);if (block)nlmsvc_delete_block (block,0 );
@@ -381,13 +381,13 @@ nlmsvc_testlock(struct nlm_file *file, sstruct file_lock *fl;dprintk ("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n" , - file->f_file.f_dentry->d_inode->i_sb->s_id, - file->f_file.f_dentry->d_inode->i_ino, + file->f_file->f_dentry->d_inode->i_sb->s_id, + file->f_file->f_dentry->d_inode->i_ino, lock->fl.fl_type, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end); -if ((fl =posix_test_lock (&file->f_file, &lock->fl)) !=NULL ) { +if ((fl =posix_test_lock (file->f_file, &lock->fl)) !=NULL ) {dprintk ("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n" , fl->fl_type, (long long )fl->fl_start, (long long )fl->fl_end);
@@ -413,8 +413,8 @@ nlmsvc_unlock(struct nlm_file *file, strint error;dprintk ("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n" , - file->f_file.f_dentry->d_inode->i_sb->s_id, - file->f_file.f_dentry->d_inode->i_ino, + file->f_file->f_dentry->d_inode->i_sb->s_id, + file->f_file->f_dentry->d_inode->i_ino, lock->fl.fl_pid, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end);
@@ -423,7 +423,7 @@ nlmsvc_unlock(struct nlm_file *file, strnlmsvc_cancel_blocked (file, lock); lock->fl.fl_type =F_UNLCK ; - error =posix_lock_file (&file->f_file, &lock->fl); + error =posix_lock_file (file->f_file, &lock->fl);return (error <0 )? nlm_lck_denied_nolocks : nlm_granted; }
@@ -441,8 +441,8 @@ nlmsvc_cancel_blocked(struct nlm_file *fstruct nlm_block *block;dprintk ("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n" , - file->f_file.f_dentry->d_inode->i_sb->s_id, - file->f_file.f_dentry->d_inode->i_ino, + file->f_file->f_dentry->d_inode->i_sb->s_id, + file->f_file->f_dentry->d_inode->i_ino, lock->fl.fl_pid, (long long )lock->fl.fl_start, (long long )lock->fl.fl_end);
@@ -524,7 +524,7 @@ nlmsvc_grant_blocked(struct nlm_block *b }/* Try the lock operation again */ -if ((conflock =posix_test_lock (&file->f_file, &lock->fl)) !=NULL ) { +if ((conflock =posix_test_lock (file->f_file, &lock->fl)) !=NULL ) {/* Bummer, we blocked again */ dprintk ("lockd: lock still blocked\n" );nlmsvc_insert_block (block,NLM_NEVER );
@@ -537,7 +537,7 @@ nlmsvc_grant_blocked(struct nlm_block *b* following yields an error, this is most probably due to low * memory. Retry the lock in a few seconds. */ -if ((error =posix_lock_file (&file->f_file, &lock->fl)) <0 ) { +if ((error =posix_lock_file (file->f_file, &lock->fl)) <0 ) {printk (KERN_WARNING "lockd: unexpected error %d in %s!\n" , -error, __FUNCTION__);nlmsvc_insert_block (block,10 *HZ );
fs/lockd/svcproc.c renamed from fs/lockd/svcproc.c~current~ +1 -1
@@ -82,7 +82,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rq *filp = file;/* Set up the missing parts of the file_lock structure */ - lock->fl.fl_file = &file->f_file; + lock->fl.fl_file = file->f_file; lock->fl.fl_owner = (fl_owner_t ) host; lock->fl.fl_lmops = &nlmsvc_lock_operations; }
fs/lockd/svcsubs.c renamed from fs/lockd/svcsubs.c~current~ +4 -4
@@ -124,7 +124,7 @@ out_free:static inline void nlm_delete_file (struct nlm_file *file) { -struct inode *inode = file->f_file.f_dentry->d_inode; +struct inode *inode = file->f_file->f_dentry->d_inode;struct nlm_file **fp, *f; dprintk("lockd: closing file %s/%ld\n",
@@ -133,7 +133,7 @@ nlm_delete_file(struct nlm_file *file)while ((f = *fp) !=NULL ) {if (f == file) { *fp = file->f_next; - nlmsvc_ops->fclose (&file->f_file); + nlmsvc_ops->fclose (file->f_file);kfree (file);return ; }
@@ -176,7 +176,7 @@ again: lock.fl_type =F_UNLCK ; lock.fl_start =0 ; lock.fl_end =OFFSET_MAX ; -if (posix_lock_file (&file->f_file, &lock) <0 ) { +if (posix_lock_file (file->f_file, &lock) <0 ) {printk ("lockd: unlock failure in %s:%d\n" , __FILE__, __LINE__);return 1 ;
@@ -230,7 +230,7 @@ nlm_traverse_files(struct nlm_host *hostif (!file->f_blocks && !file->f_locks && !file->f_shares && !file->f_count) { *fp = file->f_next; - nlmsvc_ops->fclose (&file->f_file); + nlmsvc_ops->fclose (file->f_file);kfree (file); }else { fp = &file->f_next;
fs/nfsd/lockd.c renamed from fs/nfsd/lockd.c~current~ +3 -8
@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/fs.h> +#include <linux/file.h> #include <linux/mount.h> #include <linux/sunrpc/clnt.h> #include <linux/sunrpc/svc.h>
@@ -22,7 +23,7 @@* Note: we hold the dentry use count while the file is open. */ static u32 -nlm_fopen (struct svc_rqst *rqstp,struct nfs_fh *f,struct file *filp) +nlm_fopen (struct svc_rqst *rqstp,struct nfs_fh *f,struct file **filp) {u32 nfserr;struct svc_fh fh;
@@ -35,10 +36,6 @@ nlm_fopen(struct svc_rqst *rqstp, structexp_readlock (); nfserr =nfsd_open (rqstp, &fh,S_IFREG ,MAY_LOCK , filp); -if (!nfserr) { -dget (filp->f_dentry); -mntget (filp->f_vfsmnt); - }fh_put (&fh); rqstp->rq_client =NULL ;exp_readunlock ();
@@ -60,9 +57,7 @@ nlm_fopen(struct svc_rqst *rqstp, structstatic void nlm_fclose (struct file *filp) { -nfsd_close (filp); -dput (filp->f_dentry); -mntput (filp->f_vfsmnt); +fput (filp); }struct nlmsvc_binding nfsd_nlm_ops = {
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +9 -13
@@ -962,12 +962,10 @@ release_stateid(struct nfs4_stateid *stplist_del (&stp->st_perfilestate);if ((stp->st_vfs_set) && (flags &OPEN_STATE )) {release_stateid_lockowner (stp); -nfsd_close (&stp->st_vfs_file); +nfsd_close (stp->st_vfs_file); vfsclose++; -dput (stp->st_vfs_file.f_dentry); -mntput (stp->st_vfs_file.f_vfsmnt); }else if ((stp->st_vfs_set) && (flags &LOCK_STATE )) { -struct file *filp = &stp->st_vfs_file; +struct file *filp = stp->st_vfs_file;locks_remove_posix (filp, (fl_owner_t ) stp->st_stateowner); }
@@ -1315,8 +1313,6 @@ nfsd4_process_open2(struct svc_rqst *rqs goto out_free; vfsopen++; -dget (stp->st_vfs_file.f_dentry); -mntget (stp->st_vfs_file.f_vfsmnt);init_stateid (stp, fp, sop, open); stp->st_vfs_set =1 ;
@@ -1331,7 +1327,7 @@ nfsd4_process_open2(struct svc_rqst *rqs share_access &= open->op_share_access;/* update the struct file */ -if ((status =nfs4_file_upgrade (&stp->st_vfs_file, share_access))) +if ((status =nfs4_file_upgrade (stp->st_vfs_file, share_access))) goto out;/* remember the open */ set_bit (open->op_share_access, &stp->st_access_bmap);
@@ -1499,7 +1495,7 @@ static inline int nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stateid *stp) {return (stp->st_vfs_set ==0 || - fhp->fh_dentry->d_inode != stp->st_vfs_file.f_dentry->d_inode); + fhp->fh_dentry->d_inode != stp->st_vfs_file->f_dentry->d_inode); } static int
@@ -1816,7 +1812,7 @@ nfsd4_open_downgrade(struct svc_rqst *rq goto out; }set_access (&share_access, stp->st_access_bmap); -nfs4_file_downgrade (&stp->st_vfs_file, +nfs4_file_downgrade (stp->st_vfs_file, share_access & ~od->od_share_access);reset_union_bmap_access (od->od_share_access, &stp->st_access_bmap);
@@ -2059,7 +2055,7 @@ alloc_init_lock_stateid(struct nfs4_stat stp->st_stateid.si_stateownerid = sop->so_id; stp->st_stateid.si_fileid = fp->fi_id; stp->st_stateid.si_generation =0 ; - stp->st_vfs_file = open_stp->st_vfs_file; + stp->st_vfs_file = open_stp->st_vfs_file;/* FIXME refcount?? */ stp->st_vfs_set = open_stp->st_vfs_set; stp->st_access_bmap = open_stp->st_access_bmap; stp->st_deny_bmap = open_stp->st_deny_bmap;
@@ -2172,7 +2168,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struc goto out; }/* lock->lk_stateowner and lock_stp have been created or found */ - filp = &lock_stp->st_vfs_file; + filp = lock_stp->st_vfs_file;if ((status =fh_verify (rqstp, current_fh,S_IFREG ,MAY_LOCK ))) {printk ("NFSD: nfsd4_lock: permission denied!\n" );
@@ -2379,7 +2375,7 @@ nfsd4_locku(struct svc_rqst *rqstp, stru &locku->lu_stateowner, &stp, NULL))) goto out; - filp = &stp->st_vfs_file; + filp = stp->st_vfs_file;BUG_ON (!filp);locks_init_lock (&file_lock); file_lock.fl_type =F_UNLCK ;
@@ -2474,7 +2470,7 @@ nfsd4_release_lockowner(struct svc_rqstlist_for_each_entry (stp, &local->so_perfilestate, st_perfilestate) {if (stp->st_vfs_set) { -if (check_for_locks (&stp->st_vfs_file, local)) +if (check_for_locks (stp->st_vfs_file, local)) goto out; } }
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +41 -50
266 lines not on this page · raw message
include/linux/fs.h renamed from include/linux/fs.h~current~ +0 -5
@@ -597,11 +597,6 @@ extern spinlock_t files_lock;#define get_file (x) atomic_inc(&(x)->f_count)#define file_count (x) atomic_read(&(x)->f_count) -/* Initialize and open a private file and allocate its security structure. */ -extern int open_private_file (struct file *,struct dentry *,int ); -/* Release a private file and free its security structure. */ -extern void close_private_file (struct file *file); -#define MAX_NON_LFS ((1UL<<31) - 1)/* Page cache limit. The filesystems should put that into their s_maxbytes
include/linux/lockd/bind.h renamed from include/linux/lockd/bind.h~current~ +1 -1
@@ -20,7 +20,7 @@ struct svc_rqst;struct nlmsvc_binding {u32 (*fopen)(struct svc_rqst *,struct nfs_fh *, -struct file *); +struct file **);void (*fclose)(struct file *); };
include/linux/lockd/lockd.h renamed from include/linux/lockd/lockd.h~current~ +2 -2
@@ -92,7 +92,7 @@ struct nlm_rqst {struct nlm_file {struct nlm_file * f_next;/* linked list */ struct nfs_fh f_handle;/* NFS file handle */ -struct file f_file;/* VFS file pointer */ +struct file * f_file;/* VFS file pointer */ struct nlm_share * f_shares;/* DOS shares */ struct nlm_block * f_blocks;/* blocked locks */ unsigned int f_locks;/* guesstimate # of locks */
@@ -195,7 +195,7 @@ void nlmsvc_invalidate_all(void);static __inline__struct inode *nlmsvc_file_inode (struct nlm_file *file) { -return file->f_file.f_dentry->d_inode; +return file->f_file->f_dentry->d_inode; }/*
include/linux/nfsd/nfsd.h renamed from include/linux/nfsd/nfsd.h~current~ +1 -1
@@ -94,7 +94,7 @@ int nfsd_commit(struct svc_rqst *, stru loff_t, unsigned long);#endif /* CONFIG_NFSD_V3 */ int nfsd_open (struct svc_rqst *,struct svc_fh *,int , -int ,struct file *); +int ,struct file **);void nfsd_close (struct file *);int nfsd_read (struct svc_rqst *,struct svc_fh *,loff_t ,struct kvec *,int ,unsigned long *);
include/linux/nfsd/state.h renamed from include/linux/nfsd/state.h~current~ +1 -1
@@ -218,7 +218,7 @@ struct nfs4_stateid {struct nfs4_stateowner * st_stateowner;struct nfs4_file * st_file;stateid_t st_stateid; -struct file st_vfs_file; +struct file * st_vfs_file;int st_vfs_set;unsigned long st_access_bmap;unsigned long st_deny_bmap;
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 2 of 4] Minor memory leak fix.
In reply to NeilBrownnet/sunrpc/svcauth_unix.c void ip_map_put(struct cache_head *item, · line 110
Quoted 11 lines · NeilBrown
diff
./net/sunrpc/svcauth_unix.c~current~./net/sunrpc/svcauth_unix.cnet/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +1
-0@@ -104,6 +104,7 @@ void ip_map_put(struct cache_head *item,if (test_bit (CACHE_VALID , &item->flags) && !test_bit (CACHE_NEGATIVE , &item->flags))auth_domain_put (&im->m_client->h); +kfree (im->m_class);kfree (im); } }
This is giving me oopses. Fix follows.--b.
Since ip_map->m_class is now freed with kfree() when ip_map is destroyed, we can't assign the static string "nfsd" to it.
---
linux-2.6.9-rc1-bfields/net/sunrpc/svcauth_unix.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~svcauth_ip_map_class_allocation +2 -1
@@ -306,10 +306,11 @@ struct auth_domain *auth_unix_lookup(strstruct ip_map key, *ipm;struct auth_domain *rv; - key.m_class ="nfsd" ; + key.m_class =strdup ("nfsd" ); key.m_addr = addr; ipm =ip_map_lookup (&key,0 ); +kfree (key.m_class);if (!ipm)return NULL ;
_
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 2 of 4] Minor memory leak fix.
Quoted 15 lines · bfields
net/sunrpc/svcauth_unix.c void ip_map_put(struct cache_head *item, · line 110
Quoted 11 lines · NeilBrown
diff
./net/sunrpc/svcauth_unix.c~current~./net/sunrpc/svcauth_unix.cnet/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +1
-0@@ -104,6 +104,7 @@ void ip_map_put(struct cache_head *item,if (test_bit (CACHE_VALID , &item->flags) && !test_bit (CACHE_NEGATIVE , &item->flags))auth_domain_put (&im->m_client->h); +kfree (im->m_class);kfree (im); } }This is giving me oopses. Fix follows.--b.
Quoted 2 lines
Since
ip_map->m_classis now freed withkfree()whenip_mapis destroyed, we can't assign the static string "nfsd" to it.
Oops; forgot to check return value from kmalloc, and missed the same problem in two other spots. Incremental patch against the previous fix.
---
linux-2.6.9-rc1-bfields/net/sunrpc/svcauth_unix.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~svcauth_ip_map_class_allocation2 +10 -2
@@ -307,6 +307,8 @@ struct auth_domain *auth_unix_lookup(strstruct auth_domain *rv; key.m_class =strdup ("nfsd" ); +if (!key.m_class) +return NULL ; key.m_addr = addr; ipm =ip_map_lookup (&key,0 );
@@ -369,10 +371,13 @@ svcauth_null_accept(struct svc_rqst *rqssvc_putu32 (resv,RPC_AUTH_NULL );svc_putu32 (resv,0 ); - key.m_class = rqstp->rq_server->sv_program->pg_class; + key.m_class =strdup (rqstp->rq_server->sv_program->pg_class); +if (!key.m_class) +return SVC_DROP ; key.m_addr = rqstp->rq_addr.sin_addr; ipm =ip_map_lookup (&key,0 ); +kfree (key.m_class); rqstp->rq_client =NULL ;
@@ -465,11 +470,14 @@ svcauth_unix_accept(struct svc_rqst *rqs } - key.m_class = rqstp->rq_server->sv_program->pg_class; + key.m_class =strdup (rqstp->rq_server->sv_program->pg_class); +if (!key.m_class) +return SVC_DROP ; key.m_addr = rqstp->rq_addr.sin_addr; ipm =ip_map_lookup (&key,0 ); +kfree (key.m_class);if (ipm)switch (cache_check (&ip_map_cache, &ipm->h, &rqstp->rq_chandle)) {
_
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 2 of 4] Minor memory leak fix.
Quoted 16 lines · On Tuesday August 24, [email protected] wrote:
Quoted 15 lines · bfields
net/sunrpc/svcauth_unix.c void ip_map_put(struct cache_head *item, · line 110
Quoted 11 lines · NeilBrown
diff
./net/sunrpc/svcauth_unix.c~current~./net/sunrpc/svcauth_unix.cnet/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +1
-0@@ -104,6 +104,7 @@ void ip_map_put(struct cache_head *item,if (test_bit (CACHE_VALID , &item->flags) && !test_bit (CACHE_NEGATIVE , &item->flags))auth_domain_put (&im->m_client->h); +kfree (im->m_class);kfree (im); } }This is giving me oopses. Fix follows.--b.
Quoted 6 lines
Quoted 2 lines
Since
ip_map->m_classis now freed withkfree()whenip_mapis destroyed, we can't assign the static string "nfsd" to it.Oops; forgot to check return value from kmalloc, and missed the same problem in two other spots. Incremental patch against the previous fix.
Thanks :-(
It becomes rather horrible with all those tests for kmalloc failure doesn't it.
How about we just decide that fixed-length string buffers are OK (as the reality is that any value other than "nfsd" is extremely unlikely), and use the following instead.
This is against 2.6.8.1-mm4 without Bruce's patch, but is not an official submission yet as I have actually tested it yet. (should do soon).
NeilBrown
### Diffstat output
./net/sunrpc/svcauth_unix.c | 25 ++++++++++--------------- 1 files changed, 10 insertions(+), 15 deletions(-)
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +10 -15
@@ -90,7 +90,7 @@ static void svcauth_unix_domain_release(struct ip_map {struct cache_head h; -char *m_class;/* e.g. "nfsd" */ +char m_class[8 ];/* e.g. "nfsd" */ struct in_addr m_addr;struct unix_domain *m_client;int m_add_change;
@@ -104,7 +104,6 @@ void ip_map_put(struct cache_head *item,if (test_bit (CACHE_VALID , &item->flags) && !test_bit (CACHE_NEGATIVE , &item->flags))auth_domain_put (&im->m_client->h); -kfree (im->m_class);kfree (im); } }
@@ -121,8 +120,7 @@ static inline int ip_map_match(struct ip }static inline void ip_map_init (struct ip_map *new,struct ip_map *item) { - new->m_class = item->m_class; - item->m_class =NULL ; +strcpy (new->m_class, item->m_class); new->m_addr.s_addr = item->m_addr.s_addr; }static inline void ip_map_update (struct ip_map *new,struct ip_map *item)
@@ -171,6 +169,8 @@ static int ip_map_parse(struct cache_det/* class */ len =qword_get (&mesg, class,50 );if (len <=0 )return -EINVAL ; +if (len >=sizeof (ipm.m_class)) +return -EINVAL ;/* ip address */ len =qword_get (&mesg, buf,50 );
@@ -194,9 +194,7 @@ static int ip_map_parse(struct cache_det }else dom =NULL ; - ipm.m_class =strdup (class); -if (ipm.m_class ==NULL ) -return -ENOMEM ; +strcpy (ipm.m_class, class); ipm.m_addr.s_addr =htonl ((((((b1<<8 )|b2)<<8 )|b3)<<8 )|b4); ipm.h.flags =0 ;
@@ -212,7 +210,6 @@ static int ip_map_parse(struct cache_detip_map_put (&ipmp->h, &ip_map_cache);if (dom)auth_domain_put (dom); -if (ipm.m_class)kfree (ipm.m_class);if (!ipmp)return -ENOMEM ;cache_flush ();
@@ -272,9 +269,7 @@ int auth_unix_add_addr(struct in_addr adif (dom->flavour !=RPC_AUTH_UNIX )return -EINVAL ; udom = container_of(dom, struct unix_domain, h); - ip.m_class =strdup ("nfsd" ); -if (!ip.m_class) -return -ENOMEM ; +strcpy (ip.m_class,"nfsd" ); ip.m_addr = addr; ip.m_client = udom; ip.m_add_change = udom->addr_changes+1 ;
@@ -282,7 +277,7 @@ int auth_unix_add_addr(struct in_addr ad ip.h.expiry_time =NEVER ; ipmp =ip_map_lookup (&ip,1 ); -if (ip.m_class)kfree (ip.m_class); +if (ipmp) {ip_map_put (&ipmp->h, &ip_map_cache);return 0 ;
@@ -306,7 +301,7 @@ struct auth_domain *auth_unix_lookup(strstruct ip_map key, *ipm;struct auth_domain *rv; - key.m_class ="nfsd" ; +strcpy (key.m_class,"nfsd" ); key.m_addr = addr; ipm =ip_map_lookup (&key,0 );
@@ -368,7 +363,7 @@ svcauth_null_accept(struct svc_rqst *rqssvc_putu32 (resv,RPC_AUTH_NULL );svc_putu32 (resv,0 ); - key.m_class = rqstp->rq_server->sv_program->pg_class; +strcpy (key.m_class, rqstp->rq_server->sv_program->pg_class); key.m_addr = rqstp->rq_addr.sin_addr; ipm =ip_map_lookup (&key,0 );
@@ -464,7 +459,7 @@ svcauth_unix_accept(struct svc_rqst *rqs } - key.m_class = rqstp->rq_server->sv_program->pg_class; +strcpy (key.m_class, rqstp->rq_server->sv_program->pg_class); key.m_addr = rqstp->rq_addr.sin_addr;
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 2 of 4] Minor memory leak fix.
P=E5 ty , 24/08/2004 klokka 21:54, skreiv Neil Brown:
Quoted 3 lines
How about we just decide that fixed-length string buffers are OK (as the reality is that any value other than "nfsd" is extremely unlikely), and use the following instead.
Note that this whole "domain" checking code needs to be moved out of the generic AUTH_SYS server code ASAP anyway. As it stands, it is entirely nfsd specific, and really belongs in fs/nfsd.
It is already a nuisance in the case of the lockd client callbacks (i.e. the "GRANTED" and "NOTIFY" RPC functions). It would have broken the NFSv4 client delegation callbacks too if I hadn't written an ad-hoc workaround.
In both these cases, we want to authenticate against a known list of kernel objects rather than do upcalls to userland.
Cheers,
Trond
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Re: [PATCH kNFSd 2 of 4] Minor memory leak fix.
In reply to Neil BrownQuoted 3 lines · Neil Brown
How about we just decide that fixed-length string buffers are OK (as the reality is that any value other than "nfsd" is extremely unlikely), and use the following instead.
Sure.
Quoted 3 lines
This is against 2.6.8.1-mm4 without Bruce's patch, but is not an official submission yet as I have actually tested it yet. (should do soon).
OK, I've now reviewed and tested it.
I get oopses on 2.6.9-rc1 within half an hour of mounting (I'm surprised noone else is complaining; am I doing something unusual?), so I think we should apply this sooner rather than later.
Though Trond is right that, this out of the way, we need to stop doing the ip mapping on every rpc request.
--Bruce Fields
How about we just decide that fixed-length string buffers are OK (as the reality is that any value other than "nfsd" is extremely unlikely), and use the following instead.
Quoted 1 line
From Neil Brown <[email protected]>
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +10 -15
@@ -90,7 +90,7 @@ static void svcauth_unix_domain_release(struct ip_map {struct cache_head h; -char *m_class;/* e.g. "nfsd" */ +char m_class[8 ];/* e.g. "nfsd" */ struct in_addr m_addr;struct unix_domain *m_client;int m_add_change;
@@ -104,7 +104,6 @@ void ip_map_put(struct cache_head *item,if (test_bit (CACHE_VALID , &item->flags) && !test_bit (CACHE_NEGATIVE , &item->flags))auth_domain_put (&im->m_client->h); -kfree (im->m_class);kfree (im); } }
@@ -121,8 +120,7 @@ static inline int ip_map_match(struct ip }static inline void ip_map_init (struct ip_map *new,struct ip_map *item) { - new->m_class = item->m_class; - item->m_class =NULL ; +strcpy (new->m_class, item->m_class); new->m_addr.s_addr = item->m_addr.s_addr; }static inline void ip_map_update (struct ip_map *new,struct ip_map *item)
@@ -171,6 +169,8 @@ static int ip_map_parse(struct cache_det/* class */ len =qword_get (&mesg, class,50 );if (len <=0 )return -EINVAL ; +if (len >=sizeof (ipm.m_class)) +return -EINVAL ;/* ip address */ len =qword_get (&mesg, buf,50 );
@@ -194,9 +194,7 @@ static int ip_map_parse(struct cache_det }else dom =NULL ; - ipm.m_class =strdup (class); -if (ipm.m_class ==NULL ) -return -ENOMEM ; +strcpy (ipm.m_class, class); ipm.m_addr.s_addr =htonl ((((((b1<<8 )|b2)<<8 )|b3)<<8 )|b4); ipm.h.flags =0 ;
@@ -212,7 +210,6 @@ static int ip_map_parse(struct cache_detip_map_put (&ipmp->h, &ip_map_cache);if (dom)auth_domain_put (dom); -if (ipm.m_class)kfree (ipm.m_class);if (!ipmp)return -ENOMEM ;cache_flush ();
@@ -272,9 +269,7 @@ int auth_unix_add_addr(struct in_addr adif (dom->flavour !=RPC_AUTH_UNIX )return -EINVAL ; udom = container_of(dom, struct unix_domain, h); - ip.m_class =strdup ("nfsd" ); -if (!ip.m_class) -return -ENOMEM ; +strcpy (ip.m_class,"nfsd" ); ip.m_addr = addr; ip.m_client = udom; ip.m_add_change = udom->addr_changes+1 ;
@@ -282,7 +277,7 @@ int auth_unix_add_addr(struct in_addr ad ip.h.expiry_time =NEVER ; ipmp =ip_map_lookup (&ip,1 ); -if (ip.m_class)kfree (ip.m_class); +if (ipmp) {ip_map_put (&ipmp->h, &ip_map_cache);return 0 ;
@@ -306,7 +301,7 @@ struct auth_domain *auth_unix_lookup(strstruct ip_map key, *ipm;struct auth_domain *rv; - key.m_class ="nfsd" ; +strcpy (key.m_class,"nfsd" ); key.m_addr = addr; ipm =ip_map_lookup (&key,0 );
@@ -368,7 +363,7 @@ svcauth_null_accept(struct svc_rqst *rqssvc_putu32 (resv,RPC_AUTH_NULL );svc_putu32 (resv,0 ); - key.m_class = rqstp->rq_server->sv_program->pg_class; +strcpy (key.m_class, rqstp->rq_server->sv_program->pg_class); key.m_addr = rqstp->rq_addr.sin_addr; ipm =ip_map_lookup (&key,0 );
@@ -464,7 +459,7 @@ svcauth_unix_accept(struct svc_rqst *rqs } - key.m_class = rqstp->rq_server->sv_program->pg_class; +strcpy (key.m_class, rqstp->rq_server->sv_program->pg_class); key.m_addr = rqstp->rq_addr.sin_addr;
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs