From: <shenkel@gmail.com>
To: davem@davemloft.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix unaligned accesses in tcp_input_parse
Date: Wed, 16 Mar 2005 12:01:31 +0100 [thread overview]
Message-ID: <16952.4619.28663.456755@gargle.gargle.HOWL> (raw)
Hi!
TCP options are not guaranteed to be aligned at all, so we should use
get_unaligned when accessing u16- or u32-values in the TCP
options header to avoid alignment errors on some platforms. The patch
applies to vanilla 2.6.11.
Ciao,
Sven
Signed-off-by: Sven Henkel <shenkel@gmail.com>
--- linux-2.6.11/net/ipv4/tcp_input.c.orig 2005-03-02 14:43:31.000000000 +0100
+++ linux-2.6.11/net/ipv4/tcp_input.c 2005-03-02 14:43:33.000000000 +0100
@@ -71,6 +71,7 @@
#include <net/tcp.h>
#include <net/inet_common.h>
#include <linux/ipsec.h>
+#include <asm/unaligned.h>
int sysctl_tcp_timestamps = 1;
int sysctl_tcp_window_scaling = 1;
@@ -3007,7 +3008,7 @@ void tcp_parse_options(struct sk_buff *s
switch(opcode) {
case TCPOPT_MSS:
if(opsize==TCPOLEN_MSS && th->syn && !estab) {
- u16 in_mss = ntohs(*(__u16 *)ptr);
+ u16 in_mss = ntohs(get_unaligned((__u16 *)ptr));
if (in_mss) {
if (opt_rx->user_mss && opt_rx->user_mss < in_mss)
in_mss = opt_rx->user_mss;
@@ -3034,8 +3035,8 @@ void tcp_parse_options(struct sk_buff *s
if ((estab && opt_rx->tstamp_ok) ||
(!estab && sysctl_tcp_timestamps)) {
opt_rx->saw_tstamp = 1;
- opt_rx->rcv_tsval = ntohl(*(__u32 *)ptr);
- opt_rx->rcv_tsecr = ntohl(*(__u32 *)(ptr+4));
+ opt_rx->rcv_tsval = ntohl(get_unaligned((__u32 *)ptr));
+ opt_rx->rcv_tsecr = ntohl(get_unaligned((__u32 *)(ptr+4)));
}
}
break;
next reply other threads:[~2005-03-16 11:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-16 11:01 shenkel [this message]
2005-03-16 22:07 ` David S. Miller
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=16952.4619.28663.456755@gargle.gargle.HOWL \
--to=shenkel@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®