Commit c97ddec1 authored by Stephen Hemminger's avatar Stephen Hemminger

[IPV4/IPV6]: Use size_t for size in {send,recv}msg.

parent a7984945
...@@ -23,11 +23,11 @@ extern int inet_accept(struct socket *sock, ...@@ -23,11 +23,11 @@ extern int inet_accept(struct socket *sock,
extern int inet_recvmsg(struct kiocb *iocb, extern int inet_recvmsg(struct kiocb *iocb,
struct socket *sock, struct socket *sock,
struct msghdr *ubuf, struct msghdr *ubuf,
int size, int flags); size_t size, int flags);
extern int inet_sendmsg(struct kiocb *iocb, extern int inet_sendmsg(struct kiocb *iocb,
struct socket *sock, struct socket *sock,
struct msghdr *msg, struct msghdr *msg,
int size); size_t size);
extern int inet_shutdown(struct socket *sock, int how); extern int inet_shutdown(struct socket *sock, int how);
extern unsigned int inet_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait); extern unsigned int inet_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait);
extern int inet_setsockopt(struct socket *sock, int level, extern int inet_setsockopt(struct socket *sock, int level,
......
...@@ -752,7 +752,7 @@ extern int tcp_v4_remember_stamp(struct sock *sk); ...@@ -752,7 +752,7 @@ extern int tcp_v4_remember_stamp(struct sock *sk);
extern int tcp_v4_tw_remember_stamp(struct tcp_tw_bucket *tw); extern int tcp_v4_tw_remember_stamp(struct tcp_tw_bucket *tw);
extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, int size); struct msghdr *msg, size_t size);
extern ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags); extern ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, int flags);
extern int tcp_ioctl(struct sock *sk, extern int tcp_ioctl(struct sock *sk,
...@@ -846,7 +846,7 @@ extern int tcp_setsockopt(struct sock *sk, int level, ...@@ -846,7 +846,7 @@ extern int tcp_setsockopt(struct sock *sk, int level,
extern void tcp_set_keepalive(struct sock *sk, int val); extern void tcp_set_keepalive(struct sock *sk, int val);
extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, struct msghdr *msg,
int len, int nonblock, size_t len, int nonblock,
int flags, int *addr_len); int flags, int *addr_len);
extern int tcp_listen_start(struct sock *sk); extern int tcp_listen_start(struct sock *sk);
......
...@@ -68,7 +68,7 @@ extern int udp_connect(struct sock *sk, ...@@ -68,7 +68,7 @@ extern int udp_connect(struct sock *sk,
struct sockaddr *usin, int addr_len); struct sockaddr *usin, int addr_len);
extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk, extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, int len); struct msghdr *msg, size_t len);
extern int udp_rcv(struct sk_buff *skb); extern int udp_rcv(struct sk_buff *skb);
extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg); extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
......
...@@ -731,7 +731,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -731,7 +731,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int size, int flags) size_t size, int flags)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int addr_len = 0; int addr_len = 0;
...@@ -746,7 +746,7 @@ int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, ...@@ -746,7 +746,7 @@ int inet_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int inet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int size) size_t size)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
......
...@@ -324,7 +324,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length, ...@@ -324,7 +324,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length,
} }
static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int len) size_t len)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
struct ipcm_cookie ipc; struct ipcm_cookie ipc;
...@@ -335,17 +335,6 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -335,17 +335,6 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
u8 tos; u8 tos;
int err; int err;
/* This check is ONLY to check for arithmetic overflow
on integer(!) len. Not more! Real check will be made
in ip_build_xmit --ANK
BTW socket.c -> af_*.c -> ... make multiple
invalid conversions size_t -> int. We MUST repair it f.e.
by replacing all of them with size_t and revise all
the places sort of len += sizeof(struct iphdr)
If len was ULONG_MAX-10 it would be cathastrophe --ANK
*/
err = -EMSGSIZE; err = -EMSGSIZE;
if (len < 0 || len > 0xFFFF) if (len < 0 || len > 0xFFFF)
goto out; goto out;
...@@ -523,10 +512,10 @@ out: return ret; ...@@ -523,10 +512,10 @@ out: return ret;
*/ */
int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int len, int noblock, int flags, int *addr_len) size_t len, int noblock, int flags, int *addr_len)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
int copied = 0; size_t copied = 0;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
struct sk_buff *skb; struct sk_buff *skb;
......
...@@ -1029,7 +1029,7 @@ static inline int select_size(struct sock *sk, struct tcp_opt *tp) ...@@ -1029,7 +1029,7 @@ static inline int select_size(struct sock *sk, struct tcp_opt *tp)
} }
int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int size) size_t size)
{ {
struct iovec *iov; struct iovec *iov;
struct tcp_opt *tp = tcp_sk(sk); struct tcp_opt *tp = tcp_sk(sk);
...@@ -1498,7 +1498,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, ...@@ -1498,7 +1498,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
*/ */
int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int len, int nonblock, int flags, int *addr_len) size_t len, int nonblock, int flags, int *addr_len)
{ {
struct tcp_opt *tp = tcp_sk(sk); struct tcp_opt *tp = tcp_sk(sk);
int copied = 0; int copied = 0;
......
...@@ -478,7 +478,7 @@ static unsigned short udp_check(struct udphdr *uh, int len, unsigned long saddr, ...@@ -478,7 +478,7 @@ static unsigned short udp_check(struct udphdr *uh, int len, unsigned long saddr,
} }
int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int len) size_t len)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
struct udp_opt *up = udp_sk(sk); struct udp_opt *up = udp_sk(sk);
...@@ -493,18 +493,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -493,18 +493,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int err; int err;
int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
/* This check is ONLY to check for arithmetic overflow if (len > 0xFFFF)
on integer(!) len. Not more! Real check will be made
in ip_append_* --ANK
BTW socket.c -> af_*.c -> ... make multiple
invalid conversions size_t -> int. We MUST repair it f.e.
by replacing all of them with size_t and revise all
the places sort of len += sizeof(struct iphdr)
If len was ULONG_MAX-10 it would be cathastrophe --ANK
*/
if (len < 0 || len > 0xFFFF)
return -EMSGSIZE; return -EMSGSIZE;
/* /*
...@@ -782,7 +771,7 @@ static __inline__ int udp_checksum_complete(struct sk_buff *skb) ...@@ -782,7 +771,7 @@ static __inline__ int udp_checksum_complete(struct sk_buff *skb)
*/ */
int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
int len, int noblock, int flags, int *addr_len) size_t len, int noblock, int flags, int *addr_len)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
......
...@@ -345,13 +345,15 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -345,13 +345,15 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
* we return it, otherwise we block. * we return it, otherwise we block.
*/ */
static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len, static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len) int noblock, int flags, int *addr_len)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)msg->msg_name; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)msg->msg_name;
struct sk_buff *skb; struct sk_buff *skb;
int copied, err; size_t copied;
int err;
if (flags & MSG_OOB) if (flags & MSG_OOB)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -527,7 +529,8 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length, ...@@ -527,7 +529,8 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
IP6_INC_STATS(Ip6OutDiscards); IP6_INC_STATS(Ip6OutDiscards);
return err; return err;
} }
static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len) static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len)
{ {
struct ipv6_txoptions opt_space; struct ipv6_txoptions opt_space;
struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name; struct sockaddr_in6 * sin6 = (struct sockaddr_in6 *) msg->msg_name;
......
...@@ -366,12 +366,14 @@ static void udpv6_close(struct sock *sk, long timeout) ...@@ -366,12 +366,14 @@ static void udpv6_close(struct sock *sk, long timeout)
* return it, otherwise we block. * return it, otherwise we block.
*/ */
static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len, static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len) int noblock, int flags, int *addr_len)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
struct sk_buff *skb; struct sk_buff *skb;
int copied, err; size_t copied;
int err;
if (addr_len) if (addr_len)
*addr_len=sizeof(struct sockaddr_in6); *addr_len=sizeof(struct sockaddr_in6);
...@@ -774,7 +776,8 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_opt *up) ...@@ -774,7 +776,8 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_opt *up)
return err; return err;
} }
static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, int len) static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len)
{ {
struct ipv6_txoptions opt_space; struct ipv6_txoptions opt_space;
struct udp_opt *up = udp_sk(sk); struct udp_opt *up = udp_sk(sk);
...@@ -841,7 +844,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg ...@@ -841,7 +844,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
/* Rough check on arithmetic overflow, /* Rough check on arithmetic overflow,
better check is made in ip6_build_xmit better check is made in ip6_build_xmit
*/ */
if (len < 0 || len > INT_MAX - sizeof(struct udphdr)) if (len > INT_MAX - sizeof(struct udphdr))
return -EMSGSIZE; return -EMSGSIZE;
if (up->pending) { if (up->pending) {
......
...@@ -90,7 +90,7 @@ static inline int sctp_wspace(struct sctp_association *asoc); ...@@ -90,7 +90,7 @@ static inline int sctp_wspace(struct sctp_association *asoc);
static inline void sctp_set_owner_w(struct sctp_chunk *chunk); static inline void sctp_set_owner_w(struct sctp_chunk *chunk);
static void sctp_wfree(struct sk_buff *skb); static void sctp_wfree(struct sk_buff *skb);
static int sctp_wait_for_sndbuf(struct sctp_association *, long *timeo_p, static int sctp_wait_for_sndbuf(struct sctp_association *, long *timeo_p,
int msg_len); size_t msg_len);
static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p); static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p);
static int sctp_wait_for_connect(struct sctp_association *, long *timeo_p); static int sctp_wait_for_connect(struct sctp_association *, long *timeo_p);
static int sctp_wait_for_accept(struct sock *sk, long timeo); static int sctp_wait_for_accept(struct sock *sk, long timeo);
...@@ -943,7 +943,7 @@ static int sctp_error(struct sock *sk, int flags, int err) ...@@ -943,7 +943,7 @@ static int sctp_error(struct sock *sk, int flags, int err)
SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *, sctp_cmsgs_t *); SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *, sctp_cmsgs_t *);
SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, int msg_len) struct msghdr *msg, size_t msg_len)
{ {
struct sctp_opt *sp; struct sctp_opt *sp;
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
...@@ -965,7 +965,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -965,7 +965,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
struct list_head *pos; struct list_head *pos;
int msg_flags = msg->msg_flags; int msg_flags = msg->msg_flags;
SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %d)\n", SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %u)\n",
sk, msg, msg_len); sk, msg, msg_len);
err = 0; err = 0;
...@@ -1021,7 +1021,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1021,7 +1021,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
associd = sinfo->sinfo_assoc_id; associd = sinfo->sinfo_assoc_id;
} }
SCTP_DEBUG_PRINTK("msg_len: %d, sinfo_flags: 0x%x\n", SCTP_DEBUG_PRINTK("msg_len: %u, sinfo_flags: 0x%x\n",
msg_len, sinfo_flags); msg_len, sinfo_flags);
/* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */ /* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */
...@@ -1377,7 +1377,7 @@ static int sctp_skb_pull(struct sk_buff *skb, int len) ...@@ -1377,7 +1377,7 @@ static int sctp_skb_pull(struct sk_buff *skb, int len)
static struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int, int *); static struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int, int *);
SCTP_STATIC int sctp_recvmsg(struct kiocb *iocb, struct sock *sk, SCTP_STATIC int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, int len, int noblock, struct msghdr *msg, size_t len, int noblock,
int flags, int *addr_len) int flags, int *addr_len)
{ {
struct sctp_ulpevent *event = NULL; struct sctp_ulpevent *event = NULL;
...@@ -4157,14 +4157,14 @@ static void sctp_wfree(struct sk_buff *skb) ...@@ -4157,14 +4157,14 @@ static void sctp_wfree(struct sk_buff *skb)
/* Helper function to wait for space in the sndbuf. */ /* Helper function to wait for space in the sndbuf. */
static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
int msg_len) size_t msg_len)
{ {
struct sock *sk = asoc->base.sk; struct sock *sk = asoc->base.sk;
int err = 0; int err = 0;
long current_timeo = *timeo_p; long current_timeo = *timeo_p;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%d\n", SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%u\n",
asoc, (long)(*timeo_p), msg_len); asoc, (long)(*timeo_p), msg_len);
/* Increment the association's refcnt. */ /* Increment the association's refcnt. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment