Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2032353pxb; Mon, 12 Apr 2021 12:28:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXrnFdo4R+oADk7CLA89VOAlsXqpmCm8w9JDU1A/+bWBLmr9YN4dWO7jBYfR02JhRXrDmJ X-Received: by 2002:a17:907:d15:: with SMTP id gn21mr27861547ejc.337.1618255722663; Mon, 12 Apr 2021 12:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618255722; cv=none; d=google.com; s=arc-20160816; b=V2znRHjbcKnjvCvXp72T0dYnuM8LKnSllH1kh6OUCkIy86u4skUyfY9Q8cla127OB4 krz6ml3YSuXymc40RmuZLKz3fE2EndLETxvEvTfw3KjzRte1KKxhtZKt2Lm5SduhAmQg cEzQtI77E8odBBJdbcCyJJ3JiBCAxmI5wJ8SLyw73w6EXpWV7wO9ZCgOuqeeWklVZvTy V3OOvUI9aKXZPcV1Qde9h+n0s9PsaXrAOCnuj0Yv7XLJmz5qVegc2ztSHd/MQTIRGhdb DFu1PjeqW3M2HAk0Iw5ZkTqi0qUs5ReedsYlaLvV0AhHVJ3PrXrMwP7ruS1kr2Q/T5HW g3/Q== 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=4h/99FTGI/r7JQ+q/N0bGsgzMel+RA0Txjdz4K8ocIY=; b=tSE5iu8EBy5pFHy2lP0PEqfbuPO9Ev19L2FapISHZUE4w0TErpANMusGnn3L4XhlR/ UUT5d9A9MXtrT73m1JpDkcYMX9Xwdbe/vKzvUH/KiiosqAv5jrA1DP16wFVEkpRkENF6 oRk4iWZfqdVODcPrU1OcROG7suyfvspwCwMFx9uXZanyktUYaZ1wjwHyNDaxW7s5ravp ywfj4U6sN2ERPU1W5mH+TvskOX8SOvg+DCQ+ZaNale0yPHl4tDw0jAZfl3nI+5hOVo+Z pDyS5zoLGglHkFyYHe8DFgMnGx4cHjC/H5iDZl7sgXjTMSDzk/pCAMn3OB50XgNeGaU7 Vhsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NIwbPbZ0; 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 r22si7872247edw.235.2021.04.12.12.28.18; Mon, 12 Apr 2021 12:28:42 -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=NIwbPbZ0; 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 S237081AbhDLInw (ORCPT + 99 others); Mon, 12 Apr 2021 04:43:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:35158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237523AbhDLInc (ORCPT ); Mon, 12 Apr 2021 04:43:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A4DE061243; Mon, 12 Apr 2021 08:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618216993; bh=wGfmxTQN5cHM5gK33nw1ti9aitJP/n9OXdqcb/De3z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NIwbPbZ0BWlgwDoWLbwHp0llWu0WcOkVO873iDq0GQKwCrAy+7A2TPTaArZQ56YuN QatfBGWya7o5y9WbaEq/F7AcxmRgRu0N3XCRhky3WPEB/+C6GaXqaKl5TtvbuMYM3X 73o4gprq2eM8OTG8MFDQShSF+Y2U1KgqLlhH6NdM= 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 4.19 03/66] nfc: fix refcount leak in llcp_sock_bind() Date: Mon, 12 Apr 2021 10:40:09 +0200 Message-Id: <20210412083958.239120288@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@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 c33b1cc62ac05c1dbb1cdafe2eb66da01c76ca8d upstream. nfc_llcp_local_get() is invoked in llcp_sock_bind(), 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-25670 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 @@ -120,11 +120,13 @@ static int llcp_sock_bind(struct socket llcp_sock->service_name_len, GFP_KERNEL); if (!llcp_sock->service_name) { + nfc_llcp_local_put(llcp_sock->local); ret = -ENOMEM; goto put_dev; } llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); if (llcp_sock->ssap == LLCP_SAP_MAX) { + nfc_llcp_local_put(llcp_sock->local); kfree(llcp_sock->service_name); llcp_sock->service_name = NULL; ret = -EADDRINUSE;