diff options
author | Divy Le Ray <divy@chelsio.com> | 2007-08-21 23:49:26 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:49 -0400 |
commit | c9a6ce500d78932c43361eae28c3de81b3660c77 (patch) | |
tree | d0cb68fb610a4085ee4c28164851b7ee142aa851 /drivers/net/cxgb3/cxgb3_offload.c | |
parent | e22bb45d772b5e5c850a6223c2a3245f520de641 (diff) |
cxgb3 - tighten checks on TID values
Enforce validity checks on connection ids
Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/cxgb3/cxgb3_offload.c')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_offload.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c index bac9214170ae..1c8eec38bde3 100644 --- a/drivers/net/cxgb3/cxgb3_offload.c +++ b/drivers/net/cxgb3/cxgb3_offload.c | |||
@@ -57,7 +57,7 @@ static DEFINE_RWLOCK(adapter_list_lock); | |||
57 | static LIST_HEAD(adapter_list); | 57 | static LIST_HEAD(adapter_list); |
58 | 58 | ||
59 | static const unsigned int MAX_ATIDS = 64 * 1024; | 59 | static const unsigned int MAX_ATIDS = 64 * 1024; |
60 | static const unsigned int ATID_BASE = 0x100000; | 60 | static const unsigned int ATID_BASE = 0x10000; |
61 | 61 | ||
62 | static inline int offload_activated(struct t3cdev *tdev) | 62 | static inline int offload_activated(struct t3cdev *tdev) |
63 | { | 63 | { |
@@ -694,10 +694,19 @@ static int do_cr(struct t3cdev *dev, struct sk_buff *skb) | |||
694 | { | 694 | { |
695 | struct cpl_pass_accept_req *req = cplhdr(skb); | 695 | struct cpl_pass_accept_req *req = cplhdr(skb); |
696 | unsigned int stid = G_PASS_OPEN_TID(ntohl(req->tos_tid)); | 696 | unsigned int stid = G_PASS_OPEN_TID(ntohl(req->tos_tid)); |
697 | struct tid_info *t = &(T3C_DATA(dev))->tid_maps; | ||
697 | struct t3c_tid_entry *t3c_tid; | 698 | struct t3c_tid_entry *t3c_tid; |
699 | unsigned int tid = GET_TID(req); | ||
698 | 700 | ||
699 | t3c_tid = lookup_stid(&(T3C_DATA(dev))->tid_maps, stid); | 701 | if (unlikely(tid >= t->ntids)) { |
700 | if (t3c_tid->ctx && t3c_tid->client->handlers && | 702 | printk("%s: passive open TID %u too large\n", |
703 | dev->name, tid); | ||
704 | t3_fatal_err(tdev2adap(dev)); | ||
705 | return CPL_RET_BUF_DONE; | ||
706 | } | ||
707 | |||
708 | t3c_tid = lookup_stid(t, stid); | ||
709 | if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers && | ||
701 | t3c_tid->client->handlers[CPL_PASS_ACCEPT_REQ]) { | 710 | t3c_tid->client->handlers[CPL_PASS_ACCEPT_REQ]) { |
702 | return t3c_tid->client->handlers[CPL_PASS_ACCEPT_REQ] | 711 | return t3c_tid->client->handlers[CPL_PASS_ACCEPT_REQ] |
703 | (dev, skb, t3c_tid->ctx); | 712 | (dev, skb, t3c_tid->ctx); |
@@ -779,16 +788,25 @@ static int do_act_establish(struct t3cdev *dev, struct sk_buff *skb) | |||
779 | { | 788 | { |
780 | struct cpl_act_establish *req = cplhdr(skb); | 789 | struct cpl_act_establish *req = cplhdr(skb); |
781 | unsigned int atid = G_PASS_OPEN_TID(ntohl(req->tos_tid)); | 790 | unsigned int atid = G_PASS_OPEN_TID(ntohl(req->tos_tid)); |
791 | struct tid_info *t = &(T3C_DATA(dev))->tid_maps; | ||
782 | struct t3c_tid_entry *t3c_tid; | 792 | struct t3c_tid_entry *t3c_tid; |
793 | unsigned int tid = GET_TID(req); | ||
783 | 794 | ||
784 | t3c_tid = lookup_atid(&(T3C_DATA(dev))->tid_maps, atid); | 795 | if (unlikely(tid >= t->ntids)) { |
796 | printk("%s: active establish TID %u too large\n", | ||
797 | dev->name, tid); | ||
798 | t3_fatal_err(tdev2adap(dev)); | ||
799 | return CPL_RET_BUF_DONE; | ||
800 | } | ||
801 | |||
802 | t3c_tid = lookup_atid(t, atid); | ||
785 | if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers && | 803 | if (t3c_tid && t3c_tid->ctx && t3c_tid->client->handlers && |
786 | t3c_tid->client->handlers[CPL_ACT_ESTABLISH]) { | 804 | t3c_tid->client->handlers[CPL_ACT_ESTABLISH]) { |
787 | return t3c_tid->client->handlers[CPL_ACT_ESTABLISH] | 805 | return t3c_tid->client->handlers[CPL_ACT_ESTABLISH] |
788 | (dev, skb, t3c_tid->ctx); | 806 | (dev, skb, t3c_tid->ctx); |
789 | } else { | 807 | } else { |
790 | printk(KERN_ERR "%s: received clientless CPL command 0x%x\n", | 808 | printk(KERN_ERR "%s: received clientless CPL command 0x%x\n", |
791 | dev->name, CPL_PASS_ACCEPT_REQ); | 809 | dev->name, CPL_ACT_ESTABLISH); |
792 | return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG; | 810 | return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG; |
793 | } | 811 | } |
794 | } | 812 | } |