Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3868041pxb; Tue, 17 Nov 2020 05:47:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLCA+a/nmXCl7qNIbPZNNoUDrC7ognfDKktSA/Q8Jw0+6ruFNCZgTma1/73XaClOWUhT1R X-Received: by 2002:a17:906:2454:: with SMTP id a20mr1405972ejb.208.1605620873466; Tue, 17 Nov 2020 05:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605620873; cv=none; d=google.com; s=arc-20160816; b=glGgzPi9KYXPYVNL0PijuyRWq1raEZkdWgGgFX8EEaVHBL/ovOhEp0xYrvSgWhmzJD 3mfFQTGryjmgvLSpkn8+Gg/TQKsUI7Rxs6WHvVW5burHj87b7zoEmCae3MhCp2nmwnK0 FX8LT79N01DDZm+8rg14WQQETK2LFCZYXceD7hOZA9IA/g2j5pF0fDLvJK2LGTaULsfA 1L0qV0cbNOqhZ+zYkhXp9FZpsNWhJjDGmKaBaPw7qbeay1ICHYNYN1OmTnKKpJlfdSoE BTIPy7tLb9HGtUTal1fCeq7OotfQAJWDCFOCelVGzqmvbLLZ+v4QYjd+nudutNdXzhcd Km+g== 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=pxTLre9Qbw7g+iPr8thi7f6d87mNW1d6RiRRB6lI7UI=; b=t6g3vXnpLoR/io/duNvMCoYDi4RHGZR/0KzRnAm5d/jeJOwu0WUaiF2nQeXFNdd+ur vaTw8K5UzQuTnCn/h463UPCxE/H7pjgTV/Z3dCXpGbYsAVKeynUfh2JHIoHHqJIVTMnq SB5gRqDs6F+PxmQaeko6jYE2L84YUGBuGem72fLrL6+lqTzluuP9Xbn8YwsgoEwrw3Og CO/IZyOeoYscSy6JiIaw9oODwPRBbMhVF5Yd9HxSzVkn8YZThnTEQ+9YGl4XUPXk29tL FdDdVqhCOzWR3SngMRvaXLSD8F0StbHMcPpu+xRBMXdSjt/PJ13P8mn1vpoXzKem5gLz LwWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jt3tCTuJ; 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 cc13si14407605edb.104.2020.11.17.05.47.29; Tue, 17 Nov 2020 05:47:53 -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=jt3tCTuJ; 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 S1733027AbgKQNoM (ORCPT + 99 others); Tue, 17 Nov 2020 08:44:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:54466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732781AbgKQNl5 (ORCPT ); Tue, 17 Nov 2020 08:41:57 -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 5774420729; Tue, 17 Nov 2020 13:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620516; bh=6MFYVBSOYkpoTmwi1E8Gst2W9zo/d084ETK6MaQSWJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jt3tCTuJgFwcf11yrPE9eepDdmHJHfXOhAbzQuqwL7D4WcQS9R83riz/5+fskATSY J4530VD7QasVR9x7N/NGC3X4tXJE2D09NQzElwsakELAAFtJhQi+QYOjGehXo1rJ3p Chbm5EnC96aG/yINO1OL34FE1sbZGBecyqsQOPxY= 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 5.9 245/255] net/x25: Fix null-ptr-deref in x25_connect Date: Tue, 17 Nov 2020 14:06:25 +0100 Message-Id: <20201117122150.853348655@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@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 @@ -825,7 +825,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;