NFSv4: NFSv4 errors in nfs4_init_client() must not leak to userland Fixes a potential Oops at mount time. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 4 ++-- fs/nfs/nfs4state.c | 9 +++++++-- include/linux/nfs_fs.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) Index: linux-2.6.11/fs/nfs/nfs4proc.c =================================================================== --- linux-2.6.11.orig/fs/nfs/nfs4proc.c +++ linux-2.6.11/fs/nfs/nfs4proc.c @@ -65,10 +65,10 @@ extern struct rpc_procinfo nfs4_procedur extern nfs4_stateid zero_stateid; /* Prevent leaks of NFSv4 errors into userland */ -static inline int nfs4_map_errors(int err) +int nfs4_map_errors(int err) { if (err < -1000) { - printk(KERN_WARNING "%s could not handle NFSv4 error %d\n", + dprintk("%s could not handle NFSv4 error %d\n", __FUNCTION__, -err); return -EIO; } Index: linux-2.6.11/include/linux/nfs_fs.h =================================================================== --- linux-2.6.11.orig/include/linux/nfs_fs.h +++ linux-2.6.11/include/linux/nfs_fs.h @@ -677,6 +677,7 @@ extern struct dentry_operations nfs4_den extern struct inode_operations nfs4_dir_inode_operations; /* nfs4proc.c */ +extern int nfs4_map_errors(int err); extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); extern int nfs4_open_reclaim(struct nfs4_state_owner *, struct nfs4_state *); Index: linux-2.6.11/fs/nfs/nfs4state.c =================================================================== --- linux-2.6.11.orig/fs/nfs/nfs4state.c +++ linux-2.6.11/fs/nfs/nfs4state.c @@ -206,7 +206,7 @@ nfs4_put_client(struct nfs4_client *clp) nfs4_free_client(clp); } -int nfs4_init_client(struct nfs4_client *clp) +static int __nfs4_init_client(struct nfs4_client *clp) { int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, nfs_callback_tcpport); if (status == 0) @@ -216,6 +216,11 @@ int nfs4_init_client(struct nfs4_client return status; } +int nfs4_init_client(struct nfs4_client *clp) +{ + return nfs4_map_errors(__nfs4_init_client(clp)); +} + u32 nfs4_alloc_lockowner_id(struct nfs4_client *clp) { @@ -859,7 +864,7 @@ restart_loop: status = nfs4_proc_renew(clp); if (status == 0 || status == -NFS4ERR_CB_PATH_DOWN) goto out; - status = nfs4_init_client(clp); + status = __nfs4_init_client(clp); if (status) goto out_error; /* Mark all delagations for reclaim */