2004-10-03 18:04:35

by Ed Schouten

[permalink] [raw]
Subject: [Patch] nfsd: Insecure port warning shows decimal IPv4 address

Hi guys,

Made a quick patch that changes dmesg(8) output to show IPv4 addresses in
decimal form instead of hexadecimal when you receive an insecure port
warning.
---

nfsfh.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

--- linux-2.6.9-rc3/fs/nfsd/nfsfh.c 2004-09-30 05:04:26.000000000 +0200
+++ linux-2.6.9-rc3-xbox/fs/nfsd/nfsfh.c 2004-10-03 19:29:39.711659000 +0200
@@ -153,8 +153,11 @@
error = nfserr_perm;
if (!rqstp->rq_secure && EX_SECURE(exp)) {
printk(KERN_WARNING
- "nfsd: request from insecure port (%08x:%d)!\n",
- ntohl(rqstp->rq_addr.sin_addr.s_addr),
+ "nfsd: request from insecure port (%d.%d.%d.%d:%d)!\n",
+ (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr) >> 24),
+ (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr) >> 16),
+ (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr) >> 8),
+ (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr)),
ntohs(rqstp->rq_addr.sin_port));
goto out;
}


2004-10-03 19:35:23

by Andrew Morton

[permalink] [raw]
Subject: Re: [Patch] nfsd: Insecure port warning shows decimal IPv4 address

"Ed Schouten" <[email protected]> wrote:
>
> Made a quick patch that changes dmesg(8) output to show IPv4 addresses in
> decimal form instead of hexadecimal when you receive an insecure port
> warning.
> ---
>
> nfsfh.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> --- linux-2.6.9-rc3/fs/nfsd/nfsfh.c 2004-09-30 05:04:26.000000000 +0200
> +++ linux-2.6.9-rc3-xbox/fs/nfsd/nfsfh.c 2004-10-03 19:29:39.711659000 +0200
> @@ -153,8 +153,11 @@
> error = nfserr_perm;
> if (!rqstp->rq_secure && EX_SECURE(exp)) {
> printk(KERN_WARNING
> - "nfsd: request from insecure port (%08x:%d)!\n",
> - ntohl(rqstp->rq_addr.sin_addr.s_addr),
> + "nfsd: request from insecure port (%d.%d.%d.%d:%d)!\n",
> + (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr) >> 24),
> + (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr) >> 16),
> + (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr) >> 8),
> + (unsigned char)(ntohl(rqstp->rq_addr.sin_addr.s_addr)),
> ntohs(rqstp->rq_addr.sin_port));
> goto out;
> }

There's a NIPQUAD macro to make this a bit tidier.

2004-10-03 20:17:08

by Ed Schouten

[permalink] [raw]
Subject: Re: [Patch] nfsd: Insecure port warning shows decimal IPv4 address

On Sun, October 3, 2004 9:32 pm, Andrew Morton said:
> There's a NIPQUAD macro to make this a bit tidier.

Yes, I heard that 3 minutes after I mailed this patch to you guys ;-) I'll
take a look at it tomorrow.

Yours,
--
Ed Schouten <[email protected]>
Website: http://g-rave.nl/
GnuPG key: 0xD6A1AF3E

2004-10-03 22:49:32

by Ed Schouten

[permalink] [raw]
Subject: Re: [Patch] nfsd: Insecure port warning shows decimal IPv4 address

On Sun, October 3, 2004 9:12 pm, Joe Perches said:
> There may be a couple of places where this could be done in fs/nfsd

True. After a quick look, I found another spot in nfsproc.c. Here's a new
patch, using the NIPQUAD macro.
---

nfsfh.c | 4 ++--
nfsproc.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff -u -r linux-2.6.9-rc3/fs/nfsd/nfsfh.c
linux-2.6.9-rc3-xbox/fs/nfsd/nfsfh.c
--- linux-2.6.9-rc3/fs/nfsd/nfsfh.c 2004-09-30 05:04:26.000000000 +0200
+++ linux-2.6.9-rc3-xbox/fs/nfsd/nfsfh.c 2004-10-04 00:45:16.926659000 +0200
@@ -153,8 +153,8 @@
error = nfserr_perm;
if (!rqstp->rq_secure && EX_SECURE(exp)) {
printk(KERN_WARNING
- "nfsd: request from insecure port (%08x:%d)!\n",
- ntohl(rqstp->rq_addr.sin_addr.s_addr),
+ "nfsd: request from insecure port (%u.%u.%u.%u:%d)!\n",
+ NIPQUAD(rqstp->rq_addr.sin_addr.s_addr),
ntohs(rqstp->rq_addr.sin_port));
goto out;
}
diff -u -r linux-2.6.9-rc3/fs/nfsd/nfsproc.c
linux-2.6.9-rc3-xbox/fs/nfsd/nfsproc.c
--- linux-2.6.9-rc3/fs/nfsd/nfsproc.c 2004-09-30 05:04:25.000000000 +0200
+++ linux-2.6.9-rc3-xbox/fs/nfsd/nfsproc.c 2004-10-04 00:44:58.225659000
+0200
@@ -128,8 +128,8 @@

if (NFSSVC_MAXBLKSIZE < argp->count) {
printk(KERN_NOTICE
- "oversized read request from %08x:%d (%d bytes)\n",
- ntohl(rqstp->rq_addr.sin_addr.s_addr),
+ "oversized read request from %u.%u.%u.%u:%d (%d bytes)\n",
+ NIPQUAD(rqstp->rq_addr.sin_addr.s_addr),
ntohs(rqstp->rq_addr.sin_port),
argp->count);
argp->count = NFSSVC_MAXBLKSIZE;