Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2280648rdb; Thu, 21 Sep 2023 13:57:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHX1oFIuvN7+c7TgpGdBxg7ToFR/AilT35702yxCEoGr1VUVWvCCXIuQbjNX78zrDcLUdsm X-Received: by 2002:a17:90b:d8d:b0:270:1611:484b with SMTP id bg13-20020a17090b0d8d00b002701611484bmr6413183pjb.41.1695329836742; Thu, 21 Sep 2023 13:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695329836; cv=none; d=google.com; s=arc-20160816; b=Hco8SzzmGCNbbgPGneh9agRF9r/OhDYAVUzBhenmNicjq7/JllWGmw713nRPdxD3om swoxqFGIAD69n0aNUVReI36eOgZ9P3tF4/fvtfT8+jx1x5nXsDvvs+eckWGsd5im96ac lkz+NfE3fNXsPbWAHjM4QEcpGzRxRuehBXXHHQ5kxiLdbtyHZr6Ia02h5u6u+puEWLzI DfTIryBatSsMZ4RyMT8AnFC+jLU14P3E7b5f3OPKVOE2NVpbfFuIbJ8Wo2IBL5r9yzyr JhuAejAuXpwId/4sxULeV5Q3m1p8Yc40S1jKF4nB/OcMvc7v6R5OWH0+1gFlrzMMtlHd NeMg== 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=vmAqS4POZPQ4cWVva2XsitwLpylcffcICW2xKCJAJKs=; fh=rgtllJC5AndZrS6hmCq+lLlM7o78zCXh2efIpS+v4Rc=; b=BMbrjYr39upGvIcnj9hooAilbxuReXuK69Hp8YyZC9WswYdrpNr1LscRC32tmL65Ot v1yNyxG+HLOjbT7mDYP72rp3DCIhXtvkc97V4Ck2F3OTSBYsGcvuaxJxC2ct5k79NMXv r44SpnExr98r3O22SvE9Z+lipIDmOAmZ2TuCxGbh97gyqpBxXbQcTzj43dUuewnV/6ih zEacLan93LuOCe/KJGRVflqONE3Mh9XdJI1g/Sz9OfwQ3B4e7Xb2IZ+QrXyXTfpBmue3 rihiT+z9tUTwvw+8twuaHctsKnhlpniQXEB2iAkqvdzVJYjQznSAHTab6NAMgSKWsIsN 7udg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MRqMb0Er; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x18-20020a17090a8a9200b00276f2dd1818si1850248pjn.86.2023.09.21.13.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:57:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MRqMb0Er; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0BDE0829A57C; Thu, 21 Sep 2023 13:23:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231770AbjIUUWv (ORCPT + 99 others); Thu, 21 Sep 2023 16:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbjIUUWa (ORCPT ); Thu, 21 Sep 2023 16:22:30 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED579025; Thu, 21 Sep 2023 10:11:02 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-76f2843260bso72941785a.3; Thu, 21 Sep 2023 10:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695316262; x=1695921062; 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=vmAqS4POZPQ4cWVva2XsitwLpylcffcICW2xKCJAJKs=; b=MRqMb0ErSrr4wYpe1itOlcjN7/APkPythWOmRjzTboiRL9JfU7RByvJ+F5O+xIFIUE //9lhMbVyepYpQBzICN6lJx8Z4RsedsNuXC9qIJePcKhw/0lGnni6JIxgZY+9xXpni+/ e1rvMEpKozskOfDaWLuqGRHkmdtLf2IrjzyANzv8Zg/X84BcAP2f3tjmkizpd1Br3Viq IhJtiFosCPVtAMeygLusVi/Emx/c9XtrNWlHtuSd/Rn6pUtp0oAWRY6PA3E4W6ibTaOD l15BVKpKVTCdJn16jYhf03QerAUZ/Z6+A7hrcoy5oDhoVPVdsRNhR6bavnhvhiU4VGib 3HhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695316262; x=1695921062; 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=vmAqS4POZPQ4cWVva2XsitwLpylcffcICW2xKCJAJKs=; b=T4wm7iURJMAeaggidUIV1+o/pv+Da1DiBqEulNbkY0UKyZesupg90ao9L1bma0p1P4 M8+pcHGb+wllbDQRel1sEFEaI6W4K4vyvLNHoNG1rvfPEFNrjlUkvZZWXZ6Gg1Ehm1Gt fKnGjgfbrcWKPc8A2IsdDRoTHN5/dO6/o3GIZ975j+pR8ep3UmNOzn+8dbOowZWYbtwL 3CJ157xLeZFajm4FAqjOqJgO+Hi2/9/M6ZM0sHP8ZL9thhu/xS4OkQledWccUF+2Mlnl YuZ3YmWSMHf9tDKZfVOG2E6n/1Vcl7iEg6xifvtVNJARbVIrUX5PvDMXaF76pMlCKmFZ DQ/g== X-Gm-Message-State: AOJu0YwPNJI+WREc5Q+AMX58ylpzRsn68gH40hU+CkObp+wNT1Hnk9aU nO2KG/WYYnmIVGUNFAA+eOzexHSZ7w92WLXbuIx2wqTx X-Received: by 2002:a1f:c886:0:b0:496:21dc:ec73 with SMTP id y128-20020a1fc886000000b0049621dcec73mr5737338vkf.5.1695302243773; Thu, 21 Sep 2023 06:17:23 -0700 (PDT) MIME-Version: 1.0 References: <730408.1695292879@warthog.procyon.org.uk> In-Reply-To: From: Willem de Bruijn Date: Thu, 21 Sep 2023 09:16:48 -0400 Message-ID: Subject: Re: [PATCH net v3] ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data() To: Eric Dumazet Cc: David Howells , netdev@vger.kernel.org, syzbot+62cbf263225ae13ff153@syzkaller.appspotmail.com, "David S. Miller" , David Ahern , Paolo Abeni , Jakub Kicinski , bpf@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.5 required=5.0 tests=DATE_IN_PAST_03_06,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:23:20 -0700 (PDT) On Thu, Sep 21, 2023 at 7:09=E2=80=AFAM Eric Dumazet = wrote: > > On Thu, Sep 21, 2023 at 12:41=E2=80=AFPM David Howells wrote: > > > > > > Including the transhdrlen in length is a problem when the packet is > > partially filled (e.g. something like send(MSG_MORE) happened previousl= y) > > when appending to an IPv4 or IPv6 packet as we don't want to repeat the > > transport header or account for it twice. This can happen under some > > circumstances, such as splicing into an L2TP socket. > > > > The symptom observed is a warning in __ip6_append_data(): > > > > WARNING: CPU: 1 PID: 5042 at net/ipv6/ip6_output.c:1800 __ip6_appen= d_data.isra.0+0x1be8/0x47f0 net/ipv6/ip6_output.c:1800 > > > > that occurs when MSG_SPLICE_PAGES is used to append more data to an alr= eady > > partially occupied skbuff. The warning occurs when 'copy' is larger th= an > > the amount of data in the message iterator. This is because the reques= ted > > length includes the transport header length when it shouldn't. This ca= n be > > triggered by, for example: > > > > sfd =3D socket(AF_INET6, SOCK_DGRAM, IPPROTO_L2TP); > > bind(sfd, ...); // ::1 > > connect(sfd, ...); // ::1 port 7 > > send(sfd, buffer, 4100, MSG_MORE); > > sendfile(sfd, dfd, NULL, 1024); > > > > Fix this by only adding transhdrlen into the length if the write queue = is > > empty in l2tp_ip6_sendmsg(), analogously to how UDP does things. > > > > l2tp_ip_sendmsg() looks like it won't suffer from this problem as it bu= ilds > > the UDP packet itself. > > > > Fixes: a32e0eec7042 ("l2tp: introduce L2TPv3 IP encapsulation support f= or IPv6") > > Reported-by: syzbot+62cbf263225ae13ff153@syzkaller.appspotmail.com > > Link: https://lore.kernel.org/r/0000000000001c12b30605378ce8@google.com= / > > Suggested-by: Willem de Bruijn > > Signed-off-by: David Howells > > cc: Eric Dumazet > > cc: Willem de Bruijn > > cc: "David S. Miller" > > cc: David Ahern > > cc: Paolo Abeni > > cc: Jakub Kicinski > > cc: netdev@vger.kernel.org > > cc: bpf@vger.kernel.org > > cc: syzkaller-bugs@googlegroups.com > > --- > > Looks safer indeed, thanks to you and Willem ! > > Reviewed-by: Eric Dumazet Reviewed-by: Willem de Bruijn