Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2671828ybl; Thu, 29 Aug 2019 11:15:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUmA6Wnjx9xRbOj9sG846JCnZydtxZvodIdxHt3RAdm8vttnGqcJm+SLjBQkTB8mBAjW2T X-Received: by 2002:a05:6a00:c7:: with SMTP id e7mr13128156pfj.52.1567102552219; Thu, 29 Aug 2019 11:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567102552; cv=none; d=google.com; s=arc-20160816; b=rfO1H6MnCw4MAOLY89WrNATlPWdJrsZ0H9HxHTEnm17VpN6LyYp1y45Aj/+0U5ptp/ xXQCzIQmDg5CgoAFYgouVGwqcgm/0XktvpFMQjIIUCiR3CU8QCOhJbqk0FmXWJkexvZQ mtn7IQsWMCqp/oJXzX22LAyBRLvp8p7g2iWi2VYhl+b25mJTh9iJjrtS1UWL8tPYS8R1 ePA91zYo+Qv3dTNxWzKGt6xZSWjV/kb0UpKqEWZ+Za0469mY79ml/vIpqsXWoBs6g2/m yszLg5CLaCHJmdnf+82Fj5sqjjVwOyTIKrItHZOwPvbWLRGeJ5jn/zNeMebEdffRd1UD cUMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5esa+NHKQfi0ggOr82Avb0i7L0fWG3AAX9NDYNsqOMc=; b=pfF7oTW1v7YYPBUfEhLp12M72GjXSPCUm/9ovcJFEEQ0NjcEGBGNEG6nj/ZJ8Bg9s8 Gz8EeOxQWT3nLkprt00WPOamP1c9bFTqRQ8sKoaqq+kew5y7dkOh96cH4ypenR+YEWwk 91pNbgIun7aZwMG2N7ddbKCQFWrBAWLvtZcjGbinnCYmekgM/rIN9mP5HfmRRGikkt0V 9ucuytlwWJuPjx1nf/q35LLbMo9EE1FGlOqBYG6w/mHorkMTX5IRKo9N3/kkYcZwfNmm fxH87J4mJfqgt++0OFHO+GHpR/MhbvH86vB2Mx/G4kSf2kAxXuf3s0XTIkIN6fD18JWL F1RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QNIEK5jC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si369858plr.402.2019.08.29.11.15.36; Thu, 29 Aug 2019 11:15:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QNIEK5jC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728734AbfH2SOG (ORCPT + 99 others); Thu, 29 Aug 2019 14:14:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:55662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbfH2SN5 (ORCPT ); Thu, 29 Aug 2019 14:13:57 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DD78223426; Thu, 29 Aug 2019 18:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102436; bh=S/uUICgvSilsGtYuYVeoMlz2yDoqpI2JswWuw36fMiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNIEK5jCHnPc2kiXXSaoETxgnmNt9gMqhUtQNgi+Go1EBKZkOnUyYeByiiytqtFOM p2PfbMwEtx5tFF98LD4iFy69U9qMmHzOXj4sq2JYGSEPBHDVJ2zQVPlE20cvf31Fs0 fxAdq6vhezm1eVIXzWuhtS+SK7BpM37/MVyiZvE8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Howells , syzbot+193e29e9387ea5837f1d@syzkaller.appspotmail.com, Sasha Levin , linux-afs@lists.infradead.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 25/76] rxrpc: Fix local endpoint replacement Date: Thu, 29 Aug 2019 14:12:20 -0400 Message-Id: <20190829181311.7562-25-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells [ Upstream commit b00df840fb4004b7087940ac5f68801562d0d2de ] When a local endpoint (struct rxrpc_local) ceases to be in use by any AF_RXRPC sockets, it starts the process of being destroyed, but this doesn't cause it to be removed from the namespace endpoint list immediately as tearing it down isn't trivial and can't be done in softirq context, so it gets deferred. If a new socket comes along that wants to bind to the same endpoint, a new rxrpc_local object will be allocated and rxrpc_lookup_local() will use list_replace() to substitute the new one for the old. Then, when the dying object gets to rxrpc_local_destroyer(), it is removed unconditionally from whatever list it is on by calling list_del_init(). However, list_replace() doesn't reset the pointers in the replaced list_head and so the list_del_init() will likely corrupt the local endpoints list. Fix this by using list_replace_init() instead. Fixes: 730c5fd42c1e ("rxrpc: Fix local endpoint refcounting") Reported-by: syzbot+193e29e9387ea5837f1d@syzkaller.appspotmail.com Signed-off-by: David Howells Signed-off-by: Sasha Levin --- net/rxrpc/local_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c index 9798159ee65fa..918bffca3ddb6 100644 --- a/net/rxrpc/local_object.c +++ b/net/rxrpc/local_object.c @@ -283,7 +283,7 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *net, goto sock_error; if (cursor != &rxnet->local_endpoints) - list_replace(cursor, &local->link); + list_replace_init(cursor, &local->link); else list_add_tail(&local->link, cursor); age = "new"; -- 2.20.1