Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp703663imm; Thu, 31 May 2018 08:01:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ26bvVyQi406TwxTTtTQlmFNXmpgZxydXYpNZl6+ajlA7M3sJlmw3XlkUycjkS4Ds1qc2f X-Received: by 2002:a65:4204:: with SMTP id c4-v6mr5715702pgq.26.1527778891804; Thu, 31 May 2018 08:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527778891; cv=none; d=google.com; s=arc-20160816; b=DIRVi1qJNrKFWtpZa+0SFCsrEbqYWieerNgwEPdsYOn4vh0cmU4HsQ4sJ9Df7AbWdi 4UKsEgNTkEwnfykx+3BDI8dtbX3BVt7njCSwmcINs63jlTWxNVGyMua3mMntv5QBq0A3 tXeg31xhCTVl0mWgrM9jqCOT1K13iv3BLiGMVfffU7apcWiSAnThoq3mwtudI4zeXe5M aiaDf0YPiEYqnQD/R4I9m3M+h8iOKqqECNDjTVHK13l2UNy1UyUTV7JOBxKHDNfHcIvi 9432wy4dzMB1g5jpyDNDsvUvrCislu8GINTM/8exu9uwr+BZewsDMj0VMHPJivl3oGp3 PyXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject :arc-authentication-results; bh=lBR7HNfcM9FCSwVGX39iuCKQ6/uI04Rvvs1SJVZp8SI=; b=zsxFDPTtOKaRnI9WuURLu3ep7/8Ux42qWaA5Dh4dw919lUI0PSsIXQaGq2ssYLZgtK cRcz8qi/wf+2arQ+kTt54akPN25e+L7GMqlupdHEFTddMRQEiGETOXNwNj5v9xc9pYsw ob2NKn2Fk2Bjbw1RKul0p5b3x+szJ12v4DYCOaL9SPpK6qnB02MpnKDdl4GZjlCSNyLp 1sOdLJpVsFq8MJP8EaNsO677veX819dBJqjBpVR1lUGfeIc0vHGpqcX+9+93Nu2TW3On hPoPEn42oMjTeJai7r6HrFrH4w2G9lh+tmdZOvIvPJ5qcYAKC/tWIyeN4mMQWH0sqLyL s+4A== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6-v6si30341911pgc.509.2018.05.31.08.01.16; Thu, 31 May 2018 08:01:31 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755421AbeEaPAs (ORCPT + 99 others); Thu, 31 May 2018 11:00:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59038 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755359AbeEaPAo (ORCPT ); Thu, 31 May 2018 11:00:44 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4VEwnnU145482 for ; Thu, 31 May 2018 11:00:42 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jaj4euh1x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 31 May 2018 11:00:41 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 31 May 2018 16:00:39 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 31 May 2018 16:00:35 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4VF0Ycv9896160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 31 May 2018 15:00:34 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35B17A4051; Thu, 31 May 2018 15:51:44 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A678A4069; Thu, 31 May 2018 15:51:43 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.85.240]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 31 May 2018 15:51:42 +0100 (BST) Subject: Re: [PATCH][next] EVM: fix memory leak of temporary buffer 'temp' From: Mimi Zohar To: Colin King , Matthew Garrett , James Morris , "Serge E . Hallyn" , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 31 May 2018 11:00:22 -0400 In-Reply-To: <20180527221502.25073-1-colin.king@canonical.com> References: <20180527221502.25073-1-colin.king@canonical.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18053115-0020-0000-0000-000002956846 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18053115-0021-0000-0000-000020E0E6E4 Message-Id: <1527778822.3427.13.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-31_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1805310169 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2018-05-27 at 23:15 +0100, Colin King wrote: > From: Colin Ian King > > The allocation of 'temp' is not kfree'd and hence there is a memory > leak on each call of evm_read_xattrs. Fix this by kfree'ing it > after copying data from it back to the user space buffer 'buf'. > > Detected by CoverityScan, CID#1469386 ("Resource Leak") > > Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs") > Signed-off-by: Colin Ian King Thanks, this patch and "EVM: Fix null dereference on xattr when xattr fails to allocate" are queued in the next-integrity branch. Mimi > --- > security/integrity/evm/evm_secfs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c > index a7a0a1acae99..fb8bc950aceb 100644 > --- a/security/integrity/evm/evm_secfs.c > +++ b/security/integrity/evm/evm_secfs.c > @@ -158,6 +158,8 @@ static ssize_t evm_read_xattrs(struct file *filp, char __user *buf, > mutex_unlock(&xattr_list_mutex); > rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp)); > > + kfree(temp); > + > return rc; > } >