Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3851493pxb; Tue, 17 Nov 2020 05:23:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA/lj+r9wmjxQ14z5ipdXQdEADWlojcYDwTbJeL7aev+KTOM1XThDO/YVYlmnUimOWC8zL X-Received: by 2002:a17:906:c298:: with SMTP id r24mr1778067ejz.381.1605619426926; Tue, 17 Nov 2020 05:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619426; cv=none; d=google.com; s=arc-20160816; b=pJhE0v/AnXwTz/B/czCX735pO/+jpfMPhWVp0AxMWsQLR9RsPUuwlFyBwljvaFdlPX 1PuHdaOYjALRyJbbMNIh3DnC54HbbfQEIarIQKK3m/+1R0Tv8sxDAeZ5Zh7PpjUaVDr0 VQFbC3vjYl8iRoBxClLd+uU8sNfeSR1KEMikvmPieQs8Hl2QKuishWLSE3mWagfVEM1Z c+NW6/hhCnVcNHePdVRh2CX891MMkYZUWdcD/Spp4v+13FQeymmSlB4QCW7KEtJWf34f feEAsVYvXzxJPLYoeW3DEFhKLVNKTWfiAMFoAuKZ02VXC7rK3rMm3u7tm1aEuXXbxER+ UFlA== 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=lMmAE6eTG5gnP1/ssAbTlue46TXH0WUCOKTnPDKM4A4=; b=qWEBOLtUjIkx9DNE7OfhW4C3msFk/NRhQ35szAmFfRmL86NdpBa3ycIEdzKPZzj9F1 8nSW2vyVegxjo+x3VCn2iL8/nDbsssRvNHMvR6N1fnLlwQgAdFKMFMg08d72vNQ75nlU PdgajUPTseGebeA77B7vHobPEuPNtOFF0q2bb4wN7IkbemRLd6KrhHSQVLRbtsa9s1YK UQFbgkAxGIqYNMfMRQrhj/u0F2KnuRj1F+fWbbUwX3i39qwPdT0/SlyGm52sG+lMKH/Y FCuu6s4WqwBqcsgS4Zw7jKprYNXTBee7u3P8sRdFbRXibPTWumy07I4m2lp6mC9likt0 F65A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RV31FxDW; 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 ec4si13722270ejb.549.2020.11.17.05.23.24; Tue, 17 Nov 2020 05:23:46 -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=RV31FxDW; 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 S1728949AbgKQNVc (ORCPT + 99 others); Tue, 17 Nov 2020 08:21:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:54972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730849AbgKQNVW (ORCPT ); Tue, 17 Nov 2020 08:21:22 -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 22EE320781; Tue, 17 Nov 2020 13:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619282; bh=V+bMX9bLy9WydEL5j2bY3NL26LEAuj6uPzCzWy+Vkz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RV31FxDW8DDiH5KvdBl1fs3cavhkJ6MNzKBuHTU7GEtVOrB+fuJDTA/mfpBUS4ssM cHFsGKJ2s3kmrQV1aUAcuBNsuRLoT5RazAmERBi8shsahHa9JTLTRV1fg7JJHCjszr SjIMY92JfJHdY/9bovaLBH+Ho80RUospMXSrWHTE= 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.19 090/101] net/x25: Fix null-ptr-deref in x25_connect Date: Tue, 17 Nov 2020 14:05:57 +0100 Message-Id: <20201117122117.516605433@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@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 @@ -824,7 +824,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;