From patchwork Thu Mar 8 21:45:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tycho Andersen X-Patchwork-Id: 10269273 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 5EA0E60594 for ; Thu, 8 Mar 2018 21:46:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F34F24603 for ; Thu, 8 Mar 2018 21:46:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43E8E28FBC; Thu, 8 Mar 2018 21:46:05 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 4BAEB24603 for ; Thu, 8 Mar 2018 21:46:03 +0000 (UTC) Received: (qmail 31799 invoked by uid 550); 8 Mar 2018 21:46:02 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 30717 invoked from network); 8 Mar 2018 21:46:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=QrLpN9Xuo48jmxK0El6J2/qhXp1hSMxLHOrDO04ysvg=; b=2CeeSLJ3JzXdgW1Yph3EXrtMcIZjT2DObGzQ1gN2QRYl/9WnzC6GvOhYSNxJ0uS2JX 1N19OCmcWx/TloAnZLPnKSHKhBSQURFE3yqMLubh89IcmHg/jPXxfq0mo040WdwDCDoJ iiOeOQlitmFPBfFRhlgZGhhgquw/S8Pla/8AuiIb3+U4L53CNaSa/orrq7SEuTGPh6T3 XstY7AmlZLzgSCbCOwJu+QB9iGiR6SKFYBw8YwO+toXIAq2UTQHkJycKII8KIDlbGOVR qsvR+KgancQRqVUJYLSjpnLB3Y/ra6E8xSBfcHSm5g4wMyLZd8WIkbApksCP1eXl1zjs JggQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=QrLpN9Xuo48jmxK0El6J2/qhXp1hSMxLHOrDO04ysvg=; b=DAITrczlcqKjNIeIs8UMnQN9T+ip9xTzJLpe8XFjt+ZVVRXJHYo3bJ6w1UWXzPgOnB wbFQ2CsmkxfqEmGkqjTektAM4w62OfCLdujD0IGLOlYeXPwR+KbLGLePcQVwCVdIyILX PDLt3wlI0cC47Z1t5xkuCIYSJ/m85/7JSqSf3KVk3udXjCEpu1OxAWWx8OxGH1HWnqGS YX3xMNQnNEY8cQGooF+3yrz54nrBtcRxGqIEOhZA0XPLLLZqm75hvIQjkEAAvLsWg+Rj Rhcqx6SpB6FSmSON7Fuqd55qMS7wWbegkNmtlzfPor6ppGqFDMyH9sXsh/TsxpWmTDgQ PWXw== X-Gm-Message-State: AElRT7FlhdtRSsbV1HlDcujdB50CPgjxLCmZSTo3vkTx5wOgWV6QvZYU ahYWsbOhEAR2Yefo07+w4FPaEA== X-Google-Smtp-Source: AG47ELtUEGEa0oFOXBBTNvZmQ0iqUE6YwqKYVK/grRyJ2uiI7A3pNG9mL1t6p13kwQdaGEoL69AMYw== X-Received: by 10.36.92.205 with SMTP id q196mr456808itb.135.1520545549409; Thu, 08 Mar 2018 13:45:49 -0800 (PST) Date: Thu, 8 Mar 2018 14:45:47 -0700 From: Tycho Andersen To: Mimi Zohar Cc: Dmitry Kasatkin , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [PATCH v2] ima: drop vla in ima_audit_measurement() Message-ID: <20180308214547.kdeoeozugxffzumn@smitten> References: <20180308202347.31331-1-tycho@tycho.ws> <1520541374.3605.101.camel@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1520541374.3605.101.camel@linux.vnet.ibm.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Virus-Scanned: ClamAV using ClamSMTP Hi Mimi, On Thu, Mar 08, 2018 at 03:36:14PM -0500, Mimi Zohar wrote: > On Thu, 2018-03-08 at 13:23 -0700, Tycho Andersen wrote: > > > /* > > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > > index 2cfb0c714967..356faae6f09c 100644 > > --- a/security/integrity/ima/ima_main.c > > +++ b/security/integrity/ima/ima_main.c > > @@ -288,8 +288,11 @@ static int process_measurement(struct file *file, char *buf, loff_t size, > > xattr_value, xattr_len, opened); > > inode_unlock(inode); > > } > > - if (action & IMA_AUDIT) > > - ima_audit_measurement(iint, pathname); > > + if (action & IMA_AUDIT) { > > + rc = ima_audit_measurement(iint, pathname); > > + if (rc < 0) > > + goto out_locked; > > + } > > > > if ((file->f_flags & O_DIRECT) && (iint->flags & IMA_PERMIT_DIRECTIO)) > > rc = 0; > > Only when IMA-appraisal is enforcing file data integrity should > process_measurement() ever fail.  Other errors can be logged/audited. Ok, so previously in ima_audit_measurement() when allocation failed, there was nothing logged. If we just keep this behavior like below, does that look good? Thanks! Tycho diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 356faae6f09c..4e699bc7adc5 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -289,9 +289,13 @@ static int process_measurement(struct file *file, char *buf, loff_t size, inode_unlock(inode); } if (action & IMA_AUDIT) { - rc = ima_audit_measurement(iint, pathname); - if (rc < 0) + int ret; + + ret = ima_audit_measurement(iint, pathname); + if (ret < 0 && ima_appraise & IMA_APPRAISE_ENFORCE) { + rc = ret; goto out_locked; + } } if ((file->f_flags & O_DIRECT) && (iint->flags & IMA_PERMIT_DIRECTIO))