Received: by 10.192.165.156 with SMTP id m28csp1140719imm; Wed, 11 Apr 2018 13:11:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+FNuyidq5E+J43DUI5q/uv9rTGqwLCxTerynOCtf5CcQjSf++z95Tc+NQdTBkg8yC4TDte X-Received: by 10.101.75.135 with SMTP id t7mr4511280pgq.235.1523477508190; Wed, 11 Apr 2018 13:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477508; cv=none; d=google.com; s=arc-20160816; b=Hg+AF3ywXA2wSNlIFMR3XtIIOYvDcoNsn6NbSsGcplr2ZvNuPt9t1Oquza+efFt7Q5 hOaMI4e3y/dvPn9MNnecMtRfGAaOTUqpgup/q/OgkZIpQHr/hi+4nAROvEv0jTExBFWl zxgIFdxfdZnukXjFtOv2WDOq/2nL3b9Tn/Qkwz8fo20WCiQcx+n/3ekGoF4182j+9Z9i 2uXdse2I+qCI06JOA/HTeCyFEHHgjX123Z9pFGxmfzZqRpqXpFRntgrF1+vt7FJ08KBr n2ntOnw+KbF2skdHIkoBR97yhsd4IBiGWWbtUZKsKFmvKhgChwJe8e7zcOCNh+Dv40VE iGiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+NdZxHBPls0HHc0NUxlbY5LoQm0I1AWgxmo2myukTp8=; b=pj68faH8yumtF6Fm9UnHEl7aJGPtfdTrFJy0DaX+itoJEj/ghqTgdb7aAIB8MrG+OD 3cnvP5U9eyU8Jx+gd+vx76M51YF5LB1pp6N4sI0ySdunE04yBIVAvXVYu6D8tJzIoOKm r4Dh2HhzAaGNdNwVUE6ceboqAO2Hr0LRzeWliuibB9y9IkiUSR3cIg5sZU9YFtcRyiyG A9qz1yz9POp1Rmp32At3dLC/cLT5EQZvYNXzzjCF31IwyV0SuXJBJI2tzCXOZmr9SBu/ bZBASd3t+Rm94f3vXufRAyduafh8Rj7ZkqxRjta+le4E4c9wZy3S2YKUvU5YuIZXnxVI 5Phg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k33-v6si1743409pld.158.2018.04.11.13.11.11; Wed, 11 Apr 2018 13:11:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933703AbeDKSz0 (ORCPT + 99 others); Wed, 11 Apr 2018 14:55:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35264 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932962AbeDKSzY (ORCPT ); Wed, 11 Apr 2018 14:55:24 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E0517C06; Wed, 11 Apr 2018 18:55:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ihar Hrachyshka , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 063/310] arp: honour gratuitous ARP _replies_ Date: Wed, 11 Apr 2018 20:33:22 +0200 Message-Id: <20180411183624.941193463@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ihar Hrachyshka [ Upstream commit 23d268eb240954e6e78f7cfab04f2b1e79f84489 ] When arp_accept is 1, gratuitous ARPs are supposed to override matching entries irrespective of whether they arrive during locktime. This was implemented in commit 56022a8fdd87 ("ipv4: arp: update neighbour address when a gratuitous arp is received and arp_accept is set") There is a glitch in the patch though. RFC 2002, section 4.6, "ARP, Proxy ARP, and Gratuitous ARP", defines gratuitous ARPs so that they can be either of Request or Reply type. Those Reply gratuitous ARPs can be triggered with standard tooling, for example, arping -A option does just that. This patch fixes the glitch, making both Request and Reply flavours of gratuitous ARPs to behave identically. As per RFC, if gratuitous ARPs are of Reply type, their Target Hardware Address field should also be set to the link-layer address to which this cache entry should be updated. The field is present in ARP over Ethernet but not in IEEE 1394. In this patch, I don't consider any broadcasted ARP replies as gratuitous if the field is not present, to conform the standard. It's not clear whether there is such a thing for IEEE 1394 as a gratuitous ARP reply; until it's cleared up, we will ignore such broadcasts. Note that they will still update existing ARP cache entries, assuming they arrive out of locktime time interval. Signed-off-by: Ihar Hrachyshka Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/ipv4/arp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -658,6 +658,7 @@ static int arp_process(struct net *net, unsigned char *arp_ptr; struct rtable *rt; unsigned char *sha; + unsigned char *tha = NULL; __be32 sip, tip; u16 dev_type = dev->type; int addr_type; @@ -729,6 +730,7 @@ static int arp_process(struct net *net, break; #endif default: + tha = arp_ptr; arp_ptr += dev->addr_len; } memcpy(&tip, arp_ptr, 4); @@ -847,8 +849,18 @@ static int arp_process(struct net *net, It is possible, that this option should be enabled for some devices (strip is candidate) */ - is_garp = arp->ar_op == htons(ARPOP_REQUEST) && tip == sip && - addr_type == RTN_UNICAST; + is_garp = tip == sip && addr_type == RTN_UNICAST; + + /* Unsolicited ARP _replies_ also require target hwaddr to be + * the same as source. + */ + if (is_garp && arp->ar_op == htons(ARPOP_REPLY)) + is_garp = + /* IPv4 over IEEE 1394 doesn't provide target + * hardware address field in its ARP payload. + */ + tha && + !memcmp(tha, sha, dev->addr_len); if (!n && ((arp->ar_op == htons(ARPOP_REPLY) &&