netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: davem@davemloft.net
Cc: yoshfuji@linux-ipv6.org, netdev@vger.kernel.org
Subject: IPV6: make ipv6_getsockopt_sticky honor user's buffer size
Date: Wed, 7 Mar 2007 23:10:48 -0800	[thread overview]
Message-ID: <20070308071048.GD10574@sequoia.sous-sol.org> (raw)

Make sure not to copy_to_user more than user's buffer can handle (we
already checked the min, just use it) in ipv6_getsockopt_sticky.  And
while there, minor whitespace cleanup now that ipv6_getsockopt_sticky
call can nicely fit on one line.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4e0561a..9396551 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -805,7 +805,7 @@ static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
 	hdr = opt->hopopt;
 
 	len = min_t(int, len, ipv6_optlen(hdr));
-	if (copy_to_user(optval, hdr, ipv6_optlen(hdr)))
+	if (copy_to_user(optval, hdr, len))
 		return -EFAULT;
 	return len;
 }
@@ -944,8 +944,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 	{
 
 		lock_sock(sk);
-		len = ipv6_getsockopt_sticky(sk, np->opt,
-					     optval, len);
+		len = ipv6_getsockopt_sticky(sk, np->opt, optval, len);
 		release_sock(sk);
 		return put_user(len, optlen);
 	}

             reply	other threads:[~2007-03-08  7:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-08  7:10 Chris Wright [this message]
2007-03-08 22:38 ` IPV6: make ipv6_getsockopt_sticky honor user's buffer size David Miller
2007-03-09  0:49   ` YOSHIFUJI Hideaki / 吉藤英明
2007-03-09  1:11     ` David Miller

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=20070308071048.GD10574@sequoia.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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;
as well as URLs for NNTP newsgroup(s).