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: 10269269 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 06806602C8 for ; Thu, 8 Mar 2018 21:45:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA37D209D8 for ; Thu, 8 Mar 2018 21:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE97728ED9; Thu, 8 Mar 2018 21:45:51 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI 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 6970624603 for ; Thu, 8 Mar 2018 21:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750909AbeCHVpv (ORCPT ); Thu, 8 Mar 2018 16:45:51 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:55735 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750792AbeCHVpu (ORCPT ); Thu, 8 Mar 2018 16:45:50 -0500 Received: by mail-it0-f65.google.com with SMTP id n136so348518itg.5 for ; Thu, 08 Mar 2018 13:45:50 -0800 (PST) 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=kmoMm8DEAubkVjTCTMqogke7Mbgfeb2k/hDnQ9KfzMsXtHOMIZPghd/rTZjET8QyxT wqK6DeOlaZJjyaY96bOKZLKfOlDy5mWPbqTkoK8AYaAFK/8JU9PJYgReLbuMeMF4lr6v z2vxgKsGIQmKIM0jsXV0bf8JWfFF1wCGu7hEDkkiCJQorBdlR03+Xc1C41UktXthrBvb XhXXjHZufbiR7vLSPQBlcwmlkCgRjCDT6ZkbcaTX0MZkxoYaGQ8z0poEn3HwRKFpME5c 4p8Q/zl9CDhwu7DSv2DggoG7Sxp+mZ4kTkuicfkYLlGwzWgxSd0phvXOeA5T/dDrkHgR vdAQ== X-Gm-Message-State: AElRT7FGROdgkC/7QkLhbjv9MnNkwb7iw/nUEbm3kdZ3EuqS3S+WGaLM UGTg3+tYCwkaZfWDA8aw82kbfMZt 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) Received: from smitten ([8.24.24.129]) by smtp.gmail.com with ESMTPSA id 195sm8716982itm.13.2018.03.08.13.45.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 13:45:48 -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) 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 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))