Received: by 10.192.165.148 with SMTP id m20csp763394imm; Fri, 27 Apr 2018 07:09:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZquESw8kcFqs/7iw4e3ePVa2666KGSHQc9TpcUcllsNtONazai2u8s2+tmiew9OgihwsQvl X-Received: by 2002:a63:77c9:: with SMTP id s192-v6mr2262294pgc.51.1524838196107; Fri, 27 Apr 2018 07:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838196; cv=none; d=google.com; s=arc-20160816; b=WPyTReVhbmyJ1a4pd0hoZixjapDdMvt7KrecaVgOgEvLw1kCjtc3ggOCe2sIfRqExo UnDf3SSO6vPjqCUkaOFI4vLp7JDH+1Y+tqFqd8ujpA7kmGsOCyPfgfOydYt4oYyF/tsF jX6xjj33UMAlEsv8BmogYuSeCbXnGHSJeY55PEb7QliE8XLtM1joYcIPUGR9ByPyqOwl 1o+twFnnuLPv6ihkPWdUzovHUBawVYPO4U6XqUuL+hsqSl0Si8cULGudeZYHgmOX6QiO SajL9kAxnKC8JrnzJvDkIHf/ceKr1xYOWzICK3sIGA92j9fdNSPSLTsuNpdvePF64Zas ZbXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=uyyS9GPBdiuHsgzECIK2tHI6EHk23WukbG5QwETCCX8=; b=N3nTOMVaRXkUTW1LiKChm1IKNI+C26arFcmggXIQPymrej+0d5UWc6KyuKHsa6UYEa 4UnsOdD/cye39nrA20xymyDEwvhGNY5G/GCgzwzdVWmsmq3A5V1ToS4/eM7eD6TJMOwd TdbfrZE2meg4GiDq4mlUPQXupTAkgUdXvDsJx0aDl8bOgOJVvMYjfJ2E1rtZORQcwKkH RXlGaUNXkSob1FcdPkJi3tqCIhsM25mLhhUnJVKvkX+Ur7ABGevLkNfs3jQG8gEl5s8m gZu8TmcqgfbqwFTpnToaMoCNxAH5YUXk5tutkEIGtmzCzdx/wTo/HpwGrgvsenFN3PtC iVsg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si1302119pgd.628.2018.04.27.07.09.41; Fri, 27 Apr 2018 07:09:56 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934514AbeD0OId (ORCPT + 99 others); Fri, 27 Apr 2018 10:08:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:54062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934455AbeD0OI3 (ORCPT ); Fri, 27 Apr 2018 10:08:29 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 B5E3E21892; Fri, 27 Apr 2018 14:08:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5E3E21892 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Cong Wang , "David S. Miller" Subject: [PATCH 4.14 37/80] llc: fix NULL pointer deref for SOCK_ZAPPED Date: Fri, 27 Apr 2018 15:58:30 +0200 Message-Id: <20180427135734.835304023@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit 3a04ce7130a7e5dad4e78d45d50313747f8c830f ] For SOCK_ZAPPED socket, we don't need to care about llc->sap, so we should just skip these refcount functions in this case. Fixes: f7e43672683b ("llc: hold llc_sap before release_sock()") Reported-by: kernel test robot Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/llc/af_llc.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -189,7 +189,6 @@ static int llc_ui_release(struct socket { struct sock *sk = sock->sk; struct llc_sock *llc; - struct llc_sap *sap; if (unlikely(sk == NULL)) goto out; @@ -200,15 +199,19 @@ static int llc_ui_release(struct socket llc->laddr.lsap, llc->daddr.lsap); if (!llc_send_disc(sk)) llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo); - sap = llc->sap; - /* Hold this for release_sock(), so that llc_backlog_rcv() could still - * use it. - */ - llc_sap_hold(sap); - if (!sock_flag(sk, SOCK_ZAPPED)) + if (!sock_flag(sk, SOCK_ZAPPED)) { + struct llc_sap *sap = llc->sap; + + /* Hold this for release_sock(), so that llc_backlog_rcv() + * could still use it. + */ + llc_sap_hold(sap); llc_sap_remove_socket(llc->sap, sk); - release_sock(sk); - llc_sap_put(sap); + release_sock(sk); + llc_sap_put(sap); + } else { + release_sock(sk); + } if (llc->dev) dev_put(llc->dev); sock_put(sk);