mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
To: Assar <assar@permabit.com>, Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Peter Staubach <staubach@redhat.com>,
	Valdis.Kletnieks@vt.edu, linux-kernel@vger.kernel.org
Subject: [PATCH] nfs client: handle long symlinks properly
Date: Thu, 22 Sep 2005 13:14:20 -0300	[thread overview]
Message-ID: <20050922161420.GC5588@dmt.cnet> (raw)


commit 87e03738fc15dc3ea4acde3a5dcb5f84b6b6152b
tree be323c0a65d7e380ad04cad1c3a80015a82056dd
parent bb52ef60b5caa8f973523eda15d3c3941f298e63
author Assar <assar@permabit.com> Wed, 14 Sep 2005 16:59:25 -0400
committer Marcelo Tosatti <marcelo@dmt.cnet> Thu, 22 Sep 2005 13:11:18 -0300

    [PATCH] nfs client: handle long symlinks properly

    In 2.4.31, the v2/3 nfs readlink accepts too long symlinks.
    I have tested this by having a server return long symlinks.

diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -571,8 +571,11 @@ nfs_xdr_readlinkres(struct rpc_rqst *req
        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(u32) || len > NFS2_MAXPATHLEN) {
+               printk(KERN_WARNING "NFS: server returned giant symlink!\n");
+               kunmap(rcvbuf->pages[0]);
+               return -ENAMETOOLONG;
+        }
        *strlen = len;
        /* NULL terminate the string we got */
        string = (char *)(strlen + 1);
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -759,8 +759,11 @@ nfs3_xdr_readlinkres(struct rpc_rqst *re
        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(u32)) {
+               printk(KERN_WARNING "NFS: server returned giant symlink!\n");
+               kunmap(rcvbuf->pages[0]);
+               return -ENAMETOOLONG;
+        }
        *strlen = len;
        /* NULL terminate the string we got */
        string = (char *)(strlen + 1);


             reply	other threads:[~2005-09-22 16:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-22 16:14 Marcelo Tosatti [this message]
2005-09-22 16:33 ` Trond Myklebust
2005-09-22 16:38   ` Assar
2005-09-22 16:55     ` Trond Myklebust

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=20050922161420.GC5588@dmt.cnet \
    --to=marcelo.tosatti@cyclades.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=assar@permabit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=staubach@redhat.com \
    --cc=trond.myklebust@fys.uio.no \
    /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®