public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* PATCH : ppp + big-endian = kernel crash
@ 2005-05-29 19:48 Philippe De Muyter
  2005-05-29 20:52 ` David S. Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Philippe De Muyter @ 2005-05-29 19:48 UTC (permalink / raw)
  To: linux-kernel

Hello all,

My m68k linux crashed often in ksoftirqd/0 with an `address error' (word
access to an even address) in function ip_rcv, at line 405 (line numbers
valid in current sources as of 2005-05-29) of net/ipv4/ip_input.c,
failing to execute :

	    405                 __u32 len = ntohs(iph->tot_len);

because iph was odd, tot_len is a 16-bit field and ntohs is a nop on
big-endian machines.

I searched the origin of that odd pointer, and found it in
process_input_packet at line 819 of drivers/net/ppp_async.c :

	    819                 skb_push(skb, 1)[0] = 0; 

This subtracts 1 from the packet address, yielding an odd pointer if
we had an even one and conversely.  My proposed fix is below.

Feel free to apply that to the main source trees.

Philippe

Philippe De Muyter  phdm at macqel dot be  Tel +32 27029044
Macq Electronique SA  rue de l'Aeronef 2  B-1140 Bruxelles  Fax +32 27029077

--- ppp_async.c.orig	2005-05-29 20:28:44.000000000 +0200
+++ ppp_async.c	2005-05-29 21:16:16.000000000 +0200
@@ -817,6 +817,16 @@
 	if (proto & 1) {
 		/* protocol is compressed */
 		skb_push(skb, 1)[0] = 0;
+		/* If the address of the packet is odd now, fix it. */
+		if ((unsigned long)skb->data & 1) {
+			unsigned char *p;
+			int n;
+
+			p = skb_put(skb, 1);
+			for (n = skb->len; --n >= 0; p -= 1)
+				p[0] = p[-1];
+			skb_pull(skb, 1);
+		}
 	} else {
 		if (skb->len < 2)
 			goto err;
@@ -890,6 +900,12 @@
 				if (skb == 0)
 					goto nomem;
 				/* Try to get the payload 4-byte aligned */
+				/* This should match the
+				** PPP_ALLSTATIONS/PPP_UI/compressed tests
+				** in process_input_packet,
+				** but we do not have enough chars here and
+				** now to test buf[1] and buf[2].
+				*/
 				if (buf[0] != PPP_ALLSTATIONS)
 					skb_reserve(skb, 2 + (buf[0] & 1));
 				ap->rpkt = skb;

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: PATCH : ppp + big-endian = kernel crash
@ 2005-05-30 14:05 Greg Ungerer
  0 siblings, 0 replies; 11+ messages in thread
From: Greg Ungerer @ 2005-05-30 14:05 UTC (permalink / raw)
  To: linux-kernel

Andi Kleen <ak () muc ! de> writes:
> Andrew Morton <akpm@osdl.org> writes:
>>> 
>>> So many variants of tunneling and protocol encapsulation can result in
>>> unaligned packet headers, and as a result platforms really must
>>> provide proper unaligned memory access handling in kernel mode in
>>> order to use the networking fully.
>>
>> As Philippe mentioned, old 68k's simply cannot do this.
> 
> An 68000 cannot, but 68010+ can. Are there really that many 68000 users
> left? 

Probably not of the 68000 as such, but the "new" generation of
68000 parts, Motorola/Freescales ColdFire family. There is quite
a few of them, used in all sorts of embedded applications.
And they are still churning out new varients of it. The majority
of them are MMUless - but not all.

Regards
Greg


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-06-01 15:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-29 19:48 PATCH : ppp + big-endian = kernel crash Philippe De Muyter
2005-05-29 20:52 ` David S. Miller
2005-05-29 21:38   ` Philippe De Muyter
2005-05-29 21:55     ` David S. Miller
2005-05-30  2:52       ` Andrew Morton
2005-05-30  3:11         ` David S. Miller
2005-06-01 15:26           ` Philippe De Muyter
2005-05-30 10:22         ` Andi Kleen
2005-05-30 13:01           ` cutaway
2005-05-30  7:16   ` Giuliano Pochini
  -- strict thread matches above, loose matches on Subject: below --
2005-05-30 14:05 Greg Ungerer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox