From patchwork Thu Oct 10 13:13:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11183539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EF6B1668 for ; Thu, 10 Oct 2019 13:14:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 475BB206B6 for ; Thu, 10 Oct 2019 13:14:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 475BB206B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE0BC6EB31; Thu, 10 Oct 2019 13:14:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2BB296EB36; Thu, 10 Oct 2019 13:14:39 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id v24so6178744ljj.3; Thu, 10 Oct 2019 06:14:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s1+YBubYAy3yg+TIRBWGGXrMgcLsTM12YLsh849J2aI=; b=Hc4BUbVAJvpxCgPsl2SKlk2UXzfLYFVIr2ATS65WZft3mP5VinSEJZf2kLDNuMIJBJ 9zHcbaqP0OsMRRKP1QuabSlB6z+3ICQpj1Wl18eqg2WoWwV7eu+qx+lKcWy3sYZqKu2J RxqDp5H/Zj3FO5P67tG/KrUISc7wbHDzbx+uS3A2WqUgfuqJv9QUc/uJRH1OqoOAN7jf wa03PaWU7hylrbRQeC8uU1q+6x0oPtRc2C31Pse1A77lyGbBVn1WkUPYg+ITY8QRnW8m tJrNMFzVN0tjIVoxs/XlSAdnP2LEaGcFuO8Ev325Pcukf4nNJn+o63myug47eePq3q6H ljrw== X-Gm-Message-State: APjAAAVVmg/xUSJAVceIjy7Rk3TIjsI+6vVu6/MIyRc8CF7Gq8Ob+ZDs rNUxT5rSR5d1gqNSTQStdH8= X-Google-Smtp-Source: APXvYqyGy/J5HJ8vBpZO6LgQKgo1ma21ffDHecTu24LtFMjl2KdmKbxfJ1wNcSxoN50D6wfsye9EWA== X-Received: by 2002:a2e:964c:: with SMTP id z12mr6158807ljh.79.1570713277523; Thu, 10 Oct 2019 06:14:37 -0700 (PDT) Received: from xi.terra (c-51f1e055.07-184-6d6c6d4.bbcust.telenor.se. [85.224.241.81]) by smtp.gmail.com with ESMTPSA id h3sm1238457lfc.26.2019.10.10.06.14.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Oct 2019 06:14:35 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.92.2) (envelope-from ) id 1iIYHF-0006Az-Mh; Thu, 10 Oct 2019 15:14:45 +0200 From: Johan Hovold To: Rob Clark , Sean Paul , Fabien Dessenne , Mauro Carvalho Chehab , Harald Freudenberger Subject: [PATCH 4/4] s390/zcrypt: fix memleak at release Date: Thu, 10 Oct 2019 15:13:33 +0200 Message-Id: <20191010131333.23635-5-johan@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010131333.23635-1-johan@kernel.org> References: <20191010131333.23635-1-johan@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, Vasily Gorbik , David Airlie , linux-arm-msm@vger.kernel.org, Heiko Carstens , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Johan Hovold , Christian Borntraeger , stable , Greg Kroah-Hartman , Martin Schwidefsky , freedreno@lists.freedesktop.org, linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If a process is interrupted while accessing the crypto device and the global ap_perms_mutex is contented, release() could return early and fail to free related resources. Fixes: 00fab2350e6b ("s390/zcrypt: multiple zcrypt device nodes support") Cc: stable # 4.19 Cc: Harald Freudenberger Cc: Martin Schwidefsky Signed-off-by: Johan Hovold --- drivers/s390/crypto/zcrypt_api.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 45bdb47f84c1..9157e728a362 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c @@ -522,8 +522,7 @@ static int zcrypt_release(struct inode *inode, struct file *filp) if (filp->f_inode->i_cdev == &zcrypt_cdev) { struct zcdn_device *zcdndev; - if (mutex_lock_interruptible(&ap_perms_mutex)) - return -ERESTARTSYS; + mutex_lock(&ap_perms_mutex); zcdndev = find_zcdndev_by_devt(filp->f_inode->i_rdev); mutex_unlock(&ap_perms_mutex); if (zcdndev) {