From: Assar <assar@permabit.com>
To: Valdis.Kletnieks@vt.edu
Cc: linux-kernel@vger.kernel.org, marcelo.tosatti@cyclades.com
Subject: Re: [PATCH] nfs client, kernel 2.4.31: readlink result overflow
Date: 12 Sep 2005 16:41:19 -0400 [thread overview]
Message-ID: <788xy2qas0.fsf@sober-counsel.permabit.com> (raw)
In-Reply-To: <200509122001.j8CK1kpW028651@turing-police.cc.vt.edu>
Valdis.Kletnieks@vt.edu writes:
> > To my reading, the 2.6.13 code does not copy the 4 bytes of length to
> > rcvbuf.
>
> Hmm... it still does this:
> kaddr[len+rcvbuf->page_base] = '\0';
> which still has a possible off-by-one? (Was that why you have -1 -4?)
The check is different. 2.6.13 is using ">=" instead of ">", so hence
I think that's fine.
> sizeof(actual_var) is even better, as that way it's clear what you're allowing
> space for.
diff -u linux-2.4.31.orig/fs/nfs/nfs2xdr.c linux-2.4.31/fs/nfs/nfs2xdr.c
--- linux-2.4.31.orig/fs/nfs/nfs2xdr.c 2002-11-28 18:53:15.000000000 -0500
+++ linux-2.4.31/fs/nfs/nfs2xdr.c 2005-09-12 16:12:30.000000000 -0400
@@ -571,8 +571,8 @@
strlen = (u32*)kmap(rcvbuf->pages[0]);
/* Convert length of symlink */
len = ntohl(*strlen);
- if (len > rcvbuf->page_len)
- len = rcvbuf->page_len;
+ if (len > rcvbuf->page_len - sizeof(*strlen) - 1)
+ len = rcvbuf->page_len - sizeof(*strlen) - 1;
*strlen = len;
/* NULL terminate the string we got */
string = (char *)(strlen + 1);
diff -u linux-2.4.31.orig/fs/nfs/nfs3xdr.c linux-2.4.31/fs/nfs/nfs3xdr.c
--- linux-2.4.31.orig/fs/nfs/nfs3xdr.c 2003-11-28 13:26:21.000000000 -0500
+++ linux-2.4.31/fs/nfs/nfs3xdr.c 2005-09-12 16:12:29.000000000 -0400
@@ -759,8 +759,8 @@
strlen = (u32*)kmap(rcvbuf->pages[0]);
/* Convert length of symlink */
len = ntohl(*strlen);
- if (len > rcvbuf->page_len)
- len = rcvbuf->page_len;
+ if (len > rcvbuf->page_len - sizeof(*strlen) - 1)
+ len = rcvbuf->page_len - sizeof(*strlen) - 1;
*strlen = len;
/* NULL terminate the string we got */
string = (char *)(strlen + 1);
next prev parent reply other threads:[~2005-09-12 20:41 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-12 13:26 Assar
2005-09-12 18:46 ` Valdis.Kletnieks
2005-09-12 19:37 ` Assar
2005-09-12 20:01 ` Valdis.Kletnieks
2005-09-12 20:41 ` Assar [this message]
2005-09-12 20:53 ` Valdis.Kletnieks
2005-09-13 18:39 ` Marcelo Tosatti
2005-09-13 18:52 ` Assar
2005-09-13 19:35 ` Marcelo Tosatti
2005-09-13 20:01 ` Assar
2005-09-14 18:55 ` Peter Staubach
2005-09-14 19:41 ` Assar
2005-09-14 20:11 ` Peter Staubach
2005-09-14 22:20 ` Assar
2005-09-14 22:26 ` Peter Staubach
2005-09-14 20:15 ` Peter Staubach
2005-09-14 20:26 ` Assar
2005-09-14 20:27 ` Peter Staubach
2005-09-14 20:59 ` Assar
2005-09-13 20:36 ` Peter Staubach
2005-09-13 20:55 ` Assar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=788xy2qas0.fsf@sober-counsel.permabit.com \
--to=assar@permabit.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®