Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1594097pxb; Mon, 12 Apr 2021 01:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx42V91W97IiiGTkkoAUbWmfGtwrwnYc1MnOJtTGPzR2siJUnBPz0qv//u2qz9zJWLtfsqR X-Received: by 2002:a17:902:d88e:b029:ea:dfbf:5ed9 with SMTP id b14-20020a170902d88eb02900eadfbf5ed9mr7219812plz.51.1618217149638; Mon, 12 Apr 2021 01:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618217149; cv=none; d=google.com; s=arc-20160816; b=EiS09b9RK7DTqUC8h8frpU6Sqp0VbbA8nqn1K6EwJkEq0gkW4YBAPSp0CqUQt8M8Tc 7vmqzED06SYkXLGGwaE5qRoc5EWqKHv8OOhHtf0TnuZ19xB++81dfF0FFBKa/1zcY+wn GG41Gch8rXMqBLNkxnBMoMBIeXRRwcOLiWqt9hfHzVCtneVUE6NUwqmYKwBpS9HjVWd0 c5codO/nFyv4/Gbp7zGteXTkwlgHnutShruPGljqBWFJrssUqE4ajj7iZoH6nKhKGZ/R pDm+tAjI5CfYhvyEce3RVkJBesJ2K04agm06bblJvf/dmYFixvmE3Em1zZrN9JksgEsy i+eA== 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=ebEjceqaCBdUPWJ1wX8BPrb17l11XuCi3wDY/HK9lg4=; b=1HYYMCTuJMqCLA7Sna2oBBUsrBix90OpaJm4+J3EihOG21bVpMamvZ7qjKbhadWUpr tL5Bb8G32EGCrXl86zg2f12wjSZgTEMGJq+Adn9C5aE/8CAybxYLduYILdfEMhbGw0Fs 1GS8DLXjz59tuyZIvyloE5gPoucpaG+vs1LQkeaTspWKoFPNcK3ZnH+8y8GcfJOusWOV ExYSbRLFdpSvhJmpO8iBqpBtPFZphtqdwib/x2w+raXpw0VpNqTg1cOoxXdiVumFwDvv P94+KbigKx3Wyteic10VNA7cO1BrTuoUmdhL8O+Tcf5tdCxxIUAM+Xxwr2fbFglVQB8P zAsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BDoub3OE; 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 123si13463910pgd.6.2021.04.12.01.45.37; Mon, 12 Apr 2021 01:45:49 -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=BDoub3OE; 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 S237564AbhDLIn4 (ORCPT + 99 others); Mon, 12 Apr 2021 04:43:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:35128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237526AbhDLIng (ORCPT ); Mon, 12 Apr 2021 04:43:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3BE3960241; Mon, 12 Apr 2021 08:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618216998; bh=fS+acfzHDpcFBoB9lxUE8LdI66SI5ldM2rL2MT5kA+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BDoub3OEmWO77jPf+up7G4v1gQ11llt5yBeTRE8KvJajfoLKenCHweWqeMZzjkF4B q+QYgfcKnOjrUMEyc94bof57ZPKsMKXPniZYR1E+mAOVoY3XRRRa52IHCwXDPwRlgP WmNmt6Kcz/UbWNmoEdJmeZa3pzHOafun3vC4LAQk= 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 05/66] nfc: fix memory leak in llcp_sock_connect() Date: Mon, 12 Apr 2021 10:40:11 +0200 Message-Id: <20210412083958.309423620@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 7574fcdbdcb335763b6b322f6928dc0fd5730451 upstream. In llcp_sock_connect(), use kmemdup to allocate memory for "llcp_sock->service_name". The memory is not released in the sock_unlink label of the subsequent failure branch. As a result, memory leakage occurs. fix CVE-2020-25672 Fixes: d646960f7986 ("NFC: Initial LLCP support") Reported-by: "kiyin(尹亮)" Link: https://www.openwall.com/lists/oss-security/2020/11/01/1 Cc: #v3.3 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 @@ -757,6 +757,8 @@ sock_unlink: nfc_llcp_local_put(llcp_sock->local); nfc_llcp_sock_unlink(&local->connecting_sockets, sk); + kfree(llcp_sock->service_name); + llcp_sock->service_name = NULL; put_dev: nfc_put_device(dev);