Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2355990ybp; Thu, 10 Oct 2019 06:18:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8dLJbsCFaZTqMaabd2Hl8gCyK/yZBnuz9CkCc7oOAQIl2uIswwpYvjENTJEk3L6iVaGGa X-Received: by 2002:a17:906:b245:: with SMTP id ce5mr8049139ejb.52.1570713515089; Thu, 10 Oct 2019 06:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570713515; cv=none; d=google.com; s=arc-20160816; b=cXRNSsGy6wCGKhw/GrXLZS7dX1H6T7Jm4Zb1AbM9tEwEexffLU/E5ucYQIdalE7r/X ttno+yPH9I82nSYI5JKzxWX4bG5bYM/4k5fntt2ILQqNPxR+cJJpmtbEooVTfjdX8+j3 4KS+/W0q9hh4fc0hAPvpWEmOEfVKuO+icjioDh+VmVzcqno1VfzuVqHk/rdH2VL8jIUi z6ZJZC60p/H0BcCEa1Z8Zzx8myk73VgdJZPb0AXs6RIBKRTVSGlgWsnKb5GonKMapXTg M7nAaZXqiq7X1/ZsPXvmrfr/bjYNRikuKThpw7bua/WyPBAbsWBpTdACUjP9HeVKYjiL 9gZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=s1+YBubYAy3yg+TIRBWGGXrMgcLsTM12YLsh849J2aI=; b=bv9xvtuQZWPiw3STZD8K+Q67cuLFYaKWhr53Rp5bu4I/JiaBVRz1p0yytMrTlYC/+s v8d+z3A7fB5HtrBs/Bi6yks/Bimb8mTjHpYVBofTCM7bWYnJs0b9RQz+tcjYnFVNNkVC cJ9qyCtsBwsQXgJr4Zo8hcHMAJi90sZPPuIDDQCS+E9iorq21rfhO4bsXnUoLrGU3uHL o/wLt6vosRDr29Alwf/kLz/ieI0POMVGjtlf7QDfis6kGZkMKHE1DT6+8qpT3vOqeYu9 uRP3VNK3DIriBH5XY2ZskiS0DHxmZi5HYGpZL3m9c7QgOpvjyHHL6BdTypZaZHVlbZO1 Z+bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bq16si3103082ejb.221.2019.10.10.06.18.08; Thu, 10 Oct 2019 06:18:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388193AbfJJNOw (ORCPT + 99 others); Thu, 10 Oct 2019 09:14:52 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37325 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388023AbfJJNOj (ORCPT ); Thu, 10 Oct 2019 09:14:39 -0400 Received: by mail-lj1-f193.google.com with SMTP id l21so6170980lje.4; Thu, 10 Oct 2019 06:14:38 -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=GCr/BKYneZjSwP7jPBlb57caufJrp63/BJh+AMpnpy3T46QUyd0PB7z3TKPlz/5xmb 06BLf9DqaTSxVW8HGBv20bhkTfNZtZR8/ZFTA+hUJqYmog6w1FhiDCwNc/ii/kuTYizt 1PimM7DuCLDTY9YmidqlhDQOOybJdU1GeeR33idUDRiXvaMlSOKfq0EIeC1TwP16Me15 q2nHXRk+ucRL+MPVhmEf09UHJgASZSWpxvghJdOUq6UtFXOkeOCPOueXG/DAAzLx1jWq FeDivUhIp5k7UaF5IxOBuak3Jn5g9oZu8YpgU99zIpEjau4XONmzvEjZHwmUhSQIxaFu nzvQ== X-Gm-Message-State: APjAAAW4L0Rk+//uheyRhWs5FNdUMoD+vuhWF+tdQSOr3/HjgH7YDwb2 eQpkFOFJ9yupSGtwkUw8Ewxs4Y4v 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 Cc: David Airlie , Daniel Vetter , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-s390@vger.kernel.org, Greg Kroah-Hartman , Johan Hovold , stable , Martin Schwidefsky 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.23.0