Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1674245pxb; Fri, 20 Nov 2020 16:12:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1cdCVZmdwOjr3IP8BVxyy0MaqPHjJnhu5UZEw5PE/oMur/TuoGi4h+Dhrt9K9G1c+/Ces X-Received: by 2002:a05:6402:1d82:: with SMTP id dk2mr15720475edb.366.1605917528990; Fri, 20 Nov 2020 16:12:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605917528; cv=none; d=google.com; s=arc-20160816; b=gHrSDBD3oNYbMMlKSQo3f90f/lBvEZlktZLPYiEbrUgVCLk43gGFakWwzJjSVI+7OQ TI7/b5AIr+cuAXsoxColgD1aqVLzq6K9HtjoQWoTSbdvuVFSgodUWYefl23Kk21l642H hEPhvBavi5DJQYz7ZmEoRiSKw3p4vCxH7dXvpTcXCTISoVZnNG7KzNcMirhotdEJstgH zw+WHjcZkipL7Sj5HnUMAx5Ge/TjHnkmPjWV0saKrajAjlcgT5+KsJbw4CP/Q5Wh2KcI 5emJ4BxBttkwGuDuGd4ywj7bDOL22Glz2fykaafHxxLqOhtLHAkSeK9YYArzglUsCPOc DtMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PONzCKvr+vwt6Flh5wCrTZaAerJA45zVvmdcMNuJ7vs=; b=B7w/C2CEE6F6vX2LyWZMn5VLO170TpL/XygYfpca23L/FlakgSOcw5zh5DRGFah+4U CmH692aIBOCFbIE9wQcHAtQvK4axyPcIAbCxmb6Svv/WnApp6ldrh/Vp5fxYZc+aAywl YrmV0vCHphiKRvYdCqujSIY5B7e1sa9E6bF2tm0j1wAK1EkPi+iQVaCp1Q/dI7L4ikP0 7EJbUJNcIUs7WQ//ug5mntJ6ScClpsaeinYUhO19h+tIMMzcqP/q7tYjFyewT3Ol3rVv kOdsfSaNg56ms+9lndtFLBRPIhaWHfywcjQJYy2fwduqY7iIONDeT8/7lVhWTh5mLTn/ clbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bbxfmC8e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si2725438edy.536.2020.11.20.16.11.45; Fri, 20 Nov 2020 16:12:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bbxfmC8e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728256AbgKUAI4 (ORCPT + 99 others); Fri, 20 Nov 2020 19:08:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728084AbgKUAIz (ORCPT ); Fri, 20 Nov 2020 19:08:55 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 445D6C061A47 for ; Fri, 20 Nov 2020 16:08:53 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id a9so15900266lfh.2 for ; Fri, 20 Nov 2020 16:08:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PONzCKvr+vwt6Flh5wCrTZaAerJA45zVvmdcMNuJ7vs=; b=bbxfmC8eTRqjVK5ZEjTEUJxgrpO0kFVf9/uaSgCzhVMht34nhcdL+ZW4ekpzcvrIMO 9G9gVesVNgsLfz8U1zun2zlQ6o1rW+PWPK5QLzF3yfRYlcmgfUNtISGccc6TFlKxNAtJ ewPxxLZFrlhcvMfHsn86USwX6n9sMnGcjDpCk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PONzCKvr+vwt6Flh5wCrTZaAerJA45zVvmdcMNuJ7vs=; b=QP+i8OdC1iIJtOfA+VH87PjIlt2E8j0A4uuS99DZ7uPI0NTAj7ez/LiyuyhtOerPEo kt3bJC83axVTBhRuIOyq+5+vIqsLD+Qq8KKfZtBLV+Vv65RcM+HNS0MkRTMdFMVas3BS i+WsQu42wYlrZ8vNSJO5+3sKv8mki5ut3YRto5zsPggAsuFnKKJefMJF69ApDlESD8TA sILbkaJYKKRxhleg2PEsHBNZxRY5cSRL4Kyd+/I8rR1vwY6j41uCT2U3UVYwczcRzRaO 2oEmYrgci+xUIl5VFj1xvHhd2RZ2bnw5B+xw3pRKwHsbtahb42I6kpXtd9HK85eYggqS PFUw== X-Gm-Message-State: AOAM532HjORpoK06AuJcwKllNmrwzlFzgWXhwvL0qWa0SvrS2bHT3nve WHvCZ+XneTtQp8fNaqqtki2XV1IErxUt8cZD0R1UDg== X-Received: by 2002:ac2:5591:: with SMTP id v17mr8636915lfg.562.1605917331662; Fri, 20 Nov 2020 16:08:51 -0800 (PST) MIME-Version: 1.0 References: <20201120131708.3237864-1-kpsingh@chromium.org> In-Reply-To: From: KP Singh Date: Sat, 21 Nov 2020 01:08:40 +0100 Message-ID: Subject: Re: [PATCH bpf-next 1/3] ima: Implement ima_inode_hash To: Yonghong Song Cc: James Morris , open list , bpf , Linux Security Module list , Alexei Starovoitov , Daniel Borkmann , Florent Revest , Brendan Jackman , Mimi Zohar Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] > > > > diff --git a/scripts/bpf_helpers_doc.py b/scripts/bpf_helpers_doc.py > > index c5bc947a70ad..add7fcb32dcd 100755 > > --- a/scripts/bpf_helpers_doc.py > > +++ b/scripts/bpf_helpers_doc.py > > @@ -478,6 +478,7 @@ class PrinterHelpers(Printer): > > 'struct tcp_request_sock', > > 'struct udp6_sock', > > 'struct task_struct', > > + 'struct inode', > > This change (bpf_helpers_doc.py) belongs to patch #2. Indeed, I missed it during a rebase. Thanks! > > > 'struct path', > > 'struct btf_ptr', > > } > > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > > index 2d1af8899cab..1dd2123b5b43 100644 > > --- a/security/integrity/ima/ima_main.c > > +++ b/security/integrity/ima/ima_main.c > > @@ -501,37 +501,17 @@ int ima_file_check(struct file *file, int mask) > > } > > EXPORT_SYMBOL_GPL(ima_file_check); > > > > -/** > > - * ima_file_hash - return the stored measurement if a file has been hashed and > > - * is in the iint cache. > > - * @file: pointer to the file > > - * @buf: buffer in which to store the hash > > - * @buf_size: length of the buffer > > - * > > - * On success, return the hash algorithm (as defined in the enum hash_algo). > > - * If buf is not NULL, this function also outputs the hash into buf. > > - * If the hash is larger than buf_size, then only buf_size bytes will be copied. > > - * It generally just makes sense to pass a buffer capable of holding the largest > > - * possible hash: IMA_MAX_DIGEST_SIZE. > > - * The file hash returned is based on the entire file, including the appended > > - * signature. > > - * > > - * If IMA is disabled or if no measurement is available, return -EOPNOTSUPP. > > - * If the parameters are incorrect, return -EINVAL. > > - */ > > -int ima_file_hash(struct file *file, char *buf, size_t buf_size) > > +static int __ima_inode_hash(struct inode *inode, char *buf, size_t buf_size) > > { > > - struct inode *inode; > > struct integrity_iint_cache *iint; > > int hash_algo; > > > > - if (!file) > > + if (!inode) > > return -EINVAL; > > Based on original code, for ima_file_hash(), inode cannot be NULL, > so I prefer to remove this change here and add !inode test in > ima_inode_hash. Makes sense. Thanks! > > > > [...] > > + * If the parameters are incorrect, return -EINVAL. > > + */ > > +int ima_inode_hash(struct inode *inode, char *buf, size_t buf_size) > > +{ > > Add > if (!inode) > return -EINVAL; Done. > > > > + return __ima_inode_hash(inode, buf, buf_size); > > +} > > +EXPORT_SYMBOL_GPL(ima_inode_hash); > > + > > /** > > * ima_post_create_tmpfile - mark newly created tmpfile as new > > * @file : newly created tmpfile > >