public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@redhat.com>
To: Mika.Liljeberg@welho.com
Cc: kuznet@ms2.inr.ac.ru, Mika.Liljeberg@nokia.com,
	linux-kernel@vger.kernel.org, sarolaht@cs.helsinki.fi
Subject: Re: TCP LAST-ACK state broken in 2.4.17-pre2 [NEW DATA]
Date: Tue, 18 Dec 2001 12:28:13 -0800 (PST)	[thread overview]
Message-ID: <20011218.122813.63057831.davem@redhat.com> (raw)
In-Reply-To: <3C1FA558.E889A00D@welho.com>
In-Reply-To: <200112181837.VAA10394@ms2.inr.ac.ru> <3C1FA558.E889A00D@welho.com>

   From: Mika Liljeberg <Mika.Liljeberg@welho.com>
   Date: Tue, 18 Dec 2001 22:21:44 +0200
   
   Now that you mention it, tcp_parse_options() in input.c seems to expect
   that the timestamps are word aligned, which is not the case here, and a
   false assumption in any case. I would have expected a bus error for
   that, unless the pointer cast generates code that magically word aligns
   the resulting pointer...

Unaligned kernel loads and stores must be properly handled by the
platform code, and on ARM chips where that is possible it is.

Nevertheless, if you'd like to rule this out, please try the
patch below:

diff -u --recursive --new-file --exclude=CVS --exclude=.cvsignore vanilla/linux/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c
--- vanilla/linux/net/ipv4/tcp_input.c	Tue Oct 30 15:08:12 2001
+++ linux/net/ipv4/tcp_input.c	Tue Nov  6 15:48:01 2001
@@ -1987,6 +1987,18 @@
 	return 0;
 }
 
+static __inline__ __u16 tcp_options_get16(unsigned char *p)
+{
+	return ((__u16) p[0] << 8) | (__u16) p[1];
+}
+
+static __inline__ __u32 tcp_options_get32(unsigned char *p)
+{
+	return (((__u32) p[0] << 24) |
+		((__u32) p[1] << 16) |
+		((__u32) p[2] <<  8) |
+		((__u32) p[3] <<  0));
+}
 
 /* Look for tcp options. Normally only called on SYN and SYNACK packets.
  * But, this can also be called on packets in the established flow when
@@ -2020,7 +2032,7 @@
 	  			switch(opcode) {
 				case TCPOPT_MSS:
 					if(opsize==TCPOLEN_MSS && th->syn && !estab) {
-						u16 in_mss = ntohs(*(__u16 *)ptr);
+						u16 in_mss = tcp_options_get16(ptr);
 						if (in_mss) {
 							if (tp->user_mss && tp->user_mss < in_mss)
 								in_mss = tp->user_mss;
@@ -2047,8 +2059,8 @@
 						if ((estab && tp->tstamp_ok) ||
 						    (!estab && sysctl_tcp_timestamps)) {
 							tp->saw_tstamp = 1;
-							tp->rcv_tsval = ntohl(*(__u32 *)ptr);
-							tp->rcv_tsecr = ntohl(*(__u32 *)(ptr+4));
+							tp->rcv_tsval = tcp_options_get32(ptr);
+							tp->rcv_tsecr = tcp_options_get32(ptr + 4);
 						}
 					}
 					break;

  reply	other threads:[~2001-12-18 20:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-18  9:33 TCP LAST-ACK state broken in 2.4.17-pre2 [NEW DATA] Mika.Liljeberg
2001-12-18 18:37 ` kuznet
2001-12-18 20:21   ` Mika Liljeberg
2001-12-18 20:28     ` David S. Miller [this message]
2001-12-18 20:29     ` ARM: " kuznet
2001-12-18 20:52       ` Mika Liljeberg
2001-12-18 21:08         ` David S. Miller
2001-12-18 21:03       ` Russell King
2001-12-18 21:11         ` David S. Miller
2001-12-18 21:14           ` Russell King
2001-12-18 21:15             ` David S. Miller
2001-12-18 21:27               ` Mika Liljeberg
2001-12-18 21:24           ` Rik van Riel
2001-12-18 21:28             ` Russell King
2001-12-18 21:33             ` David S. Miller
2001-12-20  7:31     ` Stevie O
2001-12-20  7:40       ` David S. Miller
2001-12-20  7:51       ` Stevie O
2001-12-20  8:58         ` Russell King
2001-12-20  9:01       ` Russell King
2001-12-20 10:22       ` David Weinehall
2002-01-02 19:52         ` Mike Touloumtzis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011218.122813.63057831.davem@redhat.com \
    --to=davem@redhat.com \
    --cc=Mika.Liljeberg@nokia.com \
    --cc=Mika.Liljeberg@welho.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sarolaht@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox