Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2233584yba; Mon, 22 Apr 2019 03:02:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrfyqJzzDg3zXRThtkxjDFffQAopzP1jTxhAkZndY/HG/VT5+Om21LcbEHYnQmQLly3wh2 X-Received: by 2002:a17:902:1e2:: with SMTP id b89mr18653353plb.278.1555927334099; Mon, 22 Apr 2019 03:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555927334; cv=none; d=google.com; s=arc-20160816; b=Utv7pq2VSTcpviO6EyQcVmt+Lv0y/8zODfQjnUBpgx23jLlPyhXwXGWzHi81JO9BEY nvsPqBjfNtR2pjPZ21+O8d/EEipBsWGZeTTQ5KphBfO3buIemx5F33md1JWqeg5TaHN7 MTJjIKxrl6MavvUIVwLUppogIEIh4o2POHYOowJdUl4UfJfpml20v7qMsReFsU0murxv 4PZRPGR/vTMHduvgSl3mW8rXNmxgoDL3s5QI3wJfE3NIw9owL7kTYL5+jej5oSEeNCft uxIn2iGtP91sBs+rglHOl4nZ8xKdt5PI4I6T+FOXxWTBd5nloTokquesXsRayzBg/Up7 FxPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/8Ia0lr8SyGRhLNV/rp9b91j7HYQOCib8nOzsqqsR1w=; b=hAEYLTJtftlBNmbgmdrLWlicEdJMBOQpDiFEiYFkwW4XbrOCy5IGGmRmIIGQlzxD4n 9+CyoazE/tZYhry5uluMYVYI77h8ZXSxskUIo/wCWp7eW2Iy2J73va0pEuQLOnN3vjUE Fbk19rUB9InztPm3LG1g4uRIpOBp8rIpO16z/w4dBgTXefqeExzdi7b4WZ5bcBXj7eK0 nU1sjI9mvxcPr26N98zqrlO9qRcvqg9s+h2gjEAIyqdItvA0VSkq3qGT08qylkX2egKm M72dX8iw7dWVZp3OEzmEsvHbJUMMyrQQR5HhJSC+5I9fm83dlNrM5Grt5pVugPOUmLou 3eGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pEpJ7+By; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t16si11522038pgu.344.2019.04.22.03.01.58; Mon, 22 Apr 2019 03:02:14 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pEpJ7+By; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbfDVJvl (ORCPT + 99 others); Mon, 22 Apr 2019 05:51:41 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:34119 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbfDVJvk (ORCPT ); Mon, 22 Apr 2019 05:51:40 -0400 Received: by mail-vs1-f66.google.com with SMTP id t78so5931293vsc.1; Mon, 22 Apr 2019 02:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/8Ia0lr8SyGRhLNV/rp9b91j7HYQOCib8nOzsqqsR1w=; b=pEpJ7+BypWkwhgcSpVHj0qLYBolMmeAMuAtX5eJAEm2Wn3Qf381fMH5Troh49WspWb 6kbK20Ha6eJQWH05TBiZbumKsJBsls3sfA9mKJXaabWvAvAUG+6nvSfhRCJjURjgvwoh Kv+RNVhctOqkmrruS5cPLg7QiLwzk9eKz5ghmtZO68/b9qOqkasAzJXWLK5jqzr6Qbiq cVrDkEhDtu+vMXDWOCiLvC44J4A7cQyqOZM5Be+wyDpXldYIm2KSg/JjKNqRHpxNgcMf YjH1DS8BM8yELgO98GJE7ocPDrQhUPElc2CId+orI+69tOS8/PtiOii03XR0OzEDNCeN DcIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/8Ia0lr8SyGRhLNV/rp9b91j7HYQOCib8nOzsqqsR1w=; b=tA0arxJxjj44vHVgKf4mW6PvmLtvLtWBe7gbsAOtJAC5sVzZAvrRuzmAEJjlzw+0bE d4O9PjcX1Nucb6gShu1+2zDajiyr+mgtuuR294RIgLJGQrc+xWv4Veg2IBdzJCMqIIF7 fXAY1sZnz3WRjq8ISF74miH5YZhDNLKNYtFvgekv4f+1eIFtjFrAz5zvWOv1+IBMU1TY gjmM5LTUpumJiYZBlVr+/w19YMQxyf2XRhr2onb1dCG8qACRJTsBPwZy3coFqWlR89wX y8yYU8MssM54zU/NyiExZ2nT2jaAleooqes5/c/dkiNAbCX3C22Ypmgzr7YpkENkHZMW Swvg== X-Gm-Message-State: APjAAAUKqvqHYobo0nOKXa0M8uzth8On/mZeRlxPbQsdLJHzWLxMYnSq piAO+JgTznSn92lfYfylHbDiDb0I7hu5kjYXEQ== X-Received: by 2002:a67:e881:: with SMTP id x1mr9854243vsn.48.1555926699737; Mon, 22 Apr 2019 02:51:39 -0700 (PDT) MIME-Version: 1.0 References: <20190409065612.32652-1-rdong.ge@gmail.com> <20190422083339.ptkxqb66pombgy5g@salvia> <20190422093502.36da6z3qf7zxpwny@breakpoint.cc> In-Reply-To: <20190422093502.36da6z3qf7zxpwny@breakpoint.cc> From: Rundong Ge Date: Mon, 22 Apr 2019 17:51:28 +0800 Message-ID: Subject: Re: [PATCH] netfilter: fix dangling pointer access of fake_rtable To: Florian Westphal Cc: Pablo Neira Ayuso , kadlec@blackhole.kfki.hu, Roopa Prabhu , davem@davemloft.net, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org skb->dev is munged in setup_prerouting() to be bridge or vlan device on top of bridge. --Yes, but br_nf_pre_routing_finish will set the skb->dev back to the phyi= ndev. Florian Westphal =E4=BA=8E2019=E5=B9=B44=E6=9C=8822=E6=97=A5= =E5=91=A8=E4=B8=80 =E4=B8=8B=E5=8D=885:35=E5=86=99=E9=81=93=EF=BC=9A > > Rundong Ge wrote: > > br_nf_pre_routing will call the NF_INET_PRE_ROUTING hooks, at this > > time both entry->state.in and entry->state.out are not bridge device. > > > > NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb, > > skb->dev, NULL, > > br_nf_pre_routing_finish); > > skb->dev is munged in setup_prerouting() to be bridge or vlan device on > top of bridge. > > That being said, I think we need this fix at least: > > diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c > --- a/net/netfilter/nf_queue.c > +++ b/net/netfilter/nf_queue.c > @@ -197,8 +197,15 @@ static int __nf_queue(struct sk_buff *skb, const str= uct nf_hook_state *state, > .size =3D sizeof(*entry) + route_key_size, > }; > > + if (skb_dst(skb)) { > + skb_dst_force(skb); > + if (!skb_dst(skb)) { > + status =3D -EHOSTUNREACH; > + goto err; > + } > + } > + > nf_queue_entry_get_refs(entry); > - skb_dst_force(skb); > > switch (entry->state.pf) { > case AF_INET: > > > Then, why not add, in dev_cmp: > > dst =3D skb_dst(skb); > if (dst && dst->dev->index =3D=3D index ... > > ?