<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: "Philippe De Muyter" &lt;phdm@macqel.be&gt;

This patch avoids ppp-generated kernel crashes on machines where unaligned
accesses are forbidden (ie: m68000), by fixing ppp alignment setting for
reused skb's.

Signed-off-by: Philippe De Muyter &lt;phdm@macqel.be&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
---

 drivers/net/ppp_async.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff -puN drivers/net/ppp_async.c~ppp-handle-misaligned-accesses-2 drivers/net/ppp_async.c
--- 25/drivers/net/ppp_async.c~ppp-handle-misaligned-accesses-2	Wed Aug 17 13:47:43 2005
+++ 25-akpm/drivers/net/ppp_async.c	Wed Aug 17 13:48:59 2005
@@ -31,6 +31,7 @@
 #include &lt;linux/spinlock.h&gt;
 #include &lt;linux/init.h&gt;
 #include &lt;asm/uaccess.h&gt;
+#include &lt;asm/string.h&gt;
 
 #define PPP_VERSION	"2.4.2"
 
@@ -835,8 +836,11 @@ process_input_packet(struct asyncppp *ap
  err:
 	/* frame had an error, remember that, reset SC_TOSS &amp; SC_ESCAPE */
 	ap-&gt;state = SC_PREV_ERROR;
-	if (skb)
+	if (skb) {
+		/* make skb appear as freshly allocated */
 		skb_trim(skb, 0);
+		skb_reserve(skb, - skb_headroom(skb));
+	}
 }
 
 /* Called when the tty driver has data for us. Runs parallel with the
@@ -889,10 +893,17 @@ ppp_async_input(struct asyncppp *ap, con
 				skb = dev_alloc_skb(ap-&gt;mru + PPP_HDRLEN + 2);
 				if (skb == 0)
 					goto nomem;
-				/* Try to get the payload 4-byte aligned */
+				ap-&gt;rpkt = skb;
+			}
+			if (skb-&gt;len == 0) {
+				/* 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 to test buf[1] and buf[2].
+				 */
 				if (buf[0] != PPP_ALLSTATIONS)
 					skb_reserve(skb, 2 + (buf[0] &amp; 1));
-				ap-&gt;rpkt = skb;
 			}
 			if (n &gt; skb_tailroom(skb)) {
 				/* packet overflowed MRU */
_
</pre></body></html>