Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp138349rwd; Tue, 30 May 2023 17:40:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DlPYUT2vWrs4fR/ZxhPOBKd6Shg+UCiqrHFLPkOMDdAUkoaeJrOlqrG3qOXqclbocqXmG X-Received: by 2002:a05:6a00:2492:b0:63f:1eb3:824b with SMTP id c18-20020a056a00249200b0063f1eb3824bmr5570925pfv.17.1685493656984; Tue, 30 May 2023 17:40:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685493656; cv=none; d=google.com; s=arc-20160816; b=VA3JRk6n3XI1/VG4HwJIEELrgHR5c+YO2ALVsQMCYH3Ifk+OBOt8hvbJ+fJ0C6UVxm 2XgPd0gZvxStikdF+asbvf9dkcp1qQ+x10ZIA1RfQ989KcLQxBsb9WJNS3/5Dw6W5BOj 8RmhqXRJy5z6WNr+qbYruw9iy9azt5VmXi+OjXrFBtpkfjTO4ZUzJHwKq/Jsbm5LOjzB 59EflwkP9V6GBnqbGjvR7ETb7xzgQ+EwhO2djsAgEB9LVlgmpnd+z0cxHVpXFgop2eat bf9JOpHtR4BRpyPWKsVZXHScMszUm+LFS1acwxLUBJNJqPWRMZLglrEpb5l1oBWockXJ SDaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fBOx4IYfVgf6x0cG+ScwlUNVX++rzTlmhMaBkt6d0YY=; b=kq88oLPxfksedW4yLB434YLSFdXeZHw51ZjwSuEBSEY+WwntzTubP6VtGJidKla7Zg TbvuTd9r9JJI5U3+DL4Hkm+Munnw9XKorsfoObQ3d+FxbQ4oOkZN20LPBk7yDZvwuNxd XF84QnctkjN/mwPJoZLml0XZYlLDNp3/pGxkZR3ISaO+sQASRguDhhk/FBaM1iyM+nrC h1LKKkvUjkE7Gca8SEYf3t9zGUpefRzNaMO7ic2O3xHzP3+J6U91lwTt1pF96nfYYnu7 4P1GgmBuur9ub23X2TPETVhRobULsgDoezeP2m3IWfpw1r0k2fXYU+sFldg7XsWJiU1R WYZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OUzgd5vh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n29-20020aa7985d000000b00640f330a547si2555780pfq.236.2023.05.30.17.40.43; Tue, 30 May 2023 17:40:56 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OUzgd5vh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233828AbjEaAcg (ORCPT + 99 others); Tue, 30 May 2023 20:32:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233513AbjEaAcf (ORCPT ); Tue, 30 May 2023 20:32:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F33D121 for ; Tue, 30 May 2023 17:32:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C21363517 for ; Wed, 31 May 2023 00:32:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D875C433D2; Wed, 31 May 2023 00:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685493134; bh=R71oU/0C7O8aZ1Fo65yDpnqy1TpGhfrRouAYxvAjdW8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OUzgd5vhGClmDKAEtoIbqwLsQS0UPyIv9zBCQ5Ph80pA8CbxCAJoXLCUZjfxEsmj7 PgTvwepq7y4uuHCcIpViRQhnOV+J8SuU5K1zrY+2j54yrHw/X8REBwzUBj8eqGRrM6 pEHx97BTFBdADQPYE82kZ5igqX4LDL7AzYZELUfpd5lNNlBZtEgaatqMi9I5EZYHC1 tDUVfAVWLMfSBDb9LfdAr9FmihzxuO+r5Kwl7Pnsd1ZWBjjh98avBnsP7Lqm43iFTS bjvK9giC87TxwLMoTpme192nFucxCXdbfUIxehZ0GyPv7hkeqtIfftVQFWK5Do8Izr oz0lrJhs7RgQw== Date: Tue, 30 May 2023 17:32:12 -0700 From: Jakub Kicinski To: David Howells Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chuck Lever , Boris Pismenny , John Fastabend , Christoph Hellwig , Linus Torvalds Subject: Re: Bug in short splice to socket? Message-ID: <20230530173212.5fec9fc3@kernel.org> In-Reply-To: <499791.1685485603@warthog.procyon.org.uk> References: <20230526180844.73745d78@kernel.org> <20230524153311.3625329-1-dhowells@redhat.com> <20230524153311.3625329-10-dhowells@redhat.com> <499791.1685485603@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Tue, 30 May 2023 23:26:43 +0100 David Howells wrote: > Interesting. Now that you've pointed me at it, I've tried running it. Mostly > it passes, but I'm having some problems with the multi_chunk_sendfile tests > that time out. I think that splice_direct_to_actor() has a bug. The problem > is this bit of code: > > /* > * If more data is pending, set SPLICE_F_MORE > * If this is the last data and SPLICE_F_MORE was not set > * initially, clears it. > */ > if (read_len < len) > sd->flags |= SPLICE_F_MORE; > else if (!more) > sd->flags &= ~SPLICE_F_MORE; > > When used with sendfile(), it sets SPLICE_F_MORE (which causes MSG_MORE to be > passed to the network protocol) if we haven't yet read everything that the > user requested and clears it if we fulfilled what the user requested. > > This has the weird effect that MSG_MORE gets kind of inverted. It's never > seen by the actor if we can read the entire request into the pipe - except if > we hit the EOF first. If we hit the EOF before we fulfil the entire request, > we get a short read and SPLICE_F_MORE and thus MSG_MORE *is* set. The > upstream TLS code ignores it - but I'm changing this with my patches as > sendmsg() then uses it to mark the EOR. > > I think we probably need to fix this in some way to check the size of source > file - which may not be a regular file:-/ With the attached change, all tests > pass; without it, a bunch of tests fail with timeouts. Yeah.. it's one of those 'known warts' which we worked around in TLS because I don't know enough about VFS to confidently fix it in fs/. Proper fix would be pretty nice to have. The original-original report of the problem is here, FWIW: https://lore.kernel.org/netdev/1591392508-14592-1-git-send-email-pooja.trivedi@stackpath.com/ And my somewhat hacky fix was d452d48b9f8.