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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 6EE20C4360F for ; Thu, 21 Feb 2019 14:48:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3270620700 for ; Thu, 21 Feb 2019 14:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550760524; bh=a/sNo6YEj/nSF+/NSnzlEirgTiUB6Y7Fngsos/fsQ/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ILwCM30WXauSyoOboV3hNk0hq4lOqih9y8VxbhG0rFPXpB+CP48DcU6l6FLfKf2uZ WcjrY2lKBQ+vfngARdnEeWI4U5vgfIu7qL3uZcdq0pZGPJEE7quYbOkRiyN5wiSfpV u25TkhR7a3ErrlbXNdopVyNkJA5quT8FII6vdJgM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729075AbfBUOkO (ORCPT ); Thu, 21 Feb 2019 09:40:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:34352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729047AbfBUOkF (ORCPT ); Thu, 21 Feb 2019 09:40:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2E2620838; Thu, 21 Feb 2019 14:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550760004; bh=a/sNo6YEj/nSF+/NSnzlEirgTiUB6Y7Fngsos/fsQ/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5LHi0LrcgO3BU6HGNGw+L5hpHdFJOsDPcFeeBh0/Icpjg7z3n1USJd3kzNGkA0bC bdkrs1FbJuE0OX2BuqlAkbi3S4WUROIwjP5GCHYYrSsz8rARQIWWBTfrmMuvNnu74e NutJrZJHprnQBYFeP9KyUlfVJWJQ6QKSWQBay23Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhiqiang Liu , Wenhao Zhang , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 02/23] net: fix IPv6 prefix route residue Date: Thu, 21 Feb 2019 15:35:44 +0100 Message-Id: <20190221125246.365144052@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221125246.162644302@linuxfoundation.org> References: <20190221125246.162644302@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit e75913c93f7cd5f338ab373c34c93a655bd309cb ] Follow those steps: # ip addr add 2001:123::1/32 dev eth0 # ip addr add 2001:123:456::2/64 dev eth0 # ip addr del 2001:123::1/32 dev eth0 # ip addr del 2001:123:456::2/64 dev eth0 and then prefix route of 2001:123::1/32 will still exist. This is because ipv6_prefix_equal in check_cleanup_prefix_route func does not check whether two IPv6 addresses have the same prefix length. If the prefix of one address starts with another shorter address prefix, even though their prefix lengths are different, the return value of ipv6_prefix_equal is true. Here I add a check of whether two addresses have the same prefix to decide whether their prefixes are equal. Fixes: 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route for IFA_F_NOPREFIXROUTE") Signed-off-by: Zhiqiang Liu Reported-by: Wenhao Zhang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/addrconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 9ac6f62322946..c47161e92407b 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1124,7 +1124,8 @@ check_cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long *expires) list_for_each_entry(ifa, &idev->addr_list, if_list) { if (ifa == ifp) continue; - if (!ipv6_prefix_equal(&ifa->addr, &ifp->addr, + if (ifa->prefix_len != ifp->prefix_len || + !ipv6_prefix_equal(&ifa->addr, &ifp->addr, ifp->prefix_len)) continue; if (ifa->flags & (IFA_F_PERMANENT | IFA_F_NOPREFIXROUTE)) -- 2.19.1