2008-09-26 14:19:25

by Jiri Benc

[permalink] [raw]
Subject: [compat-old PATCH 1/2] Fix wrong cast to ieee80211_local

This fixes a kernel crash that was caused by using a wrong pointer for
ieee80211_local dereference in mq compat implementation.

Signed-off-by: Jiri Benc <[email protected]>

---

(The bug is described at http://wireless.kernel.org/en/users/Download/compat-wireless-old-2.6.22-bug)

net/mac80211/mq_compat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- cw.orig/net/mac80211/mq_compat.h
+++ cw/net/mac80211/mq_compat.h
@@ -22,7 +22,7 @@
*/

#define IEEE80211_DEV_TO_LOCAL(dev) \
- ((struct ieee80211_local *)(IEEE80211_DEV_TO_SUB_IF(dev))->local)
+ ((struct ieee80211_local *)(wdev_priv(dev->ieee80211_ptr)))

/* This was stripped out after MQ patch for mac80211, let bring it
* back to life */


--
Jiri Benc
SUSE Labs


2008-09-26 14:20:39

by Jiri Benc

[permalink] [raw]
Subject: [compat-old PATCH 2/2] Allow compilation on 2.6.22

This allows compilation of compat-wireless-old on 2.6.22 kernel. I suspect
some drivers don't work despite they compile, though.

Signed-off-by: Jiri Benc <[email protected]>

---
config.mk | 4 +++-
drivers/net/wireless/libertas/if_usb.c | 2 ++
include/net/compat.h | 17 +++++++++++++++++
net/mac80211/wme.c | 2 +-
4 files changed, 23 insertions(+), 2 deletions(-)

--- cw.orig/config.mk
+++ cw/config.mk
@@ -27,7 +27,6 @@ CONFIG_MAC80211=m
ifeq ($(shell test -e $(KLIB_BUILD)/Makefile && echo yes),yes)
KERNEL_SUBLEVEL = $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p')
ifeq ($(shell test $(KERNEL_SUBLEVEL) -lt 23 && echo yes),yes)
-$(error "ERROR: There is a bug with compat-wireless on 2.6.22. Remove me if you want to fix me")
CONFIG_MAC80211_QOS=y
else

@@ -154,7 +153,10 @@ CONFIG_P54_PCI=m
CONFIG_SSB_PCIHOST=y
CONFIG_SSB_DRIVER_PCICORE=y
CONFIG_SSB_B43_PCI_BRIDGE=y
+ifeq ($(shell test $(KERNEL_SUBLEVEL) -gt 22 && echo yes),yes)
+# b44 is not ported to 2.6.22
CONFIG_B44=m
+endif

CONFIG_RTL8180=m
CONFIG_ADM8211=m
--- cw.orig/drivers/net/wireless/libertas/if_usb.c
+++ cw/drivers/net/wireless/libertas/if_usb.c
@@ -947,7 +947,9 @@ static struct usb_driver if_usb_driver =
.id_table = if_usb_table,
.suspend = if_usb_suspend,
.resume = if_usb_resume,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
.reset_resume = if_usb_resume,
+#endif
};

static int __init if_usb_init_module(void)
--- cw.orig/include/net/compat.h
+++ cw/include/net/compat.h
@@ -33,6 +33,7 @@

#include <net/arp.h>
#include <net/neighbour.h>
+#include <net/pkt_sched.h>

#include <linux/compat_autoconf.h>

@@ -173,6 +174,22 @@ static inline int netif_is_multiqueue(co
return (!!(NETIF_F_MULTI_QUEUE & dev->features));
}

+/* 2.6.23 fixed a bug in tcf_destroy_chain and the parameter changed */
+static inline void tcf_destroy_chain_compat(struct tcf_proto **fl)
+{
+ struct tcf_proto *tp;
+
+ while ((tp = *fl) != NULL) {
+ *fl = tp->next;
+ tp->ops->destroy(tp);
+ module_put(tp->ops->owner);
+ kfree(tp);
+ }
+}
+
+#else
+
+#define tcf_destroy_chain_compat tcf_destroy_chain

#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */

--- cw.orig/net/mac80211/wme.c
+++ cw/net/mac80211/wme.c
@@ -310,7 +310,7 @@ static void wme_qdiscop_destroy(struct Q
struct ieee80211_hw *hw = &local->hw;
int queue;

- tcf_destroy_chain(&q->filter_list);
+ tcf_destroy_chain_compat(&q->filter_list);

for (queue = 0; queue < QD_NUM(hw); queue++) {
skb_queue_purge(&q->requeued[queue]);


--
Jiri Benc
SUSE Labs

2008-09-26 23:19:59

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [compat-old PATCH 2/2] Allow compilation on 2.6.22

On Fri, Sep 26, 2008 at 07:20:36AM -0700, Jiri Benc wrote:
> This allows compilation of compat-wireless-old on 2.6.22 kernel. I suspect
> some drivers don't work despite they compile, though.
>
> Signed-off-by: Jiri Benc <[email protected]>

Thanks patches pulled and new compat-wireless-old tarball regenerated.

Luis