Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp957926rwd; Thu, 15 Jun 2023 04:38:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wUpcqRhC7DKhc0pdFCM9NPcrFJ5j4x6TMApZAFm27HFe/aMiZqqdqitwcISx/cxIKOPF9 X-Received: by 2002:a17:907:1c06:b0:969:f9e8:a77c with SMTP id nc6-20020a1709071c0600b00969f9e8a77cmr16608438ejc.64.1686829121517; Thu, 15 Jun 2023 04:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686829121; cv=none; d=google.com; s=arc-20160816; b=uoR7OzUMV5aw+RkRxxqeT43Azvp18EcE70AkTf7g7eHp2UmZCNePTrmduURBSjq8NV 44W2rcQmYGJMT798boFjukNBCYQqUIMHN1BlS/ehgUYLBHzPvMgzyYNnG4xyH04TFWij 99tvn+LhLYIZ/EUcQo8bueicCIjT72Bz8uD1E/PPdKbezvHU4aKTwt6vBdU4xdP786Os UsGVBy+VjasaE/JCO47SkY2MnRP1+o69RdFjw5rX1p2EwJFKX1mGoygpzUxSA1F4/sc1 cnbl/3M9E+6Qgw5X5AWA5uL29ljQS7cXL0Hcm69sht8t8SW3/9ovP7jAcvtxtYy0qUyk YKQg== 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-id:mime-version:subject :cc:to:from:organization:dkim-signature; bh=2jLPUY6QsgU36zacDi9VUOh4wRLZuAcl8Xg9zAds7pQ=; b=tUv8kJPO38+NlpRvS5BnH2M9qXGrNMUpyKi23LBZVUlkkKPoaHz1dJgAkIDqDSrYjN 5aa2JzIyP99FNDelXtlNryk2XPVL/abrnnzxD2AiVUN7lo/LNq8FTllshyDMhpxyuLn1 EZbwu0uutj/yzEgquNYumisrdfQi2Ky2NSo+giyuUG8Pa/zGh6GyMhmtpoeAmryQN9BU IeQfmxsKQo7astZtNdU5lbM2nDtnGboXTpE1zlKl1B6pOhbtIcCWix0TyABiUiXUOd/f BadHb2UP/tdQbvsNCB0sQOtFoDD91Y0voD4duB+pXpzQgtSpQzYwYmvkr9E9bf4AP5OL VmPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FShPQN/+"; 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 j16-20020a170906051000b0097885f7d639si9624984eja.837.2023.06.15.04.38.16; Thu, 15 Jun 2023 04:38:41 -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="FShPQN/+"; 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 S1343853AbjFOLdC (ORCPT + 99 others); Thu, 15 Jun 2023 07:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244783AbjFOLc6 (ORCPT ); Thu, 15 Jun 2023 07:32:58 -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 40FF2ED for ; Thu, 15 Jun 2023 04:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686828728; 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; bh=2jLPUY6QsgU36zacDi9VUOh4wRLZuAcl8Xg9zAds7pQ=; b=FShPQN/+1la0pmaLAxgwYfxFkyFVUJOZoB+ZcwyHfDwWk7tL6F7GO7hkbg/WDRd1o2JZRB 4DFqePJ8FHhQALURlZxgqWKoTIiwYSn7wj1bldz26LxugDv2MQKow77arAzOFWQi66Vf5i dTjcvFFrME5s/6ZmGOYhKTG0NTjJLrw= 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-517-B0uJZzaOOPCYIxFhQXYuOA-1; Thu, 15 Jun 2023 07:32:07 -0400 X-MC-Unique: B0uJZzaOOPCYIxFhQXYuOA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D21E8022EF; Thu, 15 Jun 2023 11:32:06 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 053F21415102; Thu, 15 Jun 2023 11:32:03 +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 To: netdev@vger.kernel.org cc: dhowells@redhat.com, syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com, Tom Herbert , Tom Herbert , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jens Axboe , Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH net-next] kcm: Fix unnecessary psock unreservation. MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20786.1686828722.1@warthog.procyon.org.uk> Date: Thu, 15 Jun 2023 12:32:02 +0100 Message-ID: <20787.1686828722@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=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 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 reserve 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.com/ Signed-off-by: David Howells Tested-by: syzbot+dd1339599f1840e4cc65@syzkaller.appspotmail.com 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 --- net/kcm/kcmsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 = NULL; txm->started_tx = 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 */