Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2110684pxb; Mon, 12 Apr 2021 14:51:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtZL4KxEvtx8fojFkcewOD2HkyiT4rtXqkAj5AwtM19PBJDI2vSxhkTl7o/WDvVqqi/sAi X-Received: by 2002:a17:902:e80e:b029:e4:b2b8:e36e with SMTP id u14-20020a170902e80eb02900e4b2b8e36emr28520417plg.45.1618264285590; Mon, 12 Apr 2021 14:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618264285; cv=none; d=google.com; s=arc-20160816; b=kDByNq2EFvonmQ8kreglTz4KqZZ54lmZIEUUdxYWANeHUf+3NOfj7dp8TX2Jrdnwah mE11Rstk+O/+Snf0g9q8fAsBT8hjRboWrfVSSpm1XcXo8QPz9SO7HwzPQZA5h//1ofp6 5Pj2NEZgVXSNOIYCsy/MiWIqc/zI7iwUT107Wq2G6X50zECVseTG/jECNKhf9reJQwSI 93e88SnPauiLpxFyGB/n6AXql+jQZjyra2og+QCaRRb+x3AcubbpM+AzisUN///kgpCT VDrnvSIO8RGCm/S8LcJw1yYoTTjd6ivYyWwmJfdDZHIbL86hYdSsSRqy02JYemNKRHWj tJCQ== 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=Hlfc23boPu6LONh5zuhFlI0uinka1duLA8C+HwnwyVM=; b=EQLcUF8f9Ds2S4nr8ZR04K+UP8Q6W0xmCrtYXb24hFFD2PLwdPm1pKwYtnSTCGBXe+ auTqAjylL84kgaH0X9iafbxNcx1V57e9rfB9eF8pol70i68Kl2qw7lXs1txc+ZUVdHU+ Ko9BAorvkOlDJAlK/MRVNHGB2MUNaJU+WcR61qLQzB/x4alaaTzypwn30JgqmFLoCMp0 IDLv/UXPMXcKAN9CacaHaiXBMxP2Jy7bs/gnGvN3qC3JylyCYR708/rfJ+EpiGDosEry vGtfYjamWdslZt5AqRVCun55b4bDk7lOXfyadQE29f78he96LvR1dOHcGyZ5urqYgX+O B2ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jPEFb0yZ; 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=pass (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 l129si15004275pfd.248.2021.04.12.14.51.12; Mon, 12 Apr 2021 14:51:25 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=jPEFb0yZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240609AbhDLJUB (ORCPT + 99 others); Mon, 12 Apr 2021 05:20:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:54796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239803AbhDLJBW (ORCPT ); Mon, 12 Apr 2021 05:01:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5F2C6127A; Mon, 12 Apr 2021 08:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217953; bh=9/rmLVtQR0rxgAhWp88SVpj53/FzBRpIMWunlLy8qM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPEFb0yZS2yISsfgcrBKyrpJY35+grEflJQgmeBiC2CpUhpPxK7UIAQlJzkjOaqZE yIM5PPBHFtun6JWQ2W8F2e5YRcNYx9juMi7u9Ic8pmC8199h3TPdKefKcjKP0Ps5nz PiUGfI4EV6+A0t/r3fUdJvHtr1w47Omr8AD46axo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?kiyin ?= , Xiaoming Ni , "David S. Miller" Subject: [PATCH 5.11 008/210] nfc: fix refcount leak in llcp_sock_connect() Date: Mon, 12 Apr 2021 10:38:33 +0200 Message-Id: <20210412084016.278785303@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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: Xiaoming Ni commit 8a4cd82d62b5ec7e5482333a72b58a4eea4979f0 upstream. nfc_llcp_local_get() is invoked in llcp_sock_connect(), but nfc_llcp_local_put() is not invoked in subsequent failure branches. As a result, refcount leakage occurs. To fix it, add calling nfc_llcp_local_put(). fix CVE-2020-25671 Fixes: c7aa12252f51 ("NFC: Take a reference on the LLCP local pointer when creating a socket") Reported-by: "kiyin(尹亮)" Link: https://www.openwall.com/lists/oss-security/2020/11/01/1 Cc: #v3.6 Signed-off-by: Xiaoming Ni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/nfc/llcp_sock.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -704,6 +704,7 @@ static int llcp_sock_connect(struct sock llcp_sock->local = nfc_llcp_local_get(local); llcp_sock->ssap = nfc_llcp_get_local_ssap(local); if (llcp_sock->ssap == LLCP_SAP_MAX) { + nfc_llcp_local_put(llcp_sock->local); ret = -ENOMEM; goto put_dev; } @@ -748,6 +749,7 @@ sock_unlink: sock_llcp_release: nfc_llcp_put_ssap(local, llcp_sock->ssap); + nfc_llcp_local_put(llcp_sock->local); put_dev: nfc_put_device(dev);