Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp460550rwr; Thu, 4 May 2023 23:09:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6WNj9/yhtvFNhvTsRevygbfvLh6XICVsWwQYsPUPky42hHyjV8m17UmM1n2BPKumdFw+Dd X-Received: by 2002:a17:90b:797:b0:23f:9445:318e with SMTP id l23-20020a17090b079700b0023f9445318emr847945pjz.3.1683266941302; Thu, 04 May 2023 23:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683266941; cv=none; d=google.com; s=arc-20160816; b=fML6FLgIhpFEeMsK+JeBROa9ETBWmBXIJHLnseG2FobwuzRtp7w9rcsLAdrEIwnO9x Sp5db1hjJ//O6QfpA4crXhNQ07UGS03UEJIkQBctOxxTYOyOH7Ju8O3CmZLwD08Smivr 14gVvLk3gzXgX0eR8Q6iXN6+/hBGAOUEmK2ikFnMxvutawx/xVTd8D1pK9S0GuPz6K4j hVo7EVdgyviuk6z2JB7KbA3KBoK7PR91dE2uAHsOT66Lnpf5F/w2qhTEcPgINxOt/d71 1gP0dR6HAv92McYrEf2qLpVRAry0G74nHy7kTNN4Zdmg+sqZdgtZpPOl1haavmnCEvRK NQpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=IFsWSbPqRby9UzvnYxCn30u9/MEmtbLnj3+la56BdaE=; b=N55z8nU6GLVZ0JJrHzDgFRZpD/KSeUfrkpRNNzGsQHTybqwOrPKXPPiiHLSYTjM8q5 Rl/GlBzt0GN0i5nRdzWeRHgx+2QeloxZ1GkTWw1nNnWC9EsRUoZLSDqOjqyoJN7cvb0C SIqlgYUGqoLqHaR5JxUUC3ZNWcrlpRgcZtvYzceT6TvVrrrgwqx3ENa4TrlP2d8fRnjp 55au3Mh/51zKfTP0Scl49QKxCBmJkaqyWd+Kq7qPYQO7BuRJTxnaprxNCHFvt9I2z56U UoJnbcA0WKDqvzxlhL3loZS12/vP8z6NoQxXQ1CggHXmoDEYvyUjganQQKmB6xAjOb3K a83A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo1-20020a17090b1c8100b00244930ffe45si19513532pjb.0.2023.05.04.23.08.44; Thu, 04 May 2023 23:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230334AbjEEF6j (ORCPT + 99 others); Fri, 5 May 2023 01:58:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbjEEF6i (ORCPT ); Fri, 5 May 2023 01:58:38 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E49E11D89; Thu, 4 May 2023 22:58:34 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1puoSU-0003tm-VJ; Fri, 05 May 2023 07:58:22 +0200 Date: Fri, 5 May 2023 07:58:22 +0200 From: Florian Westphal To: "Fengtao (fengtao, Euler)" Cc: Florian Westphal , jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, kuba@kernel.org, stephen@networkplumber.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, yanan@huawei.com, caowangbao@huawei.com Subject: Re: BUG: KASAN: stack-out-of-bounds in __ip_options_echo Message-ID: <20230505055822.GA6126@breakpoint.cc> References: <05324dd2-3620-8f07-60a0-051814913ff8@huawei.com> <20230502165446.GA22029@breakpoint.cc> <9dd7ec8f-bc40-39af-febb-a7e8aabbaaed@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9dd7ec8f-bc40-39af-febb-a7e8aabbaaed@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fengtao (fengtao, Euler) wrote: > Hi > > I have tested the patch, the panic not happend. > And I search the similar issue in kernel, and found commit: > [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed0de45a1008 > [2]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3da1ed7ac398 > > So I tested another patch like this: > ------------[ cut here ]------------ > --- .//net/ipv4/netfilter/nf_reject_ipv4.c 2023-05-02 13:03:35.427896081 +0000 > +++ .//net/ipv4/netfilter/nf_reject_ipv4.c.new 2023-05-02 13:03:00.433897970 +0000 > @@ -187,6 +187,7 @@ > > void nf_send_unreach(struct sk_buff *skb_in, int code, int hook) > { > + struct ip_options opt; > struct iphdr *iph = ip_hdr(skb_in); > u8 proto = iph->protocol; > > @@ -196,13 +197,18 @@ > if (hook == NF_INET_PRE_ROUTING && nf_reject_fill_skb_dst(skb_in)) > return; > > + memset(&opt, 0, sizeof(opt)); > + opt.optlen = iph->ihl*4 - sizeof(struct iphdr); > + if (__ip_options_compile(dev_net(skb_in->dev), &opt, skb_in, NULL)) > + return; > + > if (skb_csum_unnecessary(skb_in) || !nf_reject_verify_csum(proto)) { > - icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0); > + __icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0, &opt); > return; > } > > if (nf_ip_checksum(skb_in, hook, ip_hdrlen(skb_in), proto) == 0) > - icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0); > + __icmp_send(skb_in, ICMP_DEST_UNREACH, code, 0, &opt); > } > EXPORT_SYMBOL_GPL(nf_send_unreach); > ------------[ cut here ]------------ > > This can also fix the issue :) No, it papers over the problem, by only fixing this specific instance (icmpv4). What about ipv6? What about all other IPCB accesses? > BTW, I think the problem is more then ipvlan? Maybe some other scenarios that can trigger such issue. Such as? I don't see how this is fixable, just have have a look at "git grep IPCB", how do you envision stack to know how such access is valid or not?