Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40532
b: refs/heads/master
c: a27b58f
h: refs/heads/master
v: v3
  • Loading branch information
Heiko Carstens authored and David S. Miller committed Oct 30, 2006
1 parent 6aa0a18 commit 275d6a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 28cd7752734563d5b0967b96a6bade7a1dc89c7f
refs/heads/master: a27b58fed90cc5654e2daf1d292cc5bc61be4dd7
17 changes: 11 additions & 6 deletions trunk/net/ipv4/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
return err;
}

static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
static int raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
{
struct iovec *iov;
u8 __user *type = NULL;
Expand All @@ -338,7 +338,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
unsigned int i;

if (!msg->msg_iov)
return;
return 0;

for (i = 0; i < msg->msg_iovlen; i++) {
iov = &msg->msg_iov[i];
Expand All @@ -360,8 +360,9 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
code = iov->iov_base;

if (type && code) {
get_user(fl->fl_icmp_type, type);
get_user(fl->fl_icmp_code, code);
if (get_user(fl->fl_icmp_type, type) ||
get_user(fl->fl_icmp_code, code))
return -EFAULT;
probed = 1;
}
break;
Expand All @@ -372,6 +373,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
if (probed)
break;
}
return 0;
}

static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
Expand Down Expand Up @@ -480,8 +482,11 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.proto = inet->hdrincl ? IPPROTO_RAW :
sk->sk_protocol,
};
if (!inet->hdrincl)
raw_probe_proto_opt(&fl, msg);
if (!inet->hdrincl) {
err = raw_probe_proto_opt(&fl, msg);
if (err)
goto done;
}

security_sk_classify_flow(sk, &fl);
err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
Expand Down
17 changes: 11 additions & 6 deletions trunk/net/ipv6/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
return err;
}

static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
{
struct iovec *iov;
u8 __user *type = NULL;
Expand All @@ -616,7 +616,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
int i;

if (!msg->msg_iov)
return;
return 0;

for (i = 0; i < msg->msg_iovlen; i++) {
iov = &msg->msg_iov[i];
Expand All @@ -638,8 +638,9 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
code = iov->iov_base;

if (type && code) {
get_user(fl->fl_icmp_type, type);
get_user(fl->fl_icmp_code, code);
if (get_user(fl->fl_icmp_type, type) ||
get_user(fl->fl_icmp_code, code))
return -EFAULT;
probed = 1;
}
break;
Expand All @@ -650,7 +651,8 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
/* check if type field is readable or not. */
if (iov->iov_len > 2 - len) {
u8 __user *p = iov->iov_base;
get_user(fl->fl_mh_type, &p[2 - len]);
if (get_user(fl->fl_mh_type, &p[2 - len]))
return -EFAULT;
probed = 1;
} else
len += iov->iov_len;
Expand All @@ -664,6 +666,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
if (probed)
break;
}
return 0;
}

static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
Expand Down Expand Up @@ -787,7 +790,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
opt = ipv6_fixup_options(&opt_space, opt);

fl.proto = proto;
rawv6_probe_proto_opt(&fl, msg);
err = rawv6_probe_proto_opt(&fl, msg);
if (err)
goto out;

ipv6_addr_copy(&fl.fl6_dst, daddr);
if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
Expand Down
5 changes: 3 additions & 2 deletions trunk/net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,9 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
return -EINVAL;
len = sizeof(int);
val = nlk->flags & NETLINK_RECV_PKTINFO ? 1 : 0;
put_user(len, optlen);
put_user(val, optval);
if (put_user(len, optlen) ||
put_user(val, optval))
return -EFAULT;
err = 0;
break;
default:
Expand Down

0 comments on commit 275d6a7

Please sign in to comment.