From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BD48C2F3A0 for ; Mon, 21 Jan 2019 12:48:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E41692085A for ; Mon, 21 Jan 2019 12:48:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oYGHIJJy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728717AbfAUMsP (ORCPT ); Mon, 21 Jan 2019 07:48:15 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37672 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728490AbfAUMsP (ORCPT ); Mon, 21 Jan 2019 07:48:15 -0500 Received: by mail-lf1-f66.google.com with SMTP id y11so15415569lfj.4 for ; Mon, 21 Jan 2019 04:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language; bh=/ZJ2GzTVFAK2hrAu3sLorLjKppWbd0X2/qZ4I7afe7w=; b=oYGHIJJyBtrxay5fwhzfCsg+Cby6HBFkLOGZaZSabKBpJ7wfY9bXsKyKRwAL8whsuM vfbKy0Dv/ZJtIpSl8XKE/ZD893eIAJm5E1RRImiH1WGm8WRdzyEuld9lfW7d6CcNniWM jPCe38aqL8Y7m1Pz4mKxRfCscBQyspIa+UANQUff66FbUYtcth7ik1yXX1fGu3L3uQcP FtQUHXW4kHmEdZnVVivRYponMRAboujUfZtynBcGYe6bMM+rAJ39K39wg4ds3nw2zykl MoBDQjU8im7G1MPK1TMEVRlQhoIg2+GEEkebwm9RD+m/3+oRLg2a8EMk/uZhoSg0q7SP wi3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language; bh=/ZJ2GzTVFAK2hrAu3sLorLjKppWbd0X2/qZ4I7afe7w=; b=CdTwf5krDPD965+EPnaAbY7O+4vyoOr8nG5RJ1jixl866TucVfMOxhtQjOuZmWTJuD vPSfp/HfQC/EwGdePhSms6NxdGKr5VIixXpLSajkxAtjBHShJLoyH0pA+OWLaJ3xLPaw TQgfG9lQjSBfwLXSZjXZTV4S7pJ3GCAroZ8fiMsoQOw8JAQqRNvPArrKk2hQEeextu9G krupIuZ0KF8R8nQbL9WXV20bBymQjOiQnpSM57la8v7jHImCol9dcWaPcggo9HLsbiK7 SYZWBNoJBPHap0xH5E94JgI37bdS137UUUp02kVTzlemwOAfUoutqXW1Lpd7tLt2FJzj dmLg== X-Gm-Message-State: AJcUukeQkufT5gGA+UK+EigIrqXP5VfrusSqAG/7n1iyhkf60HhiCKDr erUMUuuilAMqrsfIBXzwFsvzcFDP X-Google-Smtp-Source: ALg8bN5c+KVKpCQgGREWsdtz6XNbzsnXqzK8k7ufokrkqma5OdOOixAUn1SyxiK/WoWKbphaca2T5w== X-Received: by 2002:a19:6f0a:: with SMTP id k10mr17649899lfc.119.1548074893875; Mon, 21 Jan 2019 04:48:13 -0800 (PST) Received: from ?IPv6:2a00:1370:8125:2f36:4dbc:4c13:87:1288? ([2a00:1370:8125:2f36:4dbc:4c13:87:1288]) by smtp.googlemail.com with ESMTPSA id g17sm2388916lfj.36.2019.01.21.04.48.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jan 2019 04:48:13 -0800 (PST) From: "Yuriy M. Kaminskiy" Subject: [PATCH] lan78xx: fix ip header misalignment To: netdev@vger.kernel.org Cc: Woojung Huh , Microchip Linux Driver Support Message-ID: <53800bc3-397a-ed1a-958d-a1dbc887d249@gmail.com> Date: Mon, 21 Jan 2019 15:48:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C858CFA92304514489E584E5" Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a multi-part message in MIME format. --------------C858CFA92304514489E584E5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit lan78xx.c:rx_submit() allocates space for frame-to-be-received with netdev_alloc_skb_ip_align(), which misalign start of buffer by 2 bytes in expectation that frame will start from 14-byte ethernet header, then ip header; if start of buffer misaligned by 2 bytes, ip header will be 16-byte aligned. Unfortunately, usb frame that is sent by lan78xx starts with another 10-byte header (lan78xx_rx(): rx_cmd_a/rx_cmd_b/rx_cmd_c), *then* follows ethernet header, and *then* ip header (which ends up being misaligned). This issue was observed on arm platform (where misaligned 32-bit word access triggers exception and leaves traces in /proc/cpu/alignment, see https://github.com/raspberrypi/linux/issues/2599 ; for me, about any ipv6 traffic that hits machine - `ping -I eth0 ip6-allnodes`, tcp/udp packets, etc triggered increase in this counter, with ip6_datagram_recv_common_ctl, icmpv6_echo_reply, etc as culprit). If we just allocate skb data without any misalignment tricks, ip header will end up and at offset 24 (8-byte aligned). Patch attached; runtime-tested with raspbian fork of stable/4.14.y [4.14.92] on Raspberry pi 3B+ (it is slightly different from mainline, but patch should not have any conflicts, all affected code is pretty same). P.S. I'm not subscribed, please CC me on reply. --------------C858CFA92304514489E584E5 Content-Type: text/x-patch; name="0001-lan78xx-fix-ip-header-misalignment.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-lan78xx-fix-ip-header-misalignment.patch" >From 2bd6b0a11e222be2df97da948924c71bf13d7192 Mon Sep 17 00:00:00 2001 From: "Yuriy M. Kaminskiy" Date: Mon, 21 Jan 2019 02:51:24 +0300 Subject: [PATCH] lan78xx: fix ip header misalignment As lan78xx prepends 10-byte header before ether_hdr, skb->data misalignment trick by netdev_alloc_skb_ip_align() made things worse (ip_hdr becomes always misaligned). See https://github.com/raspberrypi/linux/issues/2599 --- drivers/net/usb/lan78xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 9b782cdf8..d64b0d3b8 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3143,7 +3143,7 @@ static int rx_submit(struct lan78xx_net *dev, struct urb *urb, gfp_t flags) size_t size = dev->rx_urb_size; int ret = 0; - skb = netdev_alloc_skb_ip_align(dev->net, size); + skb = netdev_alloc_skb(dev->net, size); if (!skb) { usb_free_urb(urb); return -ENOMEM; -- 2.11.0 --------------C858CFA92304514489E584E5--