From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D44ACA9EAF for ; Thu, 24 Oct 2019 17:48:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D810E21925 for ; Thu, 24 Oct 2019 17:48:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="NmpVP5wJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392697AbfJXRsD (ORCPT ); Thu, 24 Oct 2019 13:48:03 -0400 Received: from linux.microsoft.com ([13.77.154.182]:34088 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391933AbfJXRsC (ORCPT ); Thu, 24 Oct 2019 13:48:02 -0400 Received: from [10.137.112.111] (unknown [131.107.147.111]) by linux.microsoft.com (Postfix) with ESMTPSA id BDA842007698; Thu, 24 Oct 2019 10:48:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BDA842007698 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1571939281; bh=3ZUalX6KkoUAF5B6PB7Omcj6z9c3JtgzJCEvYAwd0VY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=NmpVP5wJwINzCT0SPLjmqinpkGdSwyezoHpWRuvlMuBoj9iE7RB28lUD40Bbxfjey ekY0mojRGuFy3P8GrrjWA9dKAcBB4rHMFXuK7nh/PpQdPkp4tcss7tqrIo+VXeYYry tOfu2KguYoTByJZvD24zDoXytbjBV/MhtxKq9PlQ= Subject: Re: [PATCH v9 7/8] ima: check against blacklisted hashes for files with modsig To: Nayna Jain , linuxppc-dev@ozlabs.org, linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Ard Biesheuvel , Jeremy Kerr , Matthew Garret , Mimi Zohar , Greg Kroah-Hartman , Claudio Carvalho , George Wilson , Elaine Palmer , Eric Ricther , Oliver O'Halloran , Prakhar Srivastava References: <20191024034717.70552-1-nayna@linux.ibm.com> <20191024034717.70552-8-nayna@linux.ibm.com> From: Lakshmi Ramasubramanian Message-ID: <8e6dde58-17c2-a834-9ec3-1271b4ffd3a8@linux.microsoft.com> Date: Thu, 24 Oct 2019 10:48:19 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <20191024034717.70552-8-nayna@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On 10/23/2019 8:47 PM, Nayna Jain wrote: > +/* > + * ima_check_blacklist - determine if the binary is blacklisted. > + * > + * Add the hash of the blacklisted binary to the measurement list, based > + * on policy. > + * > + * Returns -EPERM if the hash is blacklisted. > + */ > +int ima_check_blacklist(struct integrity_iint_cache *iint, > + const struct modsig *modsig, int pcr) > +{ > + enum hash_algo hash_algo; > + const u8 *digest = NULL; > + u32 digestsize = 0; > + int rc = 0; > + > + if (!(iint->flags & IMA_CHECK_BLACKLIST)) > + return 0; > + > + if (iint->flags & IMA_MODSIG_ALLOWED && modsig) { > + ima_get_modsig_digest(modsig, &hash_algo, &digest, &digestsize); > + > + rc = is_binary_blacklisted(digest, digestsize); > + if ((rc == -EPERM) && (iint->flags & IMA_MEASURE)) > + process_buffer_measurement(digest, digestsize, > + "blacklisted-hash", NONE, > + pcr); > + } The enum value "NONE" is being passed to process_buffer_measurement to indicate that the check for required action based on ima policy is already done by ima_check_blacklist. Not sure, but this can cause confusion in the future when someone updates process_buffer_measurement. Would it instead be better to add another parameter to process_buffer_measurement to indicate the above condition? -lakshmi