Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1538215
| Path | csiph.com!news.redatomik.org!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Hannes Frederic Sowa <hannes@stressinduktion.org> |
| Newsgroups | linux.kernel |
| Subject | Re: Misalignment, MIPS, and ip_hdr(skb)->version |
| Date | Thu, 08 Dec 2016 01:40:01 +0100 |
| Message-ID | <sLUUF-7mL-5@gated-at.bofh.it> (permalink) |
| References | <sLPii-3H9-21@gated-at.bofh.it> |
| X-Original-To | "Jason A. Donenfeld" <Jason@zx2c4.com>, Netdev <netdev@vger.kernel.org>, linux-mips@linux-mips.org |
| Dkim-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= stressinduktion.org; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=FQMIIY4d+ctK+VmyW0APhnuW/Ss=; b=OCaJsVgAGWHVHOdtfa2WR /R4B2CDhLYGcORn3Yq4WxZN/wwgJvC7Cmezen31d/b/0SW3zH1KA4RCt0jSvYSTE fOUWaktcj7808TdN0aQgxUPcnXzl8JRvxQlcG7UPci9m2vZI1cmEomy01odil04x aXcQOl1blIbbFFfwh23tZM= |
| Dkim-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=FQMIIY4d+ctK+VmyW0APhnuW/Ss=; b=X6mPDFoiCXmHcDMxNs9P JH2jqtLg99Cqy9KccxwdXwD1iFWqS6DQDVWXshvhHMBTgTw/niWVH8HDqw5aRobQ f7H929QWAe+ObN8jpqsSGJmeHqnYY7n2CkmYDSDHzjgBQPBG2l6Mi9S116vv7QI1 L87HWrbUzR96S5YvE2m871I= |
| X-Me-Sender | <xms:rKlIWKO5nzRQ_d-Jlu2dqndL9eMEQa2hj6tcoXa1dx4J7rZmOAgbgQ> |
| X-Sasl-Enc | EBQ1uLfe/+HBwD78gekAQLWr8x3n1mVlMmgP/nckBxyS 1481157036 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 43 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | LKML <linux-kernel@vger.kernel.org>, WireGuard mailing list <wireguard@lists.zx2c4.com> |
| X-Original-Date | Thu, 8 Dec 2016 01:30:34 +0100 |
| X-Original-Message-ID | <095cac5b-b757-6f4a-e699-8eedf9ed7221@stressinduktion.org> |
| X-Original-References | <CAHmME9o_eCNXpVztOZKW55kpRtE+1KSEQTQOjUBVn68Y2+or2g@mail.gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1538215 |
Show key headers only | View raw
Hi Jason, On 07.12.2016 19:35, Jason A. Donenfeld wrote: > I receive encrypted packets with a 13 byte header. I decrypt the > ciphertext in place, and then discard the header. I then pass the > plaintext to the rest of the networking stack. The plaintext is an IP > packet. Due to the 13 byte header that was discarded, the plaintext > possibly begins at an unaligned location (depending on whether > dev->needed_headroom was respected). > > Does this matter? Is this bad? Will there be a necessary performance hit? Your custom protocol should be designed in a way you get an aligned ip header. Most protocols of the IETF follow this mantra and it is always possible to e.g. pad options so you end up on aligned boundaries for the next header. GRE-TEB for example needs skb_copy_bits to extract the header so it can access them in an aligned way. > In order to find out, I instrumented the MIPS unaligned access > exception handler to see where I was actually in trouble. > Surprisingly, the only part of the stack that seemed to be upset was > on calls to ip_hdr(skb)->version. > > Two things disturb me about this. First, this seems too good to be > true. Does it seem reasonable to you that this is actually the only > place that would be problematic? Or was my testing methodology wrong > to arrive at such an optimistic conclusion? > > Secondly, why should a call to ip_hdr(skb)->version cause an unaligned > access anyway? This struct member is simply the second half of a > single byte in a bit field. I'd expect for the compiler to generate a > single byte load, followed by a bitshift or a mask. Instead, the > compiler appears to generate a double byte load, hence the exception. > What's up with this? Stupid compiler that should be fixed? Some odd > optimization? What to do? I don't see an issue with that at all. Why do you think it could be a problem? Bye, Hannes
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Misalignment, MIPS, and ip_hdr(skb)->version "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-07 19:40 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Dave Taht <dave.taht@gmail.com> - 2016-12-07 19:50 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-07 20:00 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version David Miller <davem@davemloft.net> - 2016-12-07 21:00 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-08 01:40 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version David Miller <davem@davemloft.net> - 2016-12-08 01:40 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version "Jason A. Donenfeld" <Jason@zx2c4.com> - 2016-12-08 23:30 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version David Miller <davem@davemloft.net> - 2016-12-09 00:20 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Willy Tarreau <w@1wt.eu> - 2016-12-11 09:10 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Felix Fietkau <nbd@nbd.name> - 2016-12-10 13:30 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Måns Rullgård <mans@mansr.com> - 2016-12-10 14:30 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Felix Fietkau <nbd@nbd.name> - 2016-12-10 21:20 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Felix Fietkau <nbd@nbd.name> - 2016-12-10 21:40 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Måns Rullgård <mans@mansr.com> - 2016-12-10 21:40 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version David Miller <davem@davemloft.net> - 2016-12-07 20:00 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Hannes Frederic Sowa <hannes@stressinduktion.org> - 2016-12-08 01:40 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Daniel Kahn Gillmor <dkg@fifthhorseman.net> - 2016-12-08 06:10 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Jiri Benc <jbenc@redhat.com> - 2016-12-09 12:30 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Dan Lüdtke <mail@danrl.com> - 2016-12-10 23:30 +0100
Re: Misalignment, MIPS, and ip_hdr(skb)->version Greg KH <gregkh@linuxfoundation.org> - 2016-12-11 08:20 +0100
csiph-web