Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2348559rdb; Thu, 21 Sep 2023 16:29:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFU0d7Kq/hWA6rpleNVkp72g8kXmXGTHrpDG15dVuf+XrqJAmsVdqEUg20X821SegmlvrM X-Received: by 2002:a05:6a00:9a0:b0:690:2ab8:2d67 with SMTP id u32-20020a056a0009a000b006902ab82d67mr7600952pfg.1.1695338995754; Thu, 21 Sep 2023 16:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695338995; cv=none; d=google.com; s=arc-20160816; b=uDt3y3S+IIloyncFQ8ILYKPV7AKThBHwR4bQEbDHm31sSgg82M4qgIUUSPK2H5bmLg W/NpZE8oCzCYru0ihIUUyVbRxgN8xMNDe3KRhzvnIdPYWZbVa5pDsz1z7Ic/MdeWeFl9 OtKeApVfZQbJM/Gqzx9TMoc0QrjGy7uC/4o7qsJ2xa+XO7kAwjnkDhvuiWsm63/pqIE6 glfTIoo9HFt1Z1PHzkrT0uaFR/aIe1bMriBF5nLMgQG3Xx9anyFug0MSMjW6JCPGJ5Wo 1CkzBK/qsYUXissN8/xaPb8qyEqR0BZ6EBSDeQBo7f+WMTPACbdfKvNlqfaxYxfKgQVP DQMw== 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=mZhZTyGMIwZ/ie/LDnjolHR2PA5j6eoOnn74VlJviEM=; fh=/b929O17dQ/EN0pM8iXqpD5qLmFyJ8uPRmZ6rmdI2fM=; b=mVUivO8QaGeUXtDD2tdLMp/78lGZdCAbnDd1q9/6aQ+kI28+qhV9fDzljxsyfrDeH0 O7LV9watwYs7US5ZBNvJaRciO74OiK8aam7PiIflVYlO8zF9uoikGwDxdgjCdvR236dI L9gGv/aZfB3/+AHutIx1pHOzx6lVmAgu9UR6HpmPgXOGm18yjAzs6YWloEqMfeVAVAv1 c/EHBCoaXbqjGOBq2vp0h81drNsmF+3FX2KTgOrFKr6+ZfGrBMuF3TrD3yWrsTPTfivD EGWYzwu59klNH/HGWwZkhuraBtiOuXvJ6R4dsD/DDN9njwE0RCt7gbmT9kv7bV/gyTAe jjFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0xY+lD5P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w20-20020a63fb54000000b00578a7f53bacsi2363201pgj.777.2023.09.21.16.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 16:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0xY+lD5P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id CF59D8236247; Thu, 21 Sep 2023 13:16:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbjIUUPr (ORCPT + 99 others); Thu, 21 Sep 2023 16:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbjIUUPd (ORCPT ); Thu, 21 Sep 2023 16:15:33 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74626400EA for ; Thu, 21 Sep 2023 10:15:06 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-34fc9b461b6so4465ab.1 for ; Thu, 21 Sep 2023 10:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695316505; x=1695921305; 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=mZhZTyGMIwZ/ie/LDnjolHR2PA5j6eoOnn74VlJviEM=; b=0xY+lD5P3QbdnZk/BqvAF2e218Sge6Op79TTL+H2cBTMefXcjuL4tUQ8+4XApdexgR 6X364ZRiNtMAIOdhDYSayDxKgdJ5ye/5nfgwe8sl44J5tiLeL2LYiRFExSMq+oy9676B 9ZVJCr7OgaxdsBtajIBhzsjTEP6xBajZBYwoQBQ8Xym4RXKMCUj2H4ZIhif4MxewwTci 73k+Ye1mysAsT+Qwv2j+y3OcjAFqXpW3QfXn09QikWddYzfoz1hqMHTmjE9FMpPuZ9RD bwGucbdB/31+LWswVjnl13ZNedYplhMWfmf3hWP+0AgMAqdd9EjolbuUa7l8ttBLpQZi 4NwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695316505; x=1695921305; 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=mZhZTyGMIwZ/ie/LDnjolHR2PA5j6eoOnn74VlJviEM=; b=FKjR+cSsd12aoY/wYv8bSxYtD/en9EMA0hCsPkGiUOBY6T63HN1o1+obN7uiJqOI0u Jw0zhMTGiZhE88YVF4mCVoUbwLvpktGaQGPGMBc/X6GwV6K0X7oHHcVdRguLhAXwGk7y zKCq4LwSb1VjQexy9+PwgKvBjPb6kNagjl+6L5xmlnonRTYZlLttvSBiFHc2lQMax/Jw b7gm9jhJpFA42ci72WAR2PtLW+MW6DCP1MBa4qLah3STiTTV6zDYScWQZFRcLWavWX3E rCSb1Nc6P4OUW9WTJTzGboTsPEDLi/pFEqtaD9wYZUuXnMFkztPjUtOGbMI4QtjV9RNw TIig== X-Gm-Message-State: AOJu0YwgpvIbO7fp67Xm6YZPAjXV+Fch2J9CudxjIOfGDIdqLS/14y+F Zqa9RXSfyab53CSgBqxIAKockfB/ah27Qf8la0GH6s9bk5Q52PCLHuA= X-Received: by 2002:ac8:5b11:0:b0:403:e1d1:8b63 with SMTP id m17-20020ac85b11000000b00403e1d18b63mr211399qtw.24.1695294572440; Thu, 21 Sep 2023 04:09:32 -0700 (PDT) MIME-Version: 1.0 References: <730408.1695292879@warthog.procyon.org.uk> In-Reply-To: <730408.1695292879@warthog.procyon.org.uk> From: Eric Dumazet Date: Thu, 21 Sep 2023 13:09:21 +0200 Message-ID: Subject: Re: [PATCH net v3] ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data() To: David Howells Cc: netdev@vger.kernel.org, syzbot+62cbf263225ae13ff153@syzkaller.appspotmail.com, Willem de Bruijn , "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=-7.2 required=5.0 tests=DATE_IN_PAST_06_12, 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=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:16:33 -0700 (PDT) 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 previously) > 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_append_= 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 alrea= dy > partially occupied skbuff. The warning occurs when 'copy' is larger than > the amount of data in the message iterator. This is because the requeste= d > length includes the transport header length when it shouldn't. This can = 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 buil= ds > the UDP packet itself. > > Fixes: a32e0eec7042 ("l2tp: introduce L2TPv3 IP encapsulation support for= 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