Commit 45efebf2 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6

* 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6:
  [ICMP]: Fix icmp_errors_use_inbound_ifaddr sysctl
  [IPV4]: Fix "ipOutNoRoutes" counter error for TCP and UDP
  [NET] gso: Fix GSO feature mask in sk_setup_caps
  [TCP]: Fix GSO ignorance of pkts_acked arg (cong.cntrl modules)
  [NET]: Fix comparisons of unsigned < 0.
  [NET]: Make net watchdog timers 1 sec jiffy aligned.
  [ATM]: Fix warning.
  [TCP]: Use default 32768-61000 outgoing port range in all cases.
  [AF_UNIX]: Fix datagram connect race causing an OOPS.
  [TG3]: Fix link problem on Dell's onboard 5906.
  [AF_UNIX]: Make socket locking much less confusing.
parents 4acbab84 6e1d9103
...@@ -1475,6 +1475,7 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp, ...@@ -1475,6 +1475,7 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
struct FS_BPENTRY *qe, *ne; struct FS_BPENTRY *qe, *ne;
struct sk_buff *skb; struct sk_buff *skb;
int n = 0; int n = 0;
u32 qe_tmp;
fs_dprintk (FS_DEBUG_QUEUE, "Topping off queue at %x (%d-%d/%d)\n", fs_dprintk (FS_DEBUG_QUEUE, "Topping off queue at %x (%d-%d/%d)\n",
fp->offset, read_fs (dev, FP_CNT (fp->offset)), fp->n, fp->offset, read_fs (dev, FP_CNT (fp->offset)), fp->n,
...@@ -1502,10 +1503,16 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp, ...@@ -1502,10 +1503,16 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
ne->skb = skb; ne->skb = skb;
ne->fp = fp; ne->fp = fp;
qe = (struct FS_BPENTRY *) (read_fs (dev, FP_EA(fp->offset))); /*
fs_dprintk (FS_DEBUG_QUEUE, "link at %p\n", qe); * FIXME: following code encodes and decodes
if (qe) { * machine pointers (could be 64-bit) into a
qe = bus_to_virt ((long) qe); * 32-bit register.
*/
qe_tmp = read_fs (dev, FP_EA(fp->offset));
fs_dprintk (FS_DEBUG_QUEUE, "link at %x\n", qe_tmp);
if (qe_tmp) {
qe = bus_to_virt ((long) qe_tmp);
qe->next = virt_to_bus(ne); qe->next = virt_to_bus(ne);
qe->flags &= ~FP_FLAGS_EPI; qe->flags &= ~FP_FLAGS_EPI;
} else } else
......
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
#define DRV_MODULE_NAME "tg3" #define DRV_MODULE_NAME "tg3"
#define PFX DRV_MODULE_NAME ": " #define PFX DRV_MODULE_NAME ": "
#define DRV_MODULE_VERSION "3.76" #define DRV_MODULE_VERSION "3.77"
#define DRV_MODULE_RELDATE "May 5, 2007" #define DRV_MODULE_RELDATE "May 31, 2007"
#define TG3_DEF_MAC_MODE 0 #define TG3_DEF_MAC_MODE 0
#define TG3_DEF_RX_MODE 0 #define TG3_DEF_RX_MODE 0
...@@ -10961,6 +10961,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) ...@@ -10961,6 +10961,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
* upon subsystem IDs. * upon subsystem IDs.
*/ */
if (tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL && if (tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL &&
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) { !(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) {
tp->tg3_flags |= (TG3_FLAG_USE_MI_INTERRUPT | tp->tg3_flags |= (TG3_FLAG_USE_MI_INTERRUPT |
TG3_FLAG_USE_LINKCHG_REG); TG3_FLAG_USE_LINKCHG_REG);
......
...@@ -62,13 +62,11 @@ struct unix_skb_parms { ...@@ -62,13 +62,11 @@ struct unix_skb_parms {
#define UNIXCREDS(skb) (&UNIXCB((skb)).creds) #define UNIXCREDS(skb) (&UNIXCB((skb)).creds)
#define UNIXSID(skb) (&UNIXCB((skb)).secid) #define UNIXSID(skb) (&UNIXCB((skb)).secid)
#define unix_state_rlock(s) spin_lock(&unix_sk(s)->lock) #define unix_state_lock(s) spin_lock(&unix_sk(s)->lock)
#define unix_state_runlock(s) spin_unlock(&unix_sk(s)->lock) #define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock)
#define unix_state_wlock(s) spin_lock(&unix_sk(s)->lock) #define unix_state_lock_nested(s) \
#define unix_state_wlock_nested(s) \
spin_lock_nested(&unix_sk(s)->lock, \ spin_lock_nested(&unix_sk(s)->lock, \
SINGLE_DEPTH_NESTING) SINGLE_DEPTH_NESTING)
#define unix_state_wunlock(s) spin_unlock(&unix_sk(s)->lock)
#ifdef __KERNEL__ #ifdef __KERNEL__
/* The AF_UNIX socket */ /* The AF_UNIX socket */
......
...@@ -736,8 +736,7 @@ static int vlan_ioctl_handler(void __user *arg) ...@@ -736,8 +736,7 @@ static int vlan_ioctl_handler(void __user *arg)
case SET_VLAN_NAME_TYPE_CMD: case SET_VLAN_NAME_TYPE_CMD:
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
if ((args.u.name_type >= 0) && if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
(args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
vlan_name_type = args.u.name_type; vlan_name_type = args.u.name_type;
err = 0; err = 0;
} else { } else {
......
...@@ -998,7 +998,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst) ...@@ -998,7 +998,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
__sk_dst_set(sk, dst); __sk_dst_set(sk, dst);
sk->sk_route_caps = dst->dev->features; sk->sk_route_caps = dst->dev->features;
if (sk->sk_route_caps & NETIF_F_GSO) if (sk->sk_route_caps & NETIF_F_GSO)
sk->sk_route_caps |= NETIF_F_GSO_MASK; sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
if (sk_can_gso(sk)) { if (sk_can_gso(sk)) {
if (dst->header_len) if (dst->header_len)
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
......
...@@ -128,7 +128,7 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf, ...@@ -128,7 +128,7 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf,
int error = 0, cnt = 0; int error = 0, cnt = 0;
unsigned char *tbuf; unsigned char *tbuf;
if (!buf || len < 0) if (!buf)
return -EINVAL; return -EINVAL;
if (len == 0) if (len == 0)
......
...@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
RT_CONN_FLAGS(sk), oif, RT_CONN_FLAGS(sk), oif,
sk->sk_protocol, sk->sk_protocol,
inet->sport, usin->sin_port, sk, 1); inet->sport, usin->sin_port, sk, 1);
if (err) if (err) {
if (err == -ENETUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
return err; return err;
}
if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) { if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
ip_rt_put(rt); ip_rt_put(rt);
return -EACCES; return -EACCES;
......
...@@ -514,12 +514,15 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -514,12 +514,15 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
saddr = iph->daddr; saddr = iph->daddr;
if (!(rt->rt_flags & RTCF_LOCAL)) { if (!(rt->rt_flags & RTCF_LOCAL)) {
/* This is broken, skb_in->dev points to the outgoing device struct net_device *dev = NULL;
* after the packet passes through ip_output().
*/ if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr)
if (skb_in->dev && sysctl_icmp_errors_use_inbound_ifaddr) dev = dev_get_by_index(rt->fl.iif);
saddr = inet_select_addr(skb_in->dev, 0, RT_SCOPE_LINK);
else if (dev) {
saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
dev_put(dev);
} else
saddr = 0; saddr = 0;
} }
......
...@@ -31,10 +31,8 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg); ...@@ -31,10 +31,8 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg);
/* /*
* This array holds the first and last local port number. * This array holds the first and last local port number.
* For high-usage systems, use sysctl to change this to
* 32768-61000
*/ */
int sysctl_local_port_range[2] = { 1024, 4999 }; int sysctl_local_port_range[2] = { 32768, 61000 };
int inet_csk_bind_conflict(const struct sock *sk, int inet_csk_bind_conflict(const struct sock *sk,
const struct inet_bind_bucket *tb) const struct inet_bind_bucket *tb)
......
...@@ -2464,13 +2464,10 @@ void __init tcp_init(void) ...@@ -2464,13 +2464,10 @@ void __init tcp_init(void)
order++) order++)
; ;
if (order >= 4) { if (order >= 4) {
sysctl_local_port_range[0] = 32768;
sysctl_local_port_range[1] = 61000;
tcp_death_row.sysctl_max_tw_buckets = 180000; tcp_death_row.sysctl_max_tw_buckets = 180000;
sysctl_tcp_max_orphans = 4096 << (order - 4); sysctl_tcp_max_orphans = 4096 << (order - 4);
sysctl_max_syn_backlog = 1024; sysctl_max_syn_backlog = 1024;
} else if (order < 3) { } else if (order < 3) {
sysctl_local_port_range[0] = 1024 * (3 - order);
tcp_death_row.sysctl_max_tw_buckets >>= (3 - order); tcp_death_row.sysctl_max_tw_buckets >>= (3 - order);
sysctl_tcp_max_orphans >>= (3 - order); sysctl_tcp_max_orphans >>= (3 - order);
sysctl_max_syn_backlog = 128; sysctl_max_syn_backlog = 128;
......
...@@ -2407,8 +2407,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2407,8 +2407,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
struct sk_buff *skb; struct sk_buff *skb;
__u32 now = tcp_time_stamp; __u32 now = tcp_time_stamp;
int acked = 0; int acked = 0;
int prior_packets = tp->packets_out;
__s32 seq_rtt = -1; __s32 seq_rtt = -1;
u32 pkts_acked = 0;
ktime_t last_ackt = ktime_set(0,0); ktime_t last_ackt = ktime_set(0,0);
while ((skb = tcp_write_queue_head(sk)) && while ((skb = tcp_write_queue_head(sk)) &&
...@@ -2437,7 +2437,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2437,7 +2437,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
*/ */
if (!(scb->flags & TCPCB_FLAG_SYN)) { if (!(scb->flags & TCPCB_FLAG_SYN)) {
acked |= FLAG_DATA_ACKED; acked |= FLAG_DATA_ACKED;
++pkts_acked;
} else { } else {
acked |= FLAG_SYN_ACKED; acked |= FLAG_SYN_ACKED;
tp->retrans_stamp = 0; tp->retrans_stamp = 0;
...@@ -2481,6 +2480,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p) ...@@ -2481,6 +2480,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
} }
if (acked&FLAG_ACKED) { if (acked&FLAG_ACKED) {
u32 pkts_acked = prior_packets - tp->packets_out;
const struct tcp_congestion_ops *ca_ops const struct tcp_congestion_ops *ca_ops
= inet_csk(sk)->icsk_ca_ops; = inet_csk(sk)->icsk_ca_ops;
......
...@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
IPPROTO_TCP, IPPROTO_TCP,
inet->sport, usin->sin_port, sk, 1); inet->sport, usin->sin_port, sk, 1);
if (tmp < 0) if (tmp < 0) {
if (tmp == -ENETUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
return tmp; return tmp;
}
if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) { if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
ip_rt_put(rt); ip_rt_put(rt);
......
...@@ -722,8 +722,11 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -722,8 +722,11 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.dport = dport } } }; .dport = dport } } };
security_sk_classify_flow(sk, &fl); security_sk_classify_flow(sk, &fl);
err = ip_route_output_flow(&rt, &fl, sk, 1); err = ip_route_output_flow(&rt, &fl, sk, 1);
if (err) if (err) {
if (err == -ENETUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
goto out; goto out;
}
err = -EACCES; err = -EACCES;
if ((rt->rt_flags & RTCF_BROADCAST) && if ((rt->rt_flags & RTCF_BROADCAST) &&
......
...@@ -177,8 +177,7 @@ static unsigned int ipv6_confirm(unsigned int hooknum, ...@@ -177,8 +177,7 @@ static unsigned int ipv6_confirm(unsigned int hooknum,
protoff = nf_ct_ipv6_skip_exthdr(*pskb, extoff, &pnum, protoff = nf_ct_ipv6_skip_exthdr(*pskb, extoff, &pnum,
(*pskb)->len - extoff); (*pskb)->len - extoff);
if (protoff < 0 || protoff > (*pskb)->len || if (protoff > (*pskb)->len || pnum == NEXTHDR_FRAGMENT) {
pnum == NEXTHDR_FRAGMENT) {
DEBUGP("proto header not found\n"); DEBUGP("proto header not found\n");
return NF_ACCEPT; return NF_ACCEPT;
} }
......
...@@ -168,8 +168,7 @@ icmpv6_error_message(struct sk_buff *skb, ...@@ -168,8 +168,7 @@ icmpv6_error_message(struct sk_buff *skb,
skb->len - inip6off skb->len - inip6off
- sizeof(struct ipv6hdr)); - sizeof(struct ipv6hdr));
if ((inprotoff < 0) || (inprotoff > skb->len) || if ((inprotoff > skb->len) || (inprotonum == NEXTHDR_FRAGMENT)) {
(inprotonum == NEXTHDR_FRAGMENT)) {
DEBUGP("icmpv6_error: Can't get protocol header in ICMPv6 payload.\n"); DEBUGP("icmpv6_error: Can't get protocol header in ICMPv6 payload.\n");
return -NF_ACCEPT; return -NF_ACCEPT;
} }
......
...@@ -164,8 +164,7 @@ static int tcf_pedit(struct sk_buff *skb, struct tc_action *a, ...@@ -164,8 +164,7 @@ static int tcf_pedit(struct sk_buff *skb, struct tc_action *a,
printk("offset must be on 32 bit boundaries\n"); printk("offset must be on 32 bit boundaries\n");
goto bad; goto bad;
} }
if (skb->len < 0 || if (offset > 0 && offset > skb->len) {
(offset > 0 && offset > skb->len)) {
printk("offset %d cant exceed pkt length %d\n", printk("offset %d cant exceed pkt length %d\n",
offset, skb->len); offset, skb->len);
goto bad; goto bad;
......
...@@ -224,7 +224,8 @@ void __netdev_watchdog_up(struct net_device *dev) ...@@ -224,7 +224,8 @@ void __netdev_watchdog_up(struct net_device *dev)
if (dev->tx_timeout) { if (dev->tx_timeout) {
if (dev->watchdog_timeo <= 0) if (dev->watchdog_timeo <= 0)
dev->watchdog_timeo = 5*HZ; dev->watchdog_timeo = 5*HZ;
if (!mod_timer(&dev->watchdog_timer, jiffies + dev->watchdog_timeo)) if (!mod_timer(&dev->watchdog_timer,
round_jiffies(jiffies + dev->watchdog_timeo)))
dev_hold(dev); dev_hold(dev);
} }
} }
......
...@@ -77,8 +77,6 @@ static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = { ...@@ -77,8 +77,6 @@ static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
/* Lookup "chunk type" debug name. */ /* Lookup "chunk type" debug name. */
const char *sctp_cname(const sctp_subtype_t cid) const char *sctp_cname(const sctp_subtype_t cid)
{ {
if (cid.chunk < 0)
return "illegal chunk id";
if (cid.chunk <= SCTP_CID_BASE_MAX) if (cid.chunk <= SCTP_CID_BASE_MAX)
return sctp_cid_tbl[cid.chunk]; return sctp_cid_tbl[cid.chunk];
...@@ -146,8 +144,6 @@ static const char *sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = { ...@@ -146,8 +144,6 @@ static const char *sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
/* Lookup primitive debug name. */ /* Lookup primitive debug name. */
const char *sctp_pname(const sctp_subtype_t id) const char *sctp_pname(const sctp_subtype_t id)
{ {
if (id.primitive < 0)
return "illegal primitive";
if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX) if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
return sctp_primitive_tbl[id.primitive]; return sctp_primitive_tbl[id.primitive];
return "unknown_primitive"; return "unknown_primitive";
...@@ -161,8 +157,6 @@ static const char *sctp_other_tbl[] = { ...@@ -161,8 +157,6 @@ static const char *sctp_other_tbl[] = {
/* Lookup "other" debug name. */ /* Lookup "other" debug name. */
const char *sctp_oname(const sctp_subtype_t id) const char *sctp_oname(const sctp_subtype_t id)
{ {
if (id.other < 0)
return "illegal 'other' event";
if (id.other <= SCTP_EVENT_OTHER_MAX) if (id.other <= SCTP_EVENT_OTHER_MAX)
return sctp_other_tbl[id.other]; return sctp_other_tbl[id.other];
return "unknown 'other' event"; return "unknown 'other' event";
...@@ -184,8 +178,6 @@ static const char *sctp_timer_tbl[] = { ...@@ -184,8 +178,6 @@ static const char *sctp_timer_tbl[] = {
/* Lookup timer debug name. */ /* Lookup timer debug name. */
const char *sctp_tname(const sctp_subtype_t id) const char *sctp_tname(const sctp_subtype_t id)
{ {
if (id.timeout < 0)
return "illegal 'timer' event";
if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX) if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
return sctp_timer_tbl[id.timeout]; return sctp_timer_tbl[id.timeout];
return "unknown_timer"; return "unknown_timer";
......
...@@ -960,7 +960,7 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, ...@@ -960,7 +960,7 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
if (state > SCTP_STATE_MAX) if (state > SCTP_STATE_MAX)
return &bug; return &bug;
if (cid >= 0 && cid <= SCTP_CID_BASE_MAX) if (cid <= SCTP_CID_BASE_MAX)
return &chunk_event_table[cid][state]; return &chunk_event_table[cid][state];
if (sctp_prsctp_enable) { if (sctp_prsctp_enable) {
......
...@@ -174,11 +174,11 @@ static struct sock *unix_peer_get(struct sock *s) ...@@ -174,11 +174,11 @@ static struct sock *unix_peer_get(struct sock *s)
{ {
struct sock *peer; struct sock *peer;
unix_state_rlock(s); unix_state_lock(s);
peer = unix_peer(s); peer = unix_peer(s);
if (peer) if (peer)
sock_hold(peer); sock_hold(peer);
unix_state_runlock(s); unix_state_unlock(s);
return peer; return peer;
} }
...@@ -369,7 +369,7 @@ static int unix_release_sock (struct sock *sk, int embrion) ...@@ -369,7 +369,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
unix_remove_socket(sk); unix_remove_socket(sk);
/* Clear state */ /* Clear state */
unix_state_wlock(sk); unix_state_lock(sk);
sock_orphan(sk); sock_orphan(sk);
sk->sk_shutdown = SHUTDOWN_MASK; sk->sk_shutdown = SHUTDOWN_MASK;
dentry = u->dentry; dentry = u->dentry;
...@@ -378,7 +378,7 @@ static int unix_release_sock (struct sock *sk, int embrion) ...@@ -378,7 +378,7 @@ static int unix_release_sock (struct sock *sk, int embrion)
u->mnt = NULL; u->mnt = NULL;
state = sk->sk_state; state = sk->sk_state;
sk->sk_state = TCP_CLOSE; sk->sk_state = TCP_CLOSE;
unix_state_wunlock(sk); unix_state_unlock(sk);
wake_up_interruptible_all(&u->peer_wait); wake_up_interruptible_all(&u->peer_wait);
...@@ -386,12 +386,12 @@ static int unix_release_sock (struct sock *sk, int embrion) ...@@ -386,12 +386,12 @@ static int unix_release_sock (struct sock *sk, int embrion)
if (skpair!=NULL) { if (skpair!=NULL) {
if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) {
unix_state_wlock(skpair); unix_state_lock(skpair);
/* No more writes */ /* No more writes */
skpair->sk_shutdown = SHUTDOWN_MASK; skpair->sk_shutdown = SHUTDOWN_MASK;
if (!skb_queue_empty(&sk->sk_receive_queue) || embrion) if (!skb_queue_empty(&sk->sk_receive_queue) || embrion)
skpair->sk_err = ECONNRESET; skpair->sk_err = ECONNRESET;
unix_state_wunlock(skpair); unix_state_unlock(skpair);
skpair->sk_state_change(skpair); skpair->sk_state_change(skpair);
read_lock(&skpair->sk_callback_lock); read_lock(&skpair->sk_callback_lock);
sk_wake_async(skpair,1,POLL_HUP); sk_wake_async(skpair,1,POLL_HUP);
...@@ -448,7 +448,7 @@ static int unix_listen(struct socket *sock, int backlog) ...@@ -448,7 +448,7 @@ static int unix_listen(struct socket *sock, int backlog)
err = -EINVAL; err = -EINVAL;
if (!u->addr) if (!u->addr)
goto out; /* No listens on an unbound socket */ goto out; /* No listens on an unbound socket */
unix_state_wlock(sk); unix_state_lock(sk);
if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN) if (sk->sk_state != TCP_CLOSE && sk->sk_state != TCP_LISTEN)
goto out_unlock; goto out_unlock;
if (backlog > sk->sk_max_ack_backlog) if (backlog > sk->sk_max_ack_backlog)
...@@ -462,7 +462,7 @@ static int unix_listen(struct socket *sock, int backlog) ...@@ -462,7 +462,7 @@ static int unix_listen(struct socket *sock, int backlog)
err = 0; err = 0;
out_unlock: out_unlock:
unix_state_wunlock(sk); unix_state_unlock(sk);
out: out:
return err; return err;
} }
...@@ -858,6 +858,31 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -858,6 +858,31 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
goto out_up; goto out_up;
} }
static void unix_state_double_lock(struct sock *sk1, struct sock *sk2)
{
if (unlikely(sk1 == sk2) || !sk2) {
unix_state_lock(sk1);
return;
}
if (sk1 < sk2) {
unix_state_lock(sk1);
unix_state_lock_nested(sk2);
} else {
unix_state_lock(sk2);
unix_state_lock_nested(sk1);
}
}
static void unix_state_double_unlock(struct sock *sk1, struct sock *sk2)
{
if (unlikely(sk1 == sk2) || !sk2) {
unix_state_unlock(sk1);
return;
}
unix_state_unlock(sk1);
unix_state_unlock(sk2);
}
static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
int alen, int flags) int alen, int flags)
{ {
...@@ -877,11 +902,19 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, ...@@ -877,11 +902,19 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
!unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0) !unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0)
goto out; goto out;
restart:
other=unix_find_other(sunaddr, alen, sock->type, hash, &err); other=unix_find_other(sunaddr, alen, sock->type, hash, &err);
if (!other) if (!other)
goto out; goto out;
unix_state_wlock(sk); unix_state_double_lock(sk, other);
/* Apparently VFS overslept socket death. Retry. */
if (sock_flag(other, SOCK_DEAD)) {
unix_state_double_unlock(sk, other);
sock_put(other);
goto restart;
}
err = -EPERM; err = -EPERM;
if (!unix_may_send(sk, other)) if (!unix_may_send(sk, other))
...@@ -896,7 +929,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, ...@@ -896,7 +929,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
* 1003.1g breaking connected state with AF_UNSPEC * 1003.1g breaking connected state with AF_UNSPEC
*/ */
other = NULL; other = NULL;
unix_state_wlock(sk); unix_state_double_lock(sk, other);
} }
/* /*
...@@ -905,19 +938,19 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr, ...@@ -905,19 +938,19 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
if (unix_peer(sk)) { if (unix_peer(sk)) {
struct sock *old_peer = unix_peer(sk); struct sock *old_peer = unix_peer(sk);
unix_peer(sk)=other; unix_peer(sk)=other;
unix_state_wunlock(sk); unix_state_double_unlock(sk, other);
if (other != old_peer) if (other != old_peer)
unix_dgram_disconnected(sk, old_peer); unix_dgram_disconnected(sk, old_peer);
sock_put(old_peer); sock_put(old_peer);
} else { } else {
unix_peer(sk)=other; unix_peer(sk)=other;
unix_state_wunlock(sk); unix_state_double_unlock(sk, other);
} }
return 0; return 0;
out_unlock: out_unlock:
unix_state_wunlock(sk); unix_state_double_unlock(sk, other);
sock_put(other); sock_put(other);
out: out:
return err; return err;
...@@ -936,7 +969,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo) ...@@ -936,7 +969,7 @@ static long unix_wait_for_peer(struct sock *other, long timeo)
(skb_queue_len(&other->sk_receive_queue) > (skb_queue_len(&other->sk_receive_queue) >
other->sk_max_ack_backlog); other->sk_max_ack_backlog);
unix_state_runlock(other); unix_state_unlock(other);
if (sched) if (sched)
timeo = schedule_timeout(timeo); timeo = schedule_timeout(timeo);
...@@ -994,11 +1027,11 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -994,11 +1027,11 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
goto out; goto out;
/* Latch state of peer */ /* Latch state of peer */
unix_state_rlock(other); unix_state_lock(other);
/* Apparently VFS overslept socket death. Retry. */ /* Apparently VFS overslept socket death. Retry. */
if (sock_flag(other, SOCK_DEAD)) { if (sock_flag(other, SOCK_DEAD)) {
unix_state_runlock(other); unix_state_unlock(other);
sock_put(other); sock_put(other);
goto restart; goto restart;
} }
...@@ -1048,18 +1081,18 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1048,18 +1081,18 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
goto out_unlock; goto out_unlock;
} }
unix_state_wlock_nested(sk); unix_state_lock_nested(sk);
if (sk->sk_state != st) { if (sk->sk_state != st) {
unix_state_wunlock(sk); unix_state_unlock(sk);
unix_state_runlock(other); unix_state_unlock(other);
sock_put(other); sock_put(other);
goto restart; goto restart;
} }
err = security_unix_stream_connect(sock, other->sk_socket, newsk); err = security_unix_stream_connect(sock, other->sk_socket, newsk);
if (err) { if (err) {
unix_state_wunlock(sk); unix_state_unlock(sk);
goto out_unlock; goto out_unlock;
} }
...@@ -1096,7 +1129,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1096,7 +1129,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
smp_mb__after_atomic_inc(); /* sock_hold() does an atomic_inc() */ smp_mb__after_atomic_inc(); /* sock_hold() does an atomic_inc() */
unix_peer(sk) = newsk; unix_peer(sk) = newsk;
unix_state_wunlock(sk); unix_state_unlock(sk);
/* take ten and and send info to listening sock */ /* take ten and and send info to listening sock */
spin_lock(&other->sk_receive_queue.lock); spin_lock(&other->sk_receive_queue.lock);
...@@ -1105,14 +1138,14 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -1105,14 +1138,14 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
* is installed to listening socket. */ * is installed to listening socket. */
atomic_inc(&newu->inflight); atomic_inc(&newu->inflight);
spin_unlock(&other->sk_receive_queue.lock); spin_unlock(&other->sk_receive_queue.lock);
unix_state_runlock(other); unix_state_unlock(other);
other->sk_data_ready(other, 0); other->sk_data_ready(other, 0);
sock_put(other); sock_put(other);
return 0; return 0;
out_unlock: out_unlock:
if (other) if (other)
unix_state_runlock(other); unix_state_unlock(other);
out: out:
if (skb) if (skb)
...@@ -1178,10 +1211,10 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -1178,10 +1211,10 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags)
wake_up_interruptible(&unix_sk(sk)->peer_wait); wake_up_interruptible(&unix_sk(sk)->peer_wait);
/* attach accepted sock to socket */ /* attach accepted sock to socket */
unix_state_wlock(tsk); unix_state_lock(tsk);
newsock->state = SS_CONNECTED; newsock->state = SS_CONNECTED;
sock_graft(tsk, newsock); sock_graft(tsk, newsock);
unix_state_wunlock(tsk); unix_state_unlock(tsk);
return 0; return 0;
out: out:
...@@ -1208,7 +1241,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_ ...@@ -1208,7 +1241,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
} }
u = unix_sk(sk); u = unix_sk(sk);
unix_state_rlock(sk); unix_state_lock(sk);
if (!u->addr) { if (!u->addr) {
sunaddr->sun_family = AF_UNIX; sunaddr->sun_family = AF_UNIX;
sunaddr->sun_path[0] = 0; sunaddr->sun_path[0] = 0;
...@@ -1219,7 +1252,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_ ...@@ -1219,7 +1252,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int *uaddr_
*uaddr_len = addr->len; *uaddr_len = addr->len;
memcpy(sunaddr, addr->name, *uaddr_len); memcpy(sunaddr, addr->name, *uaddr_len);
} }
unix_state_runlock(sk); unix_state_unlock(sk);
sock_put(sk); sock_put(sk);
out: out:
return err; return err;
...@@ -1337,7 +1370,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1337,7 +1370,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
goto out_free; goto out_free;
} }
unix_state_rlock(other); unix_state_lock(other);
err = -EPERM; err = -EPERM;
if (!unix_may_send(sk, other)) if (!unix_may_send(sk, other))
goto out_unlock; goto out_unlock;
...@@ -1347,20 +1380,20 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1347,20 +1380,20 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
* Check with 1003.1g - what should * Check with 1003.1g - what should
* datagram error * datagram error
*/ */
unix_state_runlock(other); unix_state_unlock(other);
sock_put(other); sock_put(other);
err = 0; err = 0;
unix_state_wlock(sk); unix_state_lock(sk);
if (unix_peer(sk) == other) { if (unix_peer(sk) == other) {
unix_peer(sk)=NULL; unix_peer(sk)=NULL;
unix_state_wunlock(sk); unix_state_unlock(sk);
unix_dgram_disconnected(sk, other); unix_dgram_disconnected(sk, other);
sock_put(other); sock_put(other);
err = -ECONNREFUSED; err = -ECONNREFUSED;
} else { } else {
unix_state_wunlock(sk); unix_state_unlock(sk);
} }
other = NULL; other = NULL;
...@@ -1397,14 +1430,14 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1397,14 +1430,14 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
} }
skb_queue_tail(&other->sk_receive_queue, skb); skb_queue_tail(&other->sk_receive_queue, skb);
unix_state_runlock(other); unix_state_unlock(other);
other->sk_data_ready(other, len); other->sk_data_ready(other, len);
sock_put(other); sock_put(other);
scm_destroy(siocb->scm); scm_destroy(siocb->scm);
return len; return len;
out_unlock: out_unlock:
unix_state_runlock(other); unix_state_unlock(other);
out_free: out_free:
kfree_skb(skb); kfree_skb(skb);
out: out:
...@@ -1494,14 +1527,14 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1494,14 +1527,14 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
goto out_err; goto out_err;
} }
unix_state_rlock(other); unix_state_lock(other);
if (sock_flag(other, SOCK_DEAD) || if (sock_flag(other, SOCK_DEAD) ||
(other->sk_shutdown & RCV_SHUTDOWN)) (other->sk_shutdown & RCV_SHUTDOWN))
goto pipe_err_free; goto pipe_err_free;
skb_queue_tail(&other->sk_receive_queue, skb); skb_queue_tail(&other->sk_receive_queue, skb);
unix_state_runlock(other); unix_state_unlock(other);
other->sk_data_ready(other, size); other->sk_data_ready(other, size);
sent+=size; sent+=size;
} }
...@@ -1512,7 +1545,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, ...@@ -1512,7 +1545,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock,
return sent; return sent;
pipe_err_free: pipe_err_free:
unix_state_runlock(other); unix_state_unlock(other);
kfree_skb(skb); kfree_skb(skb);
pipe_err: pipe_err:
if (sent==0 && !(msg->msg_flags&MSG_NOSIGNAL)) if (sent==0 && !(msg->msg_flags&MSG_NOSIGNAL))
...@@ -1641,7 +1674,7 @@ static long unix_stream_data_wait(struct sock * sk, long timeo) ...@@ -1641,7 +1674,7 @@ static long unix_stream_data_wait(struct sock * sk, long timeo)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
unix_state_rlock(sk); unix_state_lock(sk);
for (;;) { for (;;) {
prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
...@@ -1654,14 +1687,14 @@ static long unix_stream_data_wait(struct sock * sk, long timeo) ...@@ -1654,14 +1687,14 @@ static long unix_stream_data_wait(struct sock * sk, long timeo)
break; break;
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
unix_state_runlock(sk); unix_state_unlock(sk);
timeo = schedule_timeout(timeo); timeo = schedule_timeout(timeo);
unix_state_rlock(sk); unix_state_lock(sk);
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
} }
finish_wait(sk->sk_sleep, &wait); finish_wait(sk->sk_sleep, &wait);
unix_state_runlock(sk); unix_state_unlock(sk);
return timeo; return timeo;
} }
...@@ -1816,12 +1849,12 @@ static int unix_shutdown(struct socket *sock, int mode) ...@@ -1816,12 +1849,12 @@ static int unix_shutdown(struct socket *sock, int mode)
mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN); mode = (mode+1)&(RCV_SHUTDOWN|SEND_SHUTDOWN);
if (mode) { if (mode) {
unix_state_wlock(sk); unix_state_lock(sk);
sk->sk_shutdown |= mode; sk->sk_shutdown |= mode;
other=unix_peer(sk); other=unix_peer(sk);
if (other) if (other)
sock_hold(other); sock_hold(other);
unix_state_wunlock(sk); unix_state_unlock(sk);
sk->sk_state_change(sk); sk->sk_state_change(sk);
if (other && if (other &&
...@@ -1833,9 +1866,9 @@ static int unix_shutdown(struct socket *sock, int mode) ...@@ -1833,9 +1866,9 @@ static int unix_shutdown(struct socket *sock, int mode)
peer_mode |= SEND_SHUTDOWN; peer_mode |= SEND_SHUTDOWN;
if (mode&SEND_SHUTDOWN) if (mode&SEND_SHUTDOWN)
peer_mode |= RCV_SHUTDOWN; peer_mode |= RCV_SHUTDOWN;
unix_state_wlock(other); unix_state_lock(other);
other->sk_shutdown |= peer_mode; other->sk_shutdown |= peer_mode;
unix_state_wunlock(other); unix_state_unlock(other);
other->sk_state_change(other); other->sk_state_change(other);
read_lock(&other->sk_callback_lock); read_lock(&other->sk_callback_lock);
if (peer_mode == SHUTDOWN_MASK) if (peer_mode == SHUTDOWN_MASK)
...@@ -1973,7 +2006,7 @@ static int unix_seq_show(struct seq_file *seq, void *v) ...@@ -1973,7 +2006,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
else { else {
struct sock *s = v; struct sock *s = v;
struct unix_sock *u = unix_sk(s); struct unix_sock *u = unix_sk(s);
unix_state_rlock(s); unix_state_lock(s);
seq_printf(seq, "%p: %08X %08X %08X %04X %02X %5lu", seq_printf(seq, "%p: %08X %08X %08X %04X %02X %5lu",
s, s,
...@@ -2001,7 +2034,7 @@ static int unix_seq_show(struct seq_file *seq, void *v) ...@@ -2001,7 +2034,7 @@ static int unix_seq_show(struct seq_file *seq, void *v)
for ( ; i < len; i++) for ( ; i < len; i++)
seq_putc(seq, u->addr->name->sun_path[i]); seq_putc(seq, u->addr->name->sun_path[i]);
} }
unix_state_runlock(s); unix_state_unlock(s);
seq_putc(seq, '\n'); seq_putc(seq, '\n');
} }
......
...@@ -454,7 +454,7 @@ static int wanrouter_device_setup(struct wan_device *wandev, ...@@ -454,7 +454,7 @@ static int wanrouter_device_setup(struct wan_device *wandev,
} }
if (conf->data_size && conf->data) { if (conf->data_size && conf->data) {
if (conf->data_size > 128000 || conf->data_size < 0) { if (conf->data_size > 128000) {
printk(KERN_INFO printk(KERN_INFO
"%s: ERROR, Invalid firmware data size %i !\n", "%s: ERROR, Invalid firmware data size %i !\n",
wandev->name, conf->data_size); wandev->name, conf->data_size);
......
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