Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3992682ybg; Fri, 25 Oct 2019 11:48:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvPjToV+UNWcYubocJT/Wkx65zfF/NbxmilEzVFob+lXttlZZs3/cv31XLDMAszRbyOa1H X-Received: by 2002:a17:906:6d45:: with SMTP id a5mr4855178ejt.218.1572029287289; Fri, 25 Oct 2019 11:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572029287; cv=none; d=google.com; s=arc-20160816; b=DV4i3Fse60xw6JbaCbdVoKU8+A9xHTmMzXP5iuY4cHADp2cCo94896/SYyakMxNPXL 70Gp/1vye2/dboVkAeoPseILzuWGSewD+WOLkPiQhHhYJc586rQETd5+I+bLo5wWWthE 6DKm/nn23R4XfKKdNM/nFQQ3YFKpKhpIV6IfTEEo4LBoE7ERaVfBcd5ENBwRISCPvQ2r ic2f6cCD65yvKeqeKDg/wThpx6prOdcpP95gLfYrVjhBkm4GHugHRGvUN/CBcqGFTTLX 88Vrl/oKGE43qJ11hfEmVAJscZlNvyZAxL/M5yWMtw7X2MIuzolURJSJdbSkOxkyrTG4 rk3g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=3ZUalX6KkoUAF5B6PB7Omcj6z9c3JtgzJCEvYAwd0VY=; b=etP+5S+v9GBzQ1Gmmi0yhXmWEQkJjANY8rGwHV2d5UExEgAmUc85wSls/UPl9ezS/M 9N6mZNXJSKWMaWu1J3u7qBsRiVMzl1KJz1iPLjZSe4jGpR3MZaNwgVeyFZEftGeWd0ce GJqYKy/WB4CZObm3ZJsUVGNVDYayWHMSdqXuuaSgbkFw/74ZFVGEJgXQe0J98hJl0c6q EVKY1Li5TEbCJaTDoseyll4D85LBy9ijnuS/K0yMHx09MWVeFtzLQGcrpCpkfxZ42m+S 1f7Br6ZcuvGap7wgv7h5THbD7UQH9E6MLILib4oIy/Xbmup8UpAhgoNwkqFUMVVZJkLB Bpqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=NmpVP5wJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si1895985edb.41.2019.10.25.11.47.44; Fri, 25 Oct 2019 11:48:07 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=NmpVP5wJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394045AbfJXRsD (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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