Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1750025imm; Sun, 27 May 2018 15:15:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqjYIEtuN471Np4bi/Ik+C8xZAmxYAwBm4nm4tcFb9X3jIdOJDko7mTcyH8shbNcWKKLyGF X-Received: by 2002:a17:902:9344:: with SMTP id g4-v6mr11354240plp.10.1527459332590; Sun, 27 May 2018 15:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527459332; cv=none; d=google.com; s=arc-20160816; b=sEZDnvwBLZLdRA+Q0uzeQJ2CM2IQ52r/4Z7V1Z/NMrEg+eTFubVWO+0zdpjDOxC18P Ir2Qy5KRHTvHnh+uLY0PrI2DJwI+G5l8EMKIQP0iwTYsL/hKYKADX26rnd4jzKjx82M9 RsjcUZnW2R2ftOp3nv9uBGmFcwLpZu4jrvTzhEpmXqATqL9KRuBLYb/Cgp0+2y2i7s4Y ACmuloHE/KP0iSezP56+kuorpy735H5nu6V3ecNZkbeAIMayDYp5l5gUwq68s+m5g7ze q6ys8bdN3b8L9eXA6NOIPxo3k8KIg9GILeJo36Uzy+M4ewK9EQiEySm9t5/v4x8nOMEd O5Eg== 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 :message-id:date:subject:cc:to:from:arc-authentication-results; bh=3ulAafuJY9caji7JDkxKhSe7EkCZFq+EUKgxNZz5joU=; b=iTcMWr+OSfOwa8teftj8s91jgIrveTINQ03nW+MyBG+JlstJ1rZVjn0AsLphkHGcJc tutZoJhK66WhQDXQlerwBAHcDmIAVQ8GHw7ekM63rApTbsof9WaNWCOLVZcVGtgwqmCs KBjG16Y+leT9umRr6fug1EkT1zBjAXQGy2yP4kbPxEeOLg+QV5+1tkM2F5AB0ONN0J7Z 323iXVEXgTYNgHRZV3TcTr7RqfCZJ5mEka3KLeRbqgQ5frses03SE9cALWwZy1M8nY2F oq40Lh4xv+VECbm/XDqvMvSh1w8UbuGCRr7Uzc7JAGFnvm7E9UuUn6Fjkr1EPG52iNTd 0dgg== 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r13-v6si22501396pgt.8.2018.05.27.15.15.17; Sun, 27 May 2018 15:15:32 -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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752065AbeE0WPI (ORCPT + 99 others); Sun, 27 May 2018 18:15:08 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42332 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbeE0WPH (ORCPT ); Sun, 27 May 2018 18:15:07 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fN3wN-00056c-1E; Sun, 27 May 2018 22:15:03 +0000 From: Colin King To: Matthew Garrett , Mimi Zohar , 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 Subject: [PATCH][next] EVM: fix memory leak of temporary buffer 'temp' Date: Sun, 27 May 2018 23:15:02 +0100 Message-Id: <20180527221502.25073-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.17.0