Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp844974rdb; Tue, 19 Sep 2023 11:52:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQ9grBuJmrH5bKSsOuLgP/KksbBdK/XGVOqmlK9JKZF1k/w6NHMaMdZhowUtMUOLVR2Ygl X-Received: by 2002:a05:6300:808c:b0:155:6e4f:8c1a with SMTP id ap12-20020a056300808c00b001556e4f8c1amr408661pzc.25.1695149521499; Tue, 19 Sep 2023 11:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695149521; cv=none; d=google.com; s=arc-20160816; b=kTHF3X0EQPMtd8aLlqnAImkakeXuA3qpc84MCSc6egzjo4PEgnQZKm82q0VVSfUYC6 Kgvnq9XsCJmXfhmTiya3+HYhALAAcowlQE+q7q2yg9G6dCueYhl75PDgPIaczz3iNAT8 t/lhp9RIBvjGrcaoe0NX4gexgarzjRPYbjkt7mjl8mkGOF2wNbtYHgkI4xBJvp7Iy9yG yIXqBdDiwFQNEqKNweZ4QXACxi39C3igEZ8C2SWosJ01UTz46TJAjIDZvjDnC24PD9BR nPv/FVt7/ssy0D5fOgIqPZeSz3udCakd2i1AnevYE0e/RnbSW4fqf0H2OOHeefJ4MYPE FpzQ== 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=7/oi4X3L5BnW+K69jB8Ov4ZNb09lPvvTlldUKOwOkGU=; fh=CVeId2u/g6MWL9QXA2Zsqh696WHS0CvrY1RvDSd8XwA=; b=ElqoSLYkbNoVjC4sDeqm0y1/lI0/md1UV0JR3m84qev9IaAMItWU9+H3c4EldDNfid VhEc7nNx88MfiRFRy0ikTJ4bKxBCCW2udU+3eApl9K3PGiAwfUDxpLI6Z7YQcaM0m6HC b+FKsi4opVL6/N0LHD7GPbD8s2JndhTnRqfyyx17dqPg7jDkICA9SEdtkcwFAyLZXcRh Kdu3i+60xjJam6DmVaeGOWM3w/1ZVqO/DJKYtpZdl/ruqT4Mo9dZD9Wzr4qkLFDVFsAy KY25RzxEkaX0GncUcsrENOaa+Ivdxu18WleUNDv1Gz/xzBP/OxqZ62jMTIE84R9nelsA zzvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qgBDb41Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id w8-20020a63f508000000b00565eb0b4f33si10210389pgh.224.2023.09.19.11.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:52:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qgBDb41Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id A4825823F58E; Tue, 19 Sep 2023 02:05:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbjISJFC (ORCPT + 99 others); Tue, 19 Sep 2023 05:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjISJFB (ORCPT ); Tue, 19 Sep 2023 05:05:01 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 493C012B for ; Tue, 19 Sep 2023 02:04:55 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-415155b2796so246041cf.1 for ; Tue, 19 Sep 2023 02:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695114294; x=1695719094; 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=7/oi4X3L5BnW+K69jB8Ov4ZNb09lPvvTlldUKOwOkGU=; b=qgBDb41YlX7gYTIa2/cCXpfPdeFrEAK5C5hCflV6DC4KATJtZzqbCHiv+puVcxgRG/ vmSite9CfaS8sDRVmY/pODPnNFmJ/1HMBjBYHcn3x1GDe9ZfR4TjTujqyt+FyrGnB4we PFpLmfreZsvHz+12IGCh1J2sUp/u7EnuGROW2snYoT5yor3oZe3awscm3KWR1Q9XVuQN 6s5lK5uEjJkXE8H5/JGUb8GM44BktBuz7WT54Lw3K0Y+YqHHmdwKz6whwQj4VCkY+8ZT zrMNKMDRmMmIQIYLag1R83YLoFeN2TuxFILrr8KOn1z1q1ou+B7ppMbxOOSnluXDLQmw ievA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695114294; x=1695719094; 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=7/oi4X3L5BnW+K69jB8Ov4ZNb09lPvvTlldUKOwOkGU=; b=RRjpZfb5guE3QvJtQ+DTOpemVla/Q4BBfhoai9wJ2ApZ3RLOVwRSH1yEmBcmJA3nmF T8pHgALh+Bxl8c1FQI6YTjUAKwHoJAx1ude0ivEepKooA8Kx/aGh+lnxJ5uqocsDSUtE MKreP8TAaUxqkG6V1rlYHsoF8KL9lE/EbRWv/a3eZvLP5zmuTvD6Zw0c3e/hWZ8luCLh PfuGs3SNfV/zOqPig8KuWo6tnuu2/nUjtFtwZjz8Y2RAf1aDHGVPElkrfxMiw07RyF0g pKcfHGNBDtMU8exUgsxtdp7HKNIgVde5suwa9ftxmsSP/oqWXtQnT/6nFRjQLlKPxOlH qINg== X-Gm-Message-State: AOJu0Yzi57uCexFxbkjXtXcLHPwkB8isLgHuX/MwEK6wcpP6PvTk5Oiw 2HT3AwWQ40pQhRsRgZnyGRd4gcjAZm20u/I8Dnhzdw== X-Received: by 2002:a05:622a:251:b0:40f:d3db:f328 with SMTP id c17-20020a05622a025100b0040fd3dbf328mr179702qtx.2.1695114294212; Tue, 19 Sep 2023 02:04:54 -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: From: Eric Dumazet Date: Tue, 19 Sep 2023 11:04:41 +0200 Message-ID: Subject: Re: [syzbot] [net?] WARNING in __ip6_append_data To: Tom Parkin Cc: Willem de Bruijn , 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:05:01 -0700 (PDT) On Tue, Sep 19, 2023 at 10:27=E2=80=AFAM Tom Parkin w= rote: > > On Mon, Sep 18, 2023 at 16:04:49 +0200, Eric Dumazet wrote: > > 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 reprodu= cer. Note > > > > > that if the length given to sendfile() is less than 65536, it fai= ls with > > > > > EINVAL before it gets into __ip6_append_data(). > > > > > > > > Actually, it only fails with EINVAL if the size is not a multiple o= f the block > > > > size of the source file because it's open O_DIRECT so, say, 65536-5= 12 is fine > > > > (and works). > > > > > > > > But thinking more on this further, is this even a bug in my code, I= wonder? > > > > 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 w= hat it > > > > seems to do when I try it). > > > > > > > > I don't see how we get past the length check in ip6_append_data() w= ith 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 i= pv6 > > > jumbograms). So that should probably trigger an EINVAL -- if that is = indeed > > > what the repro does. > > > > l2tp_ip6_sendmsg() claims ip6_append_data() can make better checks, > > but what about simply replacing INT_MAX by 65535 ? > > Slightly OT but I think the l2tp_ip6.c approach was probably cribbed > from net/ipv6/udp.c's udpv6_sendmsg originally: > > > /* Rough check on arithmetic overflow, > better check is made in ip6_append_data(). > */ > if (len > INT_MAX - sizeof(struct udphdr)) > return -EMSGSIZE; > > > Should the udp code be modified similarly? > Unfortunately both l2tp and udp support CORK (MSG_MORE), so a modified check like that will not be enough to prevent syzbot reports. Better than nothing, of course. I also note that ipv4 size of l2tp does not have any check, an overflow seems possible with carefully chosen size.