Commit 34e9a63b authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] knfsd: ratelimit some nfsd messages that are triggered by external 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: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d019bcf0
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <linux/lockd/bind.h> #include <linux/lockd/bind.h>
#define NFSDDBG_FACILITY NFSDDBG_EXPORT #define NFSDDBG_FACILITY NFSDDBG_EXPORT
#define NFSD_PARANOIA 1
typedef struct auth_domain svc_client; typedef struct auth_domain svc_client;
typedef struct svc_export svc_export; typedef struct svc_export svc_export;
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include <linux/nfsd/nfsd.h> #include <linux/nfsd/nfsd.h>
#define NFSDDBG_FACILITY NFSDDBG_FH #define NFSDDBG_FACILITY NFSDDBG_FH
#define NFSD_PARANOIA 1
/* #define NFSD_DEBUG_VERBOSE 1 */
static int nfsd_nr_verified; static int nfsd_nr_verified;
...@@ -230,13 +228,12 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) ...@@ -230,13 +228,12 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
error = nfserrno(PTR_ERR(dentry)); error = nfserrno(PTR_ERR(dentry));
goto out; goto out;
} }
#ifdef NFSD_PARANOIA
if (S_ISDIR(dentry->d_inode->i_mode) && if (S_ISDIR(dentry->d_inode->i_mode) &&
(dentry->d_flags & DCACHE_DISCONNECTED)) { (dentry->d_flags & DCACHE_DISCONNECTED)) {
printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n", printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",
dentry->d_parent->d_name.name, dentry->d_name.name); dentry->d_parent->d_name.name, dentry->d_name.name);
} }
#endif
fhp->fh_dentry = dentry; fhp->fh_dentry = dentry;
fhp->fh_export = exp; fhp->fh_export = exp;
...@@ -267,12 +264,13 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) ...@@ -267,12 +264,13 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
/* Finally, check access permissions. */ /* Finally, check access permissions. */
error = nfsd_permission(exp, dentry, access); error = nfsd_permission(exp, dentry, access);
#ifdef NFSD_PARANOIA_EXTREME
if (error) { if (error) {
printk("fh_verify: %s/%s permission failure, acc=%x, error=%d\n", dprintk("fh_verify: %s/%s permission failure, "
dentry->d_parent->d_name.name, dentry->d_name.name, access, (error >> 24)); "acc=%x, error=%d\n",
dentry->d_parent->d_name.name,
dentry->d_name.name,
access, (error >> 24));
} }
#endif
out: out:
if (exp && !IS_ERR(exp)) if (exp && !IS_ERR(exp))
exp_put(exp); exp_put(exp);
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#define NFSDDBG_FACILITY NFSDDBG_FILEOP #define NFSDDBG_FACILITY NFSDDBG_FILEOP
#define NFSD_PARANOIA
/* We must ignore files (but only files) which might have mandatory /* We must ignore files (but only files) which might have mandatory
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
#define RPCDBG_FACILITY RPCDBG_SVCDSP #define RPCDBG_FACILITY RPCDBG_SVCDSP
#define RPC_PARANOIA 1
/* /*
* Mode for mapping cpus to pools. * Mode for mapping cpus to pools.
...@@ -872,15 +871,15 @@ svc_process(struct svc_rqst *rqstp) ...@@ -872,15 +871,15 @@ svc_process(struct svc_rqst *rqstp)
return 0; return 0;
err_short_len: err_short_len:
#ifdef RPC_PARANOIA if (net_ratelimit())
printk("svc: short len %Zd, dropping request\n", argv->iov_len); printk("svc: short len %Zd, dropping request\n", argv->iov_len);
#endif
goto dropit; /* drop request */ goto dropit; /* drop request */
err_bad_dir: err_bad_dir:
#ifdef RPC_PARANOIA if (net_ratelimit())
printk("svc: bad direction %d, dropping request\n", dir); printk("svc: bad direction %d, dropping request\n", dir);
#endif
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
goto dropit; /* drop request */ goto dropit; /* drop request */
...@@ -909,10 +908,10 @@ svc_process(struct svc_rqst *rqstp) ...@@ -909,10 +908,10 @@ svc_process(struct svc_rqst *rqstp)
goto sendit; goto sendit;
err_bad_vers: err_bad_vers:
#ifdef RPC_PARANOIA if (net_ratelimit())
printk("svc: unknown version (%d for prog %d, %s)\n", printk("svc: unknown version (%d for prog %d, %s)\n",
vers, prog, progp->pg_name); vers, prog, progp->pg_name);
#endif
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putnl(resv, RPC_PROG_MISMATCH); svc_putnl(resv, RPC_PROG_MISMATCH);
svc_putnl(resv, progp->pg_lovers); svc_putnl(resv, progp->pg_lovers);
...@@ -920,17 +919,17 @@ svc_process(struct svc_rqst *rqstp) ...@@ -920,17 +919,17 @@ svc_process(struct svc_rqst *rqstp)
goto sendit; goto sendit;
err_bad_proc: err_bad_proc:
#ifdef RPC_PARANOIA if (net_ratelimit())
printk("svc: unknown procedure (%d)\n", proc); printk("svc: unknown procedure (%d)\n", proc);
#endif
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putnl(resv, RPC_PROC_UNAVAIL); svc_putnl(resv, RPC_PROC_UNAVAIL);
goto sendit; goto sendit;
err_garbage: err_garbage:
#ifdef RPC_PARANOIA if (net_ratelimit())
printk("svc: failed to decode args\n"); printk("svc: failed to decode args\n");
#endif
rpc_stat = rpc_garbage_args; rpc_stat = rpc_garbage_args;
err_bad: err_bad:
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
......
...@@ -1062,14 +1062,18 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -1062,14 +1062,18 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
* bit set in the fragment length header. * bit set in the fragment length header.
* But apparently no known nfs clients send fragmented * But apparently no known nfs clients send fragmented
* records. */ * records. */
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx (non-terminal)\n", if (net_ratelimit())
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx"
" (non-terminal)\n",
(unsigned long) svsk->sk_reclen); (unsigned long) svsk->sk_reclen);
goto err_delete; goto err_delete;
} }
svsk->sk_reclen &= 0x7fffffff; svsk->sk_reclen &= 0x7fffffff;
dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen); dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen);
if (svsk->sk_reclen > serv->sv_max_mesg) { if (svsk->sk_reclen > serv->sv_max_mesg) {
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx (large)\n", if (net_ratelimit())
printk(KERN_NOTICE "RPC: bad TCP reclen 0x%08lx"
" (large)\n",
(unsigned long) svsk->sk_reclen); (unsigned long) svsk->sk_reclen);
goto err_delete; goto err_delete;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment