Message ID | 20120307120707.933695671@de.ibm.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
> static const struct xid2 init_xid = { > @@ -132,7 +132,7 @@ void ctcmpc_dumpit(char *buf, int len) > __u32 ct, sw, rm, dup; > char *ptr, *rptr; > char tbuf[82], tdup[82]; > - #if (UTS_MACHINE == s390x) > + #ifdef CONFIG_64BIT > char addr[22]; > #else > char addr[12]; > @@ -149,8 +149,8 @@ void ctcmpc_dumpit(char *buf, int len) > > for (ct = 0; ct < len; ct++, ptr++, rptr++) { > if (sw == 0) { > - #if (UTS_MACHINE == s390x) > - sprintf(addr, "%16.16lx", (__u64)rptr); > + #ifdef CONFIG_64BIT > + sprintf(addr, "%16.16llx", (__u64)rptr); > #else > sprintf(addr, "%8.8X", (__u32)rptr); > #endif What is wrong with: char addr[24]; snprintf(addr, sizeof addr, "%p", rptr); There seemed to be other 'dangerous' unbounded string operations in that code as well. David -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff -urpN linux-2.6/drivers/s390/net/ctcm_main.c linux-2.6-patched/drivers/s390/net/ctcm_main.c --- linux-2.6/drivers/s390/net/ctcm_main.c 2012-01-05 00:55:44.000000000 +0100 +++ linux-2.6-patched/drivers/s390/net/ctcm_main.c 2012-03-06 13:36:00.000000000 +0100 @@ -562,6 +562,9 @@ static int ctcm_transmit_skb(struct chan skb_queue_tail(&ch->io_queue, skb); ccw_idx = 3; } + if (do_debug_ccw) + ctcmpc_dumpit((char *)&ch->ccw[ccw_idx], + sizeof(struct ccw1) * 3); ch->retry = 0; fsm_newstate(ch->fsm, CTC_STATE_TX); fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch); diff -urpN linux-2.6/drivers/s390/net/ctcm_mpc.c linux-2.6-patched/drivers/s390/net/ctcm_mpc.c --- linux-2.6/drivers/s390/net/ctcm_mpc.c 2012-01-05 00:55:44.000000000 +0100 +++ linux-2.6-patched/drivers/s390/net/ctcm_mpc.c 2012-03-06 13:36:00.000000000 +0100 @@ -53,8 +53,8 @@ #include <linux/moduleparam.h> #include <asm/idals.h> -#include "ctcm_mpc.h" #include "ctcm_main.h" +#include "ctcm_mpc.h" #include "ctcm_fsms.h" static const struct xid2 init_xid = { @@ -132,7 +132,7 @@ void ctcmpc_dumpit(char *buf, int len) __u32 ct, sw, rm, dup; char *ptr, *rptr; char tbuf[82], tdup[82]; - #if (UTS_MACHINE == s390x) + #ifdef CONFIG_64BIT char addr[22]; #else char addr[12]; @@ -149,8 +149,8 @@ void ctcmpc_dumpit(char *buf, int len) for (ct = 0; ct < len; ct++, ptr++, rptr++) { if (sw == 0) { - #if (UTS_MACHINE == s390x) - sprintf(addr, "%16.16lx", (__u64)rptr); + #ifdef CONFIG_64BIT + sprintf(addr, "%16.16llx", (__u64)rptr); #else sprintf(addr, "%8.8X", (__u32)rptr); #endif @@ -164,8 +164,8 @@ void ctcmpc_dumpit(char *buf, int len) if (sw == 8) strcat(bhex, " "); - #if (UTS_MACHINE == s390x) - sprintf(tbuf, "%2.2lX", (__u64)*ptr); + #if CONFIG_64BIT + sprintf(tbuf, "%2.2llX", (__u64)*ptr); #else sprintf(tbuf, "%2.2X", (__u32)*ptr); #endif