lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzikD3a8VGTpAiJg@pop-os.localdomain>
Date:   Sat, 1 Oct 2022 13:33:19 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Paul Blakey <paulb@...dia.com>
Cc:     Daniel Borkmann <daniel@...earbox.net>,
        Vlad Buslov <vladbu@...dia.com>, Oz Shlomo <ozsh@...dia.com>,
        Roi Dayan <roid@...dia.com>, netdev@...r.kernel.org,
        Saeed Mahameed <saeedm@...dia.com>,
        Eric Dumazet <edumazet@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net v2 1/2] net: Fix return value of qdisc ingress
 handling on success

On Sat, Oct 01, 2022 at 01:19:50PM -0700, Cong Wang wrote:
> On Wed, Sep 28, 2022 at 10:55:49AM +0300, Paul Blakey wrote:
> > 
> > 
> > On 25/09/2022 21:00, Cong Wang wrote:
> > > On Sun, Sep 25, 2022 at 11:14:21AM +0300, Paul Blakey wrote:
> > > > Currently qdisc ingress handling (sch_handle_ingress()) doesn't
> > > > set a return value and it is left to the old return value of
> > > > the caller (__netif_receive_skb_core()) which is RX drop, so if
> > > > the packet is consumed, caller will stop and return this value
> > > > as if the packet was dropped.
> > > > 
> > > > This causes a problem in the kernel tcp stack when having a
> > > > egress tc rule forwarding to a ingress tc rule.
> > > > The tcp stack sending packets on the device having the egress rule
> > > > will see the packets as not successfully transmitted (although they
> > > > actually were), will not advance it's internal state of sent data,
> > > > and packets returning on such tcp stream will be dropped by the tcp
> > > > stack with reason ack-of-unsent-data. See reproduction in [0] below.
> > > > 
> > > 
> > > Hm, but how is this return value propagated to egress? I checked
> > > tcf_mirred_act() code, but don't see how it is even used there.
> > > 
> > > 318         err = tcf_mirred_forward(want_ingress, skb2);
> > > 319         if (err) {
> > > 320 out:
> > > 321                 tcf_action_inc_overlimit_qstats(&m->common);
> > > 322                 if (tcf_mirred_is_act_redirect(m_eaction))
> > > 323                         retval = TC_ACT_SHOT;
> > > 324         }
> > > 325         __this_cpu_dec(mirred_rec_level);
> > > 326
> > > 327         return retval;
> > > 
> > > 
> > > What am I missing?
> > 
> > for the ingress acting act_mirred it will return TC_ACT_CONSUMED above
> > the code you mentioned (since redirect=1, use_reinsert=1. Although
> > TC_ACT_STOLEN which is the retval set for this action, will also act the
> > same)
> > 
> > 
> > It is propagated as such (TX stack starting from tcp):
> > 
> 
> Sorry for my misunderstanding.
> 
> I meant to say those TC_ACT_* return value, not NET_RX_*, but I worried
> too much here, as mirred lets user specify the return value.
> 
> BTW, it seems you at least miss the drop case, which is NET_RX_DROP for
> TC_ACT_SHOT at least? Possibly other code paths in sch_handle_ingress()
> too.
> 

I mean:

diff --git a/net/core/dev.c b/net/core/dev.c
index fa53830d0683..d1db8210d671 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5109,6 +5109,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
        struct mini_Qdisc *miniq = rcu_dereference_bh(skb->dev->miniq_ingress);
        struct tcf_result cl_res;

+       *ret = NET_RX_SUCCESS;
        /* If there's at least one ingress present somewhere (so
         * we get here via enabled static key), remaining devices
         * that are not configured with an ingress qdisc will bail
@@ -5136,6 +5137,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
        case TC_ACT_SHOT:
                mini_qdisc_qstats_cpu_drop(miniq);
                kfree_skb_reason(skb, SKB_DROP_REASON_TC_INGRESS);
+               *ret = NET_RX_DROP;
                return NULL;
        case TC_ACT_STOLEN:
        case TC_ACT_QUEUED:
@@ -5160,6 +5162,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
                break;
        }
 #endif /* CONFIG_NET_CLS_ACT */
+       *ret = NET_RX_SUCCESS;
        return skb;
 }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ