From: Roel Kluin <roel.kluin@gmail.com>
To: christine.caulfield@googlemail.com
Cc: linux-decnet-user@lists.sourceforge.net, netdev@vger.kernel.org
Subject: [PATCH] decnet: incorrect optlen size
Date: Thu, 29 Jan 2009 09:21:15 +0100 [thread overview]
Message-ID: <498166FB.5030104@gmail.com> (raw)
Several functions with something like this occur:
int sock_set_foo(int optlen, ...)
{
struct food foo;
if (optlen < sizeof(foo))
return -EINVAL;
if (copy_from_user(&foo, optval, sizeof(foo)))
return -EFAULT;
...
}
see for instance:
grep -C5 -E -R -n "copy_from_user\(&([a-zA-Z0-9]*), optval, sizeof\(\1\)\)" net
but in __dn_setsockopt, below, the checks are slightly different.
Should maybe the changes below be apllied?
-------------->8----------------8<-----------------------
fix size checks before copy_from_user
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index cf0e184..45b9199 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -1359,10 +1359,10 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us
if (optlen && !optval)
return -EINVAL;
- if (optlen > sizeof(u))
+ if (optlen < sizeof(u))
return -EINVAL;
- if (copy_from_user(&u, optval, optlen))
+ if (copy_from_user(&u, optval, sizeof(u)))
return -EFAULT;
switch(optname) {
next reply other threads:[~2009-01-29 8:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-29 8:21 Roel Kluin [this message]
2009-01-29 8:58 ` [PATCH] decnet: incorrect optlen size steve
2009-01-30 1:15 ` 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=498166FB.5030104@gmail.com \
--to=roel.kluin@gmail.com \
--cc=christine.caulfield@googlemail.com \
--cc=linux-decnet-user@lists.sourceforge.net \
--cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.