Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3058480rwd; Wed, 14 Jun 2023 10:36:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4DHcIPAylL25QS3yBpAwVoPUIHLvhS8+gfUGA+RZCMrPb/LYPaIZsFO1YtVaXZPJEqloYM X-Received: by 2002:a05:6808:150d:b0:398:2db1:dc26 with SMTP id u13-20020a056808150d00b003982db1dc26mr12393899oiw.31.1686764200203; Wed, 14 Jun 2023 10:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686764200; cv=none; d=google.com; s=arc-20160816; b=i/M1msVB5Nv33iJexKJmktYDWz5GYzlD2ABXaShYXmShbBqXYEYMw0TYOSomS5Fkqc 7bKjjm5Rpmqc8fIwc3k3WMQi1GcTVq2iBvoJgzYawbMEY5Hk8t0bldUEgxvFZ/W7Aa4K /U0MRRiPTtydPh6+4u1lLvTHs0PZ5ZxechOCrqKUHpt1FWoO1KSuSNjrLDM7eLgPjSs7 Ctzrgv/2+Y1klmk4hFsPXBk2/YP4G0wtQm+VA1N6JxrS0b0gllUeE+XuRHclv0KxkfW0 OqebYshqNUdmfx9sHGTJ78rP1j1JnoH7mRtKQognAnt8kkstXkoJs4K1aR05CvqD8CfH 7Bbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=HQz5NdE45oaAvzySylSACbH+ABZmOjstmJq8mz1VYQk=; b=d3YsXvkJLX8YO8U4JMVmaZmniml+N1PasSKkwgG1gPY0fakCbaQ79Ed2mMJlbBeC0p VZn+TJYcw2OtU3xA+g5aCytZJCBmIZcmrXlIi/6nkbKLXYmgr5NcMaQEQGNeVvAZG5c1 AjcWX3xS644SLhqFlReMO2FhI/sxNKbecZ5HAI1jmHYK9qbTSAyrtea80GjmSUoHtaa9 G856lgCL3nLo5dtXaJ6d/NqcEt41KIyMU64CwaXYkeGxuH1HjrAFlP8jL5uLJmMnIKlu hnXGt7DNE8pEvt8eKcwZXdH/AGCeAIq10FFSBiLDswCU8T8Sai9TBIMRvWJWZfgupiwE sg2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EZ11W9dq; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a633e03000000b00542a44deb65si11023337pga.676.2023.06.14.10.36.23; Wed, 14 Jun 2023 10:36:40 -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=@redhat.com header.s=mimecast20190719 header.b=EZ11W9dq; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237091AbjFNRXS (ORCPT + 99 others); Wed, 14 Jun 2023 13:23:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236814AbjFNRW7 (ORCPT ); Wed, 14 Jun 2023 13:22:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88ADB3 for ; Wed, 14 Jun 2023 10:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686763332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQz5NdE45oaAvzySylSACbH+ABZmOjstmJq8mz1VYQk=; b=EZ11W9dqs9WVMMxmcmnBEGfO0Q5T0eH0SGWy9T1ldBeObLCBZfFn6jz3N0TfROYEDBeNZo DN5dkEafh8/xdcun4VHNOdEc6mmjL00GoCkFR7+S2Xd4fsQDJ+qX7uHvn7231Q2+nzxiyN o3jhLUw+myKpBzj4GDOZ0yMocDN84f4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-za5E70CiPiqH928GIvIN5g-1; Wed, 14 Jun 2023 13:22:08 -0400 X-MC-Unique: za5E70CiPiqH928GIvIN5g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B60F185A78B; Wed, 14 Jun 2023 17:22:04 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id C25E0492CA6; Wed, 14 Jun 2023 17:22:02 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <000000000000a61ffe05fe0c3d08@google.com> References: <000000000000a61ffe05fe0c3d08@google.com> To: syzbot Cc: dhowells@redhat.com, bpf@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [net?] WARNING in unreserve_psock MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1665042.1686763322.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 14 Jun 2023 18:22:02 +0100 Message-ID: <1665043.1686763322@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.g= it main kcm: Fix unnecessary psock unreservation. = kcm_write_msgs() calls unreserve_psock() to release its hold on the underlying TCP socket if it has run out of things to transmit, but if = we have nothing in the write queue on entry (e.g. because someone did a zero-length sendmsg), we don't actually go into the transmission loop = and as a consequence don't call reserve_psock(). = Fix this by skipping the call to unreserve_psock() if we didn't reserv= e a psock. = Fixes: c31a25e1db48 ("kcm: Send multiple frags in one sendmsg()") Reported-by: syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/000000000000a61ffe05fe0c3d08@google.co= m/ Signed-off-by: David Howells cc: Tom Herbert cc: Tom Herbert cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index d75d775e9462..d0537c1c8cd7 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -661,6 +661,7 @@ static int kcm_write_msgs(struct kcm_sock *kcm) kcm_abort_tx_psock(psock, ret ? -ret : EPIPE, true); unreserve_psock(kcm); + psock =3D NULL; = txm->started_tx =3D false; kcm_report_tx_retry(kcm); @@ -696,7 +697,8 @@ static int kcm_write_msgs(struct kcm_sock *kcm) if (!head) { /* Done with all queued messages. */ WARN_ON(!skb_queue_empty(&sk->sk_write_queue)); - unreserve_psock(kcm); + if (psock) + unreserve_psock(kcm); } = /* Check if write space is available */