From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BFF334D3A9 for ; Wed, 8 Apr 2026 19:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775676167; cv=none; b=n57anVHgCtCA5ZsLYWJqQ3ETc1njV4sWs16vsslJD75+CJqdBnDwhHYtsqoVGDr1v8nLLfdmPJEL0I+Y91XGLbNB7OoQHE6Lc3Zh2TEgvOF75e7ecYKpRG+YKliv065oVgzAEAujPHwi+esKThnsnmUxHYoTLsn8PEZ7cYU0jcc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775676167; c=relaxed/simple; bh=FOGDadXlBxdlXCoO3c6S0SumyHhWL9dtjdG9AXbZ6uI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tq9aDVw3hRaIjjN5cfvhCQLfMoBe2I/BXsdTdIOsdbEd+teRCSwBNDreqGgRbTYYXT2Lv9QrZJewbY36n3M4VS3G5KbUZSeTw8bsxRDhW27+Yynt6Bupm+1T0eoClSVipNeCtgmEOA4RWpleG38tWAG1Rv6kA0KoYWM4CbU5m0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ql6grjlV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ql6grjlV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D08CC19421; Wed, 8 Apr 2026 19:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775676166; bh=FOGDadXlBxdlXCoO3c6S0SumyHhWL9dtjdG9AXbZ6uI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ql6grjlVa/4olc1mRkeAy2QJZrG/Q6ehdCvbcVmGw1Lw8Jyz3PITerQOGNTNQaB9X Ict/6IGztowjdxG4oGShA7tGPE8t3C+ZQoVER3TM5JD4/gyBvUySnIG39dqZ6oTw1F oGQyqNYHNiFv517QjZdwRXx89tPm/SvNfi0WjZc3lBfukNH0EQ9fFB/7ccLQKDDcv+ F5IX9RJkXC9nUXXPylzkJJIm0iYAxg8Qa7Dn/uon5PvLJ3FBYaBYNQq0FPNUIQd8+h lzu7dCxK0j6fffhPZJOTydai7mbQN1yYH1XyMMd/fr6V+iNKckGZt51FROe1p2nf5E DcYF+IJonCrsA== Message-ID: <36618554-367d-4b01-a4f5-6a183abaf918@kernel.org> Date: Wed, 8 Apr 2026 13:22:45 -0600 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] ipv4: nexthop: update has_v4 flag for any family change in replace_nexthop_single() Content-Language: en-US To: Xiang Mei , netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, idosch@nvidia.com, bestswngs@gmail.com References: <20260408182850.2618488-1-xmei5@asu.edu> From: David Ahern In-Reply-To: <20260408182850.2618488-1-xmei5@asu.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/8/26 12:28 PM, Xiang Mei wrote: > When a nexthop within a group is replaced, nh_group_v4_update() is only > called when the old nexthop is AF_INET and the new one is AF_INET6. The > reverse direction (AF_INET6 to AF_INET) is not handled, leaving the > group's has_v4 flag stale at false. > > This causes fib6_check_nexthop() to incorrectly accept an IPv6 route > referencing a group that now contains an AF_INET nexthop. During route > lookup, nexthop_fib6_nh() returns NULL for the AF_INET nexthop and the > subsequent dereference in rt6_find_cached_rt() crashes with a general > protection fault: > ... > > Fix by calling nh_group_v4_update() whenever the old and new nexthops > have different address families, not just for AF_INET to AF_INET6. > Using a general inequality is safe here: individual nexthops can only > be AF_INET or AF_INET6 (enforced at parse time), so the only family > transitions possible are between these two, and nh_group_v4_update() > is a full rescan that always produces the correct has_v4 value. > please add a test to tools/testing/selftests/net/fib_nexthops.sh covering this use case.