Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527841pxf; Mon, 15 Mar 2021 11:33:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr3UWH3v9kzgRAxM+A6LrJVgmdeRMW7XJa3CvNAxIMlx6J1EHilt0CbuMPOWDwBodnoP2c X-Received: by 2002:aa7:d9c8:: with SMTP id v8mr30893802eds.9.1615833192225; Mon, 15 Mar 2021 11:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833192; cv=none; d=google.com; s=arc-20160816; b=CtHcLTZEQTXCqqbAl9SPFzrMAjV8iCOuuNSxfdjvwRuRlOCV9cMYH3RPeUufslq0rJ XealYKtWAz8Nm72nu1cVuGRN9VUHhi+SOA/7mMu+TggEZd9XP5mE0C/uf7rF7yIqxyeP FZEebq3w29gPDz0Uu/XU4ztSuUFpLafYIT7yhF8AZrf/r+kY6MACbqfoGU2doTDh1i03 Z/aaBJ0EYyYoLeTehjPUT/oalzjrIpCjlPphx4n65q9KJw5SfR3uELmtzEGL1pC15FgZ 7+H0aZdFaPl1IrbiTRu9AFlZ34A9jmYXR+KJggje98B415HbwIVRLbsDeLmCeGWJO2E6 MQgA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cbwfNAL3lRXaYLzn90work2FXQi0U/yEQLGOXkApep0=; b=Sc5wYVLLm3OxLnJWuUfDQBKG0xEfpMJ4FgqTJ2dHPBB7STn+zlQvf2yrk1TSQFEKJk Q+mm3aerX+5ElOW9vYmfXfXFTdQj2rZuYKyZRYXJz/xqBC4hE8cYK0pgKFNJYlL/rGVx 7fKcgVVjvAUMR1b4GeGAyNAuSTjHkyZ5WJB/G0HDQdPNJINbdlHDmXAWsci4in3BUgb3 2Ut7XK0eiW/SNnTFZXUSny2QCkt14lnbyJgTGhyKTK5x0IeUvNYORKIQEK8gvOHfSnII fpn+ATKjjcSLaBD1ZyK5Q9v0qYCMPEr50BWezl2PreWbmpjQ6+2c5Fwr2dPDzFHZK7SF qyLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0NLveqHv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si11855615ejh.313.2021.03.15.11.32.48; Mon, 15 Mar 2021 11:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0NLveqHv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238050AbhCOOnj (ORCPT + 99 others); Mon, 15 Mar 2021 10:43:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:49843 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231366AbhCOODc (ORCPT ); Mon, 15 Mar 2021 10:03:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2169B64F00; Mon, 15 Mar 2021 14:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817011; bh=gWOLsGhfyb5ShdkRj7VqK2QTyUraBbnd89GJnpCGgD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0NLveqHvnQf/MliVyc5nXUBfdKU2bfbX6g01p77zCWP7mobtucrYiU1SB/K41PXmx hkSDVmddW3whAif955RXOdKQXX8yuEEDAzlJX7VSojHjC9Zx3SjNSw1et7Pl84GFfA XsWBk15eWyRNV0Lk2tSgDvxPpxDjuTQOTYoebBsc= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Paasch , Paolo Abeni , Mat Martineau , "David S. Miller" , Sasha Levin Subject: [PATCH 5.11 259/306] mptcp: fix memory accounting on allocation error Date: Mon, 15 Mar 2021 14:55:22 +0100 Message-Id: <20210315135516.401701542@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Paolo Abeni [ Upstream commit eaeef1ce55ec9161e0c44ff27017777b1644b421 ] In case of memory pressure the MPTCP xmit path keeps at most a single skb in the tx cache, eventually freeing additional ones. The associated counter for forward memory is not update accordingly, and that causes the following splat: WARNING: CPU: 0 PID: 12 at net/core/stream.c:208 sk_stream_kill_queues+0x3ca/0x530 net/core/stream.c:208 Modules linked in: CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.11.0-rc2 #59 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Workqueue: events mptcp_worker RIP: 0010:sk_stream_kill_queues+0x3ca/0x530 net/core/stream.c:208 Code: 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e 63 01 00 00 8b ab 00 01 00 00 e9 60 ff ff ff e8 2f 24 d3 fe 0f 0b eb 97 e8 26 24 d3 fe <0f> 0b eb a0 e8 1d 24 d3 fe 0f 0b e9 a5 fe ff ff 4c 89 e7 e8 0e d0 RSP: 0018:ffffc900000c7bc8 EFLAGS: 00010293 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: ffff88810030ac40 RSI: ffffffff8262ca4a RDI: 0000000000000003 RBP: 0000000000000d00 R08: 0000000000000000 R09: ffffffff85095aa7 R10: ffffffff8262c9ea R11: 0000000000000001 R12: ffff888108908100 R13: ffffffff85095aa0 R14: ffffc900000c7c48 R15: 1ffff92000018f85 FS: 0000000000000000(0000) GS:ffff88811b200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa7444baef8 CR3: 0000000035ee9005 CR4: 0000000000170ef0 Call Trace: __mptcp_destroy_sock+0x4a7/0x6c0 net/mptcp/protocol.c:2547 mptcp_worker+0x7dd/0x1610 net/mptcp/protocol.c:2272 process_one_work+0x896/0x1170 kernel/workqueue.c:2275 worker_thread+0x605/0x1350 kernel/workqueue.c:2421 kthread+0x344/0x410 kernel/kthread.c:292 ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:296 At close time, as reported by syzkaller/Christoph. This change address the issue properly updating the fwd allocated memory counter in the error path. Reported-by: Christoph Paasch Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/136 Fixes: 724cfd2ee8aa ("mptcp: allocate TX skbs in msk context") Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index de89824a2a36..056846eb2e5b 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1176,6 +1176,7 @@ static bool mptcp_tx_cache_refill(struct sock *sk, int size, */ while (skbs->qlen > 1) { skb = __skb_dequeue_tail(skbs); + *total_ts -= skb->truesize; __kfree_skb(skb); } return skbs->qlen > 0; -- 2.30.1