mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Pascal Schmidt <der.eremit@email.de>, linux-kernel@vger.kernel.org
Subject: Re: NFS & long symlinks = stack overflow
Date: Sat, 15 May 2004 13:37:18 -0400	[thread overview]
Message-ID: <1084642637.3490.29.camel@lade.trondhjem.org> (raw)
In-Reply-To: <20040515145306.GQ17014@parcelfarce.linux.theplanet.co.uk>

On Sat, 2004-05-15 at 10:53, viro@parcelfarce.linux.theplanet.co.uk
wrote:

> Lovely...  How are other clients dealing with that?  Put a reasonable
> limit on the size and return an error if READLINK brings more than that?

Yes. The following patch (backported from the NFSv4 code) should do the
right thing...

Cheers,
  Trond

--- linux-2.6.6-rc3/fs/nfs/nfs3xdr.c.orig	2004-05-09 01:31:17.000000000 -0400
+++ linux-2.6.6-rc3/fs/nfs/nfs3xdr.c	2004-05-15 13:35:06.000000000 -0400
@@ -742,8 +742,11 @@ nfs3_xdr_readlinkres(struct rpc_rqst *re
 	strlen = (u32*)kmap_atomic(rcvbuf->pages[0], KM_USER0);
 	/* Convert length of symlink */
 	len = ntohl(*strlen);
-	if (len > rcvbuf->page_len)
-		len = rcvbuf->page_len;
+	if (len > PAGE_CACHE_SIZE - 5) {
+		printk(KERN_WARNING "nfs: server returned giant symlink!\n");
+		kunmap_atomic(strlen, KM_USER0);
+		return -EIO;
+	}
 	*strlen = len;
 	/* NULL terminate the string we got */
 	string = (char *)(strlen + 1);


  reply	other threads:[~2004-05-15 17:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1W7yE-3lZ-13@gated-at.bofh.it>
     [not found] ` <1W7S5-3Am-13@gated-at.bofh.it>
2004-05-15 14:30   ` Pascal Schmidt
2004-05-15 14:53     ` viro
2004-05-15 17:37       ` Trond Myklebust [this message]
2004-05-15 20:19         ` Oleg Drokin
2004-05-16  4:41         ` Linus Torvalds
2004-05-16  4:55           ` viro
2004-05-16 22:20             ` Trond Myklebust
2004-05-15 13:21 Oleg Drokin
2004-05-15 13:53 ` viro
2004-05-15 17:26   ` 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=1084642637.3490.29.camel@lade.trondhjem.org \
    --to=trond.myklebust@fys.uio.no \
    --cc=der.eremit@email.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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®