From patchwork Wed Sep 28 20:19:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Leitner X-Patchwork-Id: 116854 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 82AD0B6F9A for ; Thu, 29 Sep 2011 06:20:04 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753914Ab1I1UT5 (ORCPT ); Wed, 28 Sep 2011 16:19:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752221Ab1I1UT4 (ORCPT ); Wed, 28 Sep 2011 16:19:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8SKJt4v017923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Sep 2011 16:19:55 -0400 Received: from asterix.rh (ovpn-113-51.phx2.redhat.com [10.3.113.51]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8SKJrrK030356; Wed, 28 Sep 2011 16:19:54 -0400 Date: Wed, 28 Sep 2011 17:19:52 -0300 From: Flavio Leitner To: David Miller Cc: netdev@vger.kernel.org Subject: Re: ICMP redirect issue Message-ID: <20110928171952.0c0d2d05@asterix.rh> In-Reply-To: <20110928.140632.726302773135946390.davem@davemloft.net> References: <20110927162120.30394030@asterix.rh> <20110928.140632.726302773135946390.davem@davemloft.net> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 28 Sep 2011 14:06:32 -0400 (EDT) David Miller wrote: > From: Flavio Leitner > Date: Tue, 27 Sep 2011 16:21:20 -0300 > > > The issue is about the gateway being a LVS, so the servers behind > > use the IP alias address as the default gateway. However, when the > > gateway sends an ICMP redirect, it comes from the primary IP > > address which is ignored on older kernels because of the old_gw > > check: > > > > - if (rth->rt_dst != daddr || > > - rth->rt_src != saddr || > > - rth->dst.error || > > - rth->rt_gateway != old_gw || > > - rth->dst.dev != dev) > > - break; > > > > > > Well, the consequence is that the issue doesn't happen in newer > > kernels because it happily accepts the ICMP redirect. > > > > The admin can still control using shared_media and secure_redirects > > if the host should accept only the ICMP redirects for gateways > > listed in default gateway list or not. > > Unfortunately, shared_media is on by default which means the default > secure_redirects setting of '1' is ignored. > > This means that redirects can be spoofed in the default configuration, > but with the above check they would not be spoofable. I fail to see what that check is preventing because if someone manages to inject a redirect packet into the network, then likely the old_gw can be tweaked to be the network gateway. > I suspect that, because of this, we'll need to add the check back. Or > do something similar. > > We can't "fix" this by turning shared_media off by default because > that changes behavior on input route processing wrt. how we decide > whether to emit a redirect or not. What about something like below? It will change a bit the secure_redirects documentation. shared_media secure_redirect behavior: 0 0 all pass. 0 1 only from gateways and for gateways. 1 0 all pass. 1 1 default, old behavior, only from gateways. If you agree with the approach, I'll run tests here and post the patch with a proper changelog, documentation and signed-off. thanks, fbl --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 075212e..fa00fcd 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1332,6 +1332,9 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, goto reject_redirect; } + if (IN_DEV_SEC_REDIRECTS(in_dev) && ip_fib_check_default(old_gw, dev)) + goto reject_redirect; + peer = inet_getpeer_v4(daddr, 1); if (peer) { peer->redirect_learned.a4 = new_gw;