Skip to content

Commit

Permalink
[PATCH] knfsd: ratelimit some nfsd messages that are triggered by ext…
Browse files Browse the repository at this point in the history
…ernal events

Also remove {NFSD,RPC}_PARANOIA as having the defines doesn't really add
anything.

The printks covered by RPC_PARANOIA were triggered by badly formatted
packets and so should be ratelimited.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Jan 30, 2007
1 parent d019bcf commit 34e9a63
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
1 change: 0 additions & 1 deletion fs/nfsd/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <linux/lockd/bind.h>

#define NFSDDBG_FACILITY NFSDDBG_EXPORT
#define NFSD_PARANOIA 1

typedef struct auth_domain svc_client;
typedef struct svc_export svc_export;
Expand Down
14 changes: 6 additions & 8 deletions fs/nfsd/nfsfh.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <linux/nfsd/nfsd.h>

#define NFSDDBG_FACILITY NFSDDBG_FH
#define NFSD_PARANOIA 1
/* #define NFSD_DEBUG_VERBOSE 1 */


static int nfsd_nr_verified;
Expand Down Expand Up @@ -230,13 +228,12 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
error = nfserrno(PTR_ERR(dentry));
goto out;
}
#ifdef NFSD_PARANOIA

if (S_ISDIR(dentry->d_inode->i_mode) &&
(dentry->d_flags & DCACHE_DISCONNECTED)) {
printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",
dentry->d_parent->d_name.name, dentry->d_name.name);
}
#endif

fhp->fh_dentry = dentry;
fhp->fh_export = exp;
Expand Down Expand Up @@ -267,12 +264,13 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
/* Finally, check access permissions. */
error = nfsd_permission(exp, dentry, access);

#ifdef NFSD_PARANOIA_EXTREME
if (error) {
printk("fh_verify: %s/%s permission failure, acc=%x, error=%d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, access, (error >> 24));
dprintk("fh_verify: %s/%s permission failure, "
"acc=%x, error=%d\n",
dentry->d_parent->d_name.name,
dentry->d_name.name,
access, (error >> 24));
}
#endif
out:
if (exp && !IS_ERR(exp))
exp_put(exp);
Expand Down
1 change: 0 additions & 1 deletion fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#include <asm/uaccess.h>

#define NFSDDBG_FACILITY NFSDDBG_FILEOP
#define NFSD_PARANOIA


/* We must ignore files (but only files) which might have mandatory
Expand Down
33 changes: 16 additions & 17 deletions net/sunrpc/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <linux/sunrpc/clnt.h>

#define RPCDBG_FACILITY RPCDBG_SVCDSP
#define RPC_PARANOIA 1

/*
* Mode for mapping cpus to pools.
Expand Down Expand Up @@ -872,15 +871,15 @@ svc_process(struct svc_rqst *rqstp)
return 0;

err_short_len:
#ifdef RPC_PARANOIA
printk("svc: short len %Zd, dropping request\n", argv->iov_len);
#endif
if (net_ratelimit())
printk("svc: short len %Zd, dropping request\n", argv->iov_len);

goto dropit; /* drop request */

err_bad_dir:
#ifdef RPC_PARANOIA
printk("svc: bad direction %d, dropping request\n", dir);
#endif
if (net_ratelimit())
printk("svc: bad direction %d, dropping request\n", dir);

serv->sv_stats->rpcbadfmt++;
goto dropit; /* drop request */

Expand Down Expand Up @@ -909,28 +908,28 @@ svc_process(struct svc_rqst *rqstp)
goto sendit;

err_bad_vers:
#ifdef RPC_PARANOIA
printk("svc: unknown version (%d for prog %d, %s)\n",
vers, prog, progp->pg_name);
#endif
if (net_ratelimit())
printk("svc: unknown version (%d for prog %d, %s)\n",
vers, prog, progp->pg_name);

serv->sv_stats->rpcbadfmt++;
svc_putnl(resv, RPC_PROG_MISMATCH);
svc_putnl(resv, progp->pg_lovers);
svc_putnl(resv, progp->pg_hivers);
goto sendit;

err_bad_proc:
#ifdef RPC_PARANOIA
printk("svc: unknown procedure (%d)\n", proc);
#endif
if (net_ratelimit())
printk("svc: unknown procedure (%d)\n", proc);

serv->sv_stats->rpcbadfmt++;
svc_putnl(resv, RPC_PROC_UNAVAIL);
goto sendit;

err_garbage:
#ifdef RPC_PARANOIA
printk("svc: failed to decode args\n");
#endif
if (net_ratelimit())
printk("svc: failed to decode args\n");

rpc_stat = rpc_garbage_args;
err_bad:
serv->sv_stats->rpcbadfmt++;
Expand Down
12 changes: 8 additions & 4 deletions net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1062,15 +1062,19 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
* bit set in the fragment length header.
* But apparently no known nfs clients send fragmented
* records. */
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx (non-terminal)\n",
(unsigned long) svsk->sk_reclen);
if (net_ratelimit())
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx"
" (non-terminal)\n",
(unsigned long) svsk->sk_reclen);
goto err_delete;
}
svsk->sk_reclen &= 0x7fffffff;
dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen);
if (svsk->sk_reclen > serv->sv_max_mesg) {
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx (large)\n",
(unsigned long) svsk->sk_reclen);
if (net_ratelimit())
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx"
" (large)\n",
(unsigned long) svsk->sk_reclen);
goto err_delete;
}
}
Expand Down

0 comments on commit 34e9a63

Please sign in to comment.