From patchwork Fri Jun 1 08:00:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10442637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4292D604D4 for ; Fri, 1 Jun 2018 08:00:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F4629045 for ; Fri, 1 Jun 2018 08:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34F9D2909C; Fri, 1 Jun 2018 08:00:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C17E0290A3 for ; Fri, 1 Jun 2018 08:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751270AbeFAIA0 (ORCPT ); Fri, 1 Jun 2018 04:00:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56864 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbeFAIAZ (ORCPT ); Fri, 1 Jun 2018 04:00:25 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w517u7nh181497; Fri, 1 Jun 2018 08:00:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=/hRbM2dRR9G34KtEae37AXO/vY3x8iE1NoIIWvmChH8=; b=H/l3ascUiI9g+jN2S9GdsyunuYGBzN7/AZ0w9dAkRUM7nau/FtwpQRwW1x7q2QATpLsq 2N+PXnresSGZGqMMm3QFe0oa0Xuu0di4i0p3EFyK09jZ45RHV5E+TFskeOJZzG0pxRZ8 xuGx2p7iZpJHeAZEk4md43lP9nR5u5jSQR+lQC8TjRYUsTw9jjKpbSJJy0oxpL+5eCol cw/1HwoCqs4I3Izw7JeM0W4VuUnwUcLU4MS4gIbA4ZgCeg6Vi9N3vXsHb2Y4oMMGBOH/ vi62q4Y4lI/JdVi/9xMCVruk0x8aHRQJnYl6FyocMOHStHd+Ru8KEQitDAxa9PTCJM+E 6g== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2janje2y0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Jun 2018 08:00:18 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5180GwX007775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Jun 2018 08:00:16 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5180D9G028926; Fri, 1 Jun 2018 08:00:14 GMT Received: from kili.mountain (/197.157.0.20) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Jun 2018 01:00:13 -0700 Date: Fri, 1 Jun 2018 11:00:05 +0300 From: Dan Carpenter To: Mimi Zohar , Matthew Garrett Cc: James Morris , "Serge E. Hallyn" , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] EVM: unlock on error path in evm_read_xattrs() Message-ID: <20180601075946.wpyly2mgmaynfm4c@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8910 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=921 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806010090 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to unlock before returning on this error path. Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs") Signed-off-by: Dan Carpenter diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c index a7a0a1acae99..6d3b34ae8499 100644 --- a/security/integrity/evm/evm_secfs.c +++ b/security/integrity/evm/evm_secfs.c @@ -147,8 +147,10 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf, size += strlen(xattr->name) + 1; temp = kmalloc(size + 1, GFP_KERNEL); - if (!temp) + if (!temp) { + mutex_unlock(&xattr_list_mutex); return -ENOMEM; + } list_for_each_entry(xattr, &evm_config_xattrnames, list) { sprintf(temp + offset, "%s\n", xattr->name);