Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp248064rdb; Mon, 18 Sep 2023 13:57:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKk6DHE+1Tf1JvPzTzAQbm4WeHEeYChIlM+weWn3S2pLLL6zzcI5IE/1e3nkh1b+vDfdio X-Received: by 2002:a17:90a:17cb:b0:268:14d7:bc34 with SMTP id q69-20020a17090a17cb00b0026814d7bc34mr8936038pja.20.1695070643873; Mon, 18 Sep 2023 13:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695070643; cv=none; d=google.com; s=arc-20160816; b=lBco5YAsc6fgRPlkDmq9NM5BFSvuV5ZtTDywMYRdraHCURjtiRAjnq/eJI+4Mk/5E7 0KL3wMNiNPdnwUMpuQgReqOfSFzkzvuhHAGZux2dLlrnFqpQ8FaYhvKWrtqBcfCjdQOv 4gBa5HqvH0stULFaiUKc/AtQWbG9qenpqtfx/JbbAowzH+2dUSesOWHiL6g7xPCS7JG3 qx2w9e3TaneLwQhLYl91dB37TFgtR9AINt2BU3qs/SMEDhzGTOxakqS7NrUqSSC3uG5y 4tEliBzNSK9M9ENy6SYXYJBtgDrjmolAfC3aOCY5FGMKHxROIuNNQH9XWWlCxLNBTz+f lcOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UvV317n6yyGUg56R/7pdLcqCtdADu2ogATpf8Oy64Nk=; fh=vlD2b744/VpSw2lsoxGEje3k1z2vTjCmlaYoInyqW+4=; b=nIaO0Wzx19qWIpthX1JCM5ouzP1KKMBmyDednenrVYFXNq5Fn4UlZ1bgb9+7GJRRPq rYP+xOaGVqq9F0aYwQ4LRR6qmjydKZHh7nRoTv2YCJ8DxlzLvcwRwmq82V6naOLcIfNH N5w+PoocOce9WnCsD7MwTL8iL5RfAiHcycc/p+719xzSN9ovCtnWosi2lG/s2HuJNl6J Ttr54VxxubR84lRqe2DfoeL9aOY57SgFk2CE7KSv3PiGBF3ulbJROw+S1bqJYxw0yiEF B20Ygq82uK4ZBcBDB7d6vfF0XyrHiRKt6NaQbo//VAoKuP3LEgIIcf1drZF5p/3/yBNu Oh9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ssBsfFlk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k6-20020a17090a3e8600b0026d4bf68022si8626119pjc.182.2023.09.18.13.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ssBsfFlk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5789180BB3D0; Mon, 18 Sep 2023 08:53:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjIRPxf (ORCPT + 99 others); Mon, 18 Sep 2023 11:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjIRPxe (ORCPT ); Mon, 18 Sep 2023 11:53:34 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DF5173D for ; Mon, 18 Sep 2023 08:52:16 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-34f1ffda46fso313225ab.0 for ; Mon, 18 Sep 2023 08:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695052060; x=1695656860; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UvV317n6yyGUg56R/7pdLcqCtdADu2ogATpf8Oy64Nk=; b=ssBsfFlkBcWmKH1Gng1juSZnLRvr7D2rKBG9Nz3JRiABpRTdRL04/wSie7IcL/v3TS JF6Inpet9jk6aXvf+JTl0w4Jh4d+PtpaKaWNZ2SJly5d+uNjONnH11c1Af/1/MG0k/r/ TivRuuFP+z9cROsXK5N2+4Pt1t+BwlQWWM6pwTY9wHXWvtkn9gMSlgpYQXISqKGMpAtL gkOXT/et0pEiHD2A/tkC9J5ashpaJYFXVrzwlD57MGNUYZMv97hVMjHVg0cXlvtHeTzH dvIY0Djox6fc0HYtkJD3BzljSyEkBfBee1mZbZF/NlafvQquh+pe56c1k6QhfipL5IQ/ Srbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695052060; x=1695656860; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UvV317n6yyGUg56R/7pdLcqCtdADu2ogATpf8Oy64Nk=; b=nU7B1dQehK7L2AF+iRDHBbX7jK6nGzgoX0XFN43WLO1XWMmGlO8ID3CIsMDd6WcWpY msJ9ICOjuACXiS4criGlLYR/Zwb1Ug1hspBCCE3Y3WHJ++swTGw/i7qczyIiqi2exmx+ zSq5wdxlFJdUCfOQ0TnVwsGha7ZC9Va4OX4OrHSwVwGaGXWZMOsUrpCzkhEJMva1knPz LxHsT3F3SwIuzUotAN8UuAa60MTNzDg2OXZdA0LcAU6BMa2Lwmboftb171/zeGXyWvdy ptloRWcPVRwzej31UxB+2inNyNkMbVdVyGuL6MEdrq3ctYJfKh5QANNjrRd4DojoOMm4 VqUw== X-Gm-Message-State: AOJu0YziA98srU0nd/ccrcXC5ZDKW+y6//SJfeHB4NxfjVBKpmVLKOy2 S4x4N/jNWDvucE11JnhdTEgB/X62MzJvRaxCQpCnXZl/FPW2E7DAKurE7A== X-Received: by 2002:ac8:5ac2:0:b0:417:944a:bcb2 with SMTP id d2-20020ac85ac2000000b00417944abcb2mr385498qtd.13.1695045901037; Mon, 18 Sep 2023 07:05:01 -0700 (PDT) MIME-Version: 1.0 References: <3793723.1694795079@warthog.procyon.org.uk> <0000000000001c12b30605378ce8@google.com> <3905046.1695031382@warthog.procyon.org.uk> <65085768c17da_898cd294ae@willemb.c.googlers.com.notmuch> In-Reply-To: <65085768c17da_898cd294ae@willemb.c.googlers.com.notmuch> From: Eric Dumazet Date: Mon, 18 Sep 2023 16:04:49 +0200 Message-ID: Subject: Re: [syzbot] [net?] WARNING in __ip6_append_data To: Willem de Bruijn Cc: David Howells , syzbot , bpf@vger.kernel.org, davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:53:36 -0700 (PDT) On Mon, Sep 18, 2023 at 3:58=E2=80=AFPM Willem de Bruijn wrote: > > David Howells wrote: > > David Howells wrote: > > > > > I think the attached is probably an equivalent cleaned up reproducer.= Note > > > that if the length given to sendfile() is less than 65536, it fails w= ith > > > EINVAL before it gets into __ip6_append_data(). > > > > Actually, it only fails with EINVAL if the size is not a multiple of th= e block > > size of the source file because it's open O_DIRECT so, say, 65536-512 i= s fine > > (and works). > > > > But thinking more on this further, is this even a bug in my code, I won= der? > > The length passed is 65536 - but a UDP packet can't carry that, so it > > shouldn't it have errored out before getting that far? (which is what = it > > seems to do when I try it). > > > > I don't see how we get past the length check in ip6_append_data() with = the > > reproducer we're given unless the MTU is somewhat bigger than 65536 (is= that > > even possible?) > > An ipv6 packet can carry 64KB of payload, so maxnonfragsize of 65535 + 40 > sounds correct. But payload length passed of 65536 is not (ignoring ipv6 > jumbograms). So that should probably trigger an EINVAL -- if that is inde= ed > what the repro does. l2tp_ip6_sendmsg() claims ip6_append_data() can make better checks, but what about simply replacing INT_MAX by 65535 ? diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index 44cfb72bbd18a34e83e50bebca09729c55df524f..ab57a134923bfc8040dba0d8fb7= 02551ff265184 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -502,10 +502,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) int ulen; int err; - /* Rough check on arithmetic overflow, - * better check is made in ip6_append_data(). - */ - if (len > INT_MAX - transhdrlen) + if (len > 65535 - transhdrlen) return -EMSGSIZE; ulen =3D len + transhdrlen;