mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "YOSHIFUJI Hideaki / 吉藤英明" <yoshfuji@linux-ipv6.org>
To: hpplinuxml@0xdef.net, dccp@vger.kernel.org, acme@ghostprotocols.net
Cc: linux-kernel@vger.kernel.org, yoshfuji@linux-ipv6.org
Subject: Re: [PATCH] dccp sizeof correction
Date: Tue, 22 Nov 2005 19:09:30 +0900 (JST)	[thread overview]
Message-ID: <20051122.190930.02663054.yoshfuji@linux-ipv6.org> (raw)
In-Reply-To: <20051122105130.GA25078@0xdef.net>

In article <20051122105130.GA25078@0xdef.net> (at Tue, 22 Nov 2005 11:51:31 +0100), Hagen Paul Pfeifer <hpplinuxml@0xdef.net> says:

> Setsockopt in DCCP make the assumption that sizeof(int) is the same as
> sizeof(u32), that isn't correct at all. ;)

The patch is not correct.
I think we should use int for DCCP_SOCKOPT_SERVICE.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 8a6b2a9..f4299db 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -211,14 +211,21 @@ int dccp_ioctl(struct sock *sk, int cmd,
 	return -ENOIOCTLCMD;
 }
 
-static int dccp_setsockopt_service(struct sock *sk, const u32 service,
+static int dccp_setsockopt_service(struct sock *sk,
 				   char __user *optval, int optlen)
 {
+	u32 service;
 	struct dccp_sock *dp = dccp_sk(sk);
 	struct dccp_service_list *sl = NULL;
 
-	if (service == DCCP_SERVICE_INVALID_VALUE || 
-	    optlen > DCCP_SERVICE_LIST_MAX_LEN * sizeof(u32))
+	if (optlen < sizeof(u32) ||
+	    optlen > DCCP_SERCICE_LISR_MAX_LEN * sizeof(u32))
+		return -EINVAL;
+
+	if (get_user(service, (u32 __user *)optval))
+		return -EFAULT;
+
+	if (service == DCCP_SERVICE_INVALID_VALUE)
 		return -EINVAL;
 
 	if (optlen > sizeof(service)) {
@@ -256,14 +263,14 @@ int dccp_setsockopt(struct sock *sk, int
 	if (level != SOL_DCCP)
 		return ip_setsockopt(sk, level, optname, optval, optlen);
 
+	if (optname == DCCP_SOCKOPT_SERVICE)
+		return dccp_setsockopt_service(sk, optval, optlen);
+
 	if (optlen < sizeof(int))
 		return -EINVAL;
 
 	if (get_user(val, (int __user *)optval))
 		return -EFAULT;
-
-	if (optname == DCCP_SOCKOPT_SERVICE)
-		return dccp_setsockopt_service(sk, val, optval, optlen);
 
 	lock_sock(sk);
 	dp = dccp_sk(sk);

-- 
YOSHIFUJI Hideaki @ USAGI Project  <yoshfuji@linux-ipv6.org>
GPG-FP  : 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-22 10:51 Hagen Paul Pfeifer
2005-11-22 10:09 ` YOSHIFUJI Hideaki / 吉藤英明 [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=20051122.190930.02663054.yoshfuji@linux-ipv6.org \
    --to=yoshfuji@linux-ipv6.org \
    --cc=acme@ghostprotocols.net \
    --cc=dccp@vger.kernel.org \
    --cc=hpplinuxml@0xdef.net \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®