public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Trond Myklebust <Trond.Myklebust@netapp.com>, 549002@bugs.debian.org
Cc: linux-nfs@vger.kernel.org
Subject: Re: Bug#549002: [PATCH] nfs: Avoid overrun when copying client IP address string
Date: Mon, 05 Oct 2009 00:24:48 +0100	[thread overview]
Message-ID: <1254698688.27417.10.camel@localhost> (raw)
In-Reply-To: <1254695596.30515.75.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

On Sun, 2009-10-04 at 18:33 -0400, Trond Myklebust wrote:
> On Sun, 2009-10-04 at 14:25 +0100, Ben Hutchings wrote:
> > As seen in <http://bugs.debian.org/549002>, nfs4_init_client() can
> > overrun the source string when copying the client IP address from
> > nfs_parsed_mount_data::client_address to nfs_client::cl_ipaddr.  Since
> > these are both treated as null-terminated strings elsewhere, the copy
> > should be done with strlcpy() not memcpy().
> > 
> > Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> > ---
> > diff --git a/fs/nfs/client.c b/fs/nfs/client.c
> > index 75c9cd2..f525a2f 100644
> > --- a/fs/nfs/client.c
> > +++ b/fs/nfs/client.c
> > @@ -1073,7 +1073,7 @@ static int nfs4_init_client(struct nfs_client *clp,
> >  				      1, flags & NFS_MOUNT_NORESVPORT);
> >  	if (error < 0)
> >  		goto error;
> > -	memcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
> > +	strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
> >  
> >  	error = nfs_idmap_new(clp);
> >  	if (error < 0) {
> 
> It looks good, so I'll push it upstream. I assume the bug report also
> applies to stable@kernel.org?

This bug appears to have been present "forever", though I think it has
become a practical problem since nfs_client::cl_ipaddr was enlarged to
48 bytes in v2.6.25.  So yes, the bug and fix are applicable to every
stable series.

Ben.

-- 
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      parent reply	other threads:[~2009-10-04 23:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1254662749.2395.68.camel@localhost>
2009-10-04 22:33 ` [PATCH] nfs: Avoid overrun when copying client IP address string Trond Myklebust
     [not found]   ` <1254695596.30515.75.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-10-04 23:24     ` Ben Hutchings [this message]

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=1254698688.27417.10.camel@localhost \
    --to=ben@decadent.org.uk \
    --cc=549002@bugs.debian.org \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /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