Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3850028pxb; Tue, 17 Nov 2020 05:21:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpCCZVs2fT374jrDXgK4Ika335CundtaXMIRm7DPI7wGhJ5AhwQoC9d/RZAJEZradl6WBQ X-Received: by 2002:a50:b761:: with SMTP id g88mr20813996ede.387.1605619292152; Tue, 17 Nov 2020 05:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619292; cv=none; d=google.com; s=arc-20160816; b=FdVCOAqGhmtdBs9rptW32Pg8+vzpwYSFnKxNVkfhk7KIoDg1Kxv4P/WcYElc4dljw0 7n5bSB4dWdDv52vBa2nV9x9ae6SjiEHqQ7SIxmzXC6fLj+s49g5/9s9HN7S3FeqfjtKR Vndzu+kVYQ5lJTrscdKA5sT9tGMeMBjfFpUdghh9ucFkHYxTDgKwMmO9rE1tjR6Ybf4y 2YUVU8TGLikHt/68WZti6uhqbuCTuw0vCkRfZl69TDQwydSUZSDdoEh95mI0WyNnNOaD 9Tcpuk0nNEKGgfEfK2cvVDLWxT3TQl4xagL20T/TugjKVR64MnQT1vADQmFu09H0sQFe 8HUA== 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=KKAhlHdUYa99OTQlfWslDs/hFJIlqiJq0+w+rLJNPFs=; b=xIvg2EOm+VqzDt81EZeiihVzzNb45cWRLHMLeJwgFR+TcRnPoo285ob2wC4UxIGxvU HEXVxBMs1pe8BHQCtFT/8F7d3rDWvM6Y2Kjg0n9uJVtYPqGD2rVtTR8UMt2cOmdAwuz2 98NodbCppXOISPCBOC2LKmf/j+Gk5NwXPntPiKfOgl6v8EVrJBfq1PsmXkcGo0cHe47O 0fnTv0vgydPct6SpsyS7jsNUE7fmqLpM9A/o4bo/+SpkTQz+89bKZVnHUW9OElFpJsPg yM2f5bZT862nLHi8EDWvrc1U5KIDvNLRSmIaS95dRV2lfbQikT7FnNKxklYBRvYCvXTk BAKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=03VT2ff0; 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=fail (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 5si14756367edh.141.2020.11.17.05.21.08; Tue, 17 Nov 2020 05:21:32 -0800 (PST) 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=@kernel.org header.s=default header.b=03VT2ff0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730215AbgKQNSx (ORCPT + 99 others); Tue, 17 Nov 2020 08:18:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:47192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730198AbgKQNPm (ORCPT ); Tue, 17 Nov 2020 08:15:42 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A31A7241A5; Tue, 17 Nov 2020 13:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618942; bh=KIjxkzgdOwMJoSiRdDNpZiJS6sgnIB69WrDcBfVwplk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=03VT2ff0IGTOo70TWNBjicBkOJyn91vG2ncTZke7Nzz9OZnDWM/l8L81dg3+Va1R1 UzGuraFGDxkej0Bqvk8HlrHOA+tgytCrPlhilrlAt2fhrC55U8ZcKiPlcfhZfQzRdd Dbd3GVKQVj9L1khaIUhFYIOJjdqCNXdcdXVclPM4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Schiller , Xie He , Jakub Kicinski Subject: [PATCH 4.14 60/85] net/x25: Fix null-ptr-deref in x25_connect Date: Tue, 17 Nov 2020 14:05:29 +0100 Message-Id: <20201117122113.976741835@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@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: Martin Schiller [ Upstream commit 361182308766a265b6c521879b34302617a8c209 ] This fixes a regression for blocking connects introduced by commit 4becb7ee5b3d ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect"). The x25->neighbour is already set to "NULL" by x25_disconnect() now, while a blocking connect is waiting in x25_wait_for_connection_establishment(). Therefore x25->neighbour must not be accessed here again and x25->state is also already set to X25_STATE_0 by x25_disconnect(). Fixes: 4becb7ee5b3d ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect") Signed-off-by: Martin Schiller Reviewed-by: Xie He Link: https://lore.kernel.org/r/20201109065449.9014-1-ms@dev.tdt.de Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/x25/af_x25.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -823,7 +823,7 @@ static int x25_connect(struct socket *so sock->state = SS_CONNECTED; rc = 0; out_put_neigh: - if (rc) { + if (rc && x25->neighbour) { read_lock_bh(&x25_list_lock); x25_neigh_put(x25->neighbour); x25->neighbour = NULL;