Received: by 10.192.165.148 with SMTP id m20csp846889imm; Fri, 27 Apr 2018 08:26:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrM5JsSLIVHejsiLl8NxUaBUaPxwbntt1HELp5gnL8GOXzuT9CxfjvgXIh8YcXAdJMmg0lx X-Received: by 2002:a63:921a:: with SMTP id o26-v6mr2522200pgd.438.1524842789812; Fri, 27 Apr 2018 08:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524842789; cv=none; d=google.com; s=arc-20160816; b=CBI42OXgpqnwr9oSGPV1i3s6vzmu/lFpsfaDDARkp1dPI2SMxEb72LiKJeLfsdYQhB QxJkbu6EVr7n8HduFk6S9X5vJNMX6USYInzy7dBPx2Q7Ulb0YDvpXF4FIyJYgJFKw6SH bjHGbkXHp9C3DYheYAfjJDEuTtoT0Z61SlusLBt0LPTIENLpa2xlEfIteNytX7ggSl03 2rxjHUHKuilfr7Xqj7ILQw8+SxYL8OxYypstARbtSJuEctvIkpA1C7Irp/1pEvlLLRpR EHoHJssbXE8t1JEpqKbAukdA62fkWuk5RvgLMUjf6nB/xJ7f844cz/n7uNst4XVvtC+A p74A== 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=bwU20L7cU2rT0PPhpky0feVP+lm9lKkKL7Q2RJup1kI=; b=ithGIPY8DPJ5PMkFYqiQ95kyYIeWy8Sz5CUsSr4B2m6yQeet5Uo3X5u7BdiJ1wPhwi pPd9Ca6I9Jb4klfKXOw3ChAIf4YBj4dNcqB80xXPq2uAFXvEi+BBguwS6wWHR9sBDaGX IKksIg9OwlupjHwEMvCLlohqynruSgN14m589hgmVlHmC5DZZ2o7ad0nhsf9fNp8GvT9 yQX3WbANzDclFmXlIJw9ahBRA3JZ7T96NOyGq4+B0s8bxZ5ZCCyyoGcCM3ovHNcXfqI0 hxOnxGCVyL/LSYC5funa5srvLWJ8+tUbK/9SBQKsLSWfMc4WbYjLfcjT5zxz2hlNiLF+ 4wHw== 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 w10si1518713pfi.88.2018.04.27.08.26.15; Fri, 27 Apr 2018 08:26:29 -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 S933297AbeD0OCN (ORCPT + 99 others); Fri, 27 Apr 2018 10:02:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933266AbeD0OCD (ORCPT ); Fri, 27 Apr 2018 10:02:03 -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 AAA1721897; Fri, 27 Apr 2018 14:02:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAA1721897 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.4 41/50] llc: fix NULL pointer deref for SOCK_ZAPPED Date: Fri, 27 Apr 2018 15:58:43 +0200 Message-Id: <20180427135658.104287309@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135655.623669681@linuxfoundation.org> References: <20180427135655.623669681@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.4-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 @@ -187,7 +187,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; @@ -198,15 +197,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);