Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2469402pxj; Mon, 10 May 2021 03:52:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI64c/d3sq3t5r4y+lo9uOWda2KATXevrFYPFbzshDfVIW3YPcJJtbeLfiy/WcXU9HJu9h X-Received: by 2002:a05:6602:3159:: with SMTP id m25mr6008976ioy.147.1620643945202; Mon, 10 May 2021 03:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643945; cv=none; d=google.com; s=arc-20160816; b=qpICVSsljMwerDhpzNarqecOQkGmhv1bGevaxe+KiWcxrQoD01VZ5jg7Joc8f8W9W2 UzplmCAs4icVOQM05XZLhWyuUz6CMM0YVV7z7k9myA0GWkHv9YZ/CvwooBk6txQj2/fM eYhGNZh2p54EMWFRbu16hU5hmMVSNwWEr6frVRgFGz0zDPj+W+QWmT6gHcjor5bM9M8c /gieW5xuVyhl+aWLEndtuPB0fCn9ISzCcAEC8hIURe+XMjjhrrLjWb3/SRiarYfMdOFu 2+M1oGK8mrrSRut7xfrIo+8o/Mu4UPrdXO1INJazNi1ekimV/SrSvKz8Os8gjqFP+KdK m0sg== 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=IlWcA3L+4rS5yn5prxgTfYvGdH0VbaPys7oQN0GAyBA=; b=Fp3gjfzyaHVgru8IJz/SSbLGORayRaLba11LBho5eB1TB3GztnABk75Etp3pJ3deQG Fbn8yDsfNLsqWl712jl2dIgvJODYIqfgfZUx7QDG4WJDwjpVmiucihgId4qUu86LKeWN KhcPmcbQ0ebB4cqbJA6UazgebSeq4Dg3K3KmtfHZVe7PoHRgWDKDjDWZ8NUic4p253ix b9xEBBS0owQsB3YKz3f4/98dv2yrs6ze3ugNNDgnGC/85gA1fijxJmszUGgtN7cDX0QH JOyVJlHt/ineujjZQu4PEXkASuA05BuQGOzd5vd+68DBBqoGjEBcqVothx9RJA2hp7Mi u/uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mh7el/fL"; 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 r14si15138707jad.14.2021.05.10.03.52.13; Mon, 10 May 2021 03:52: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="mh7el/fL"; 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 S233115AbhEJKvm (ORCPT + 99 others); Mon, 10 May 2021 06:51:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbhEJKlL (ORCPT ); Mon, 10 May 2021 06:41:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4533461971; Mon, 10 May 2021 10:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642722; bh=7hBYsmq3KtSYF2pUFkYJxrX++i1XE/CS+Ns8JFKTeL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mh7el/fLeKpCxk2ilIzAlBljV1azGybxEzhLsdEi+mZW1naOpRU/5eRBB1EVV3dXx B9tOzXO4S06y9o0sfyFQhpvcnYttX1gHt2N7gApQF2VLEeRP/iJqXRfA1N4BYgR9oy rDCrjG00BTvcepDVk+8EEK/o8PcYOPtNHI3RZnRU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Hartmayer , Harald Freudenberger , Julian Wiedmann , Heiko Carstens Subject: [PATCH 5.10 007/299] s390/zcrypt: fix zcard and zqueue hot-unplug memleak Date: Mon, 10 May 2021 12:16:44 +0200 Message-Id: <20210510102005.068076700@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Harald Freudenberger commit 70fac8088cfad9f3b379c9082832b4d7532c16c2 upstream. Tests with kvm and a kmemdebug kernel showed, that on hot unplug the zcard and zqueue structs for the unplugged card or queue are not properly freed because of a mismatch with get/put for the embedded kref counter. This fix now adjusts the handling of the kref counters. With init the kref counter starts with 1. This initial value needs to drop to zero with the unregister of the card or queue to trigger the release and free the object. Fixes: 29c2680fd2bf ("s390/ap: fix ap devices reference counting") Reported-by: Marc Hartmayer Signed-off-by: Harald Freudenberger Cc: stable@vger.kernel.org Reviewed-by: Julian Wiedmann Signed-off-by: Heiko Carstens Signed-off-by: Greg Kroah-Hartman --- drivers/s390/crypto/zcrypt_card.c | 1 + drivers/s390/crypto/zcrypt_queue.c | 1 + 2 files changed, 2 insertions(+) --- a/drivers/s390/crypto/zcrypt_card.c +++ b/drivers/s390/crypto/zcrypt_card.c @@ -192,5 +192,6 @@ void zcrypt_card_unregister(struct zcryp spin_unlock(&zcrypt_list_lock); sysfs_remove_group(&zc->card->ap_dev.device.kobj, &zcrypt_card_attr_group); + zcrypt_card_put(zc); } EXPORT_SYMBOL(zcrypt_card_unregister); --- a/drivers/s390/crypto/zcrypt_queue.c +++ b/drivers/s390/crypto/zcrypt_queue.c @@ -223,5 +223,6 @@ void zcrypt_queue_unregister(struct zcry sysfs_remove_group(&zq->queue->ap_dev.device.kobj, &zcrypt_queue_attr_group); zcrypt_card_put(zc); + zcrypt_queue_put(zq); } EXPORT_SYMBOL(zcrypt_queue_unregister);