Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2624397pxv; Sun, 27 Jun 2021 03:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+pmgSyxyAkceTKjfgWtwcw7fUmMM0HYJUcvoCmycjFqptaUsFLxWAwsObBEmdgCN/GFC1 X-Received: by 2002:a05:6602:1244:: with SMTP id o4mr5048854iou.22.1624791427843; Sun, 27 Jun 2021 03:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624791427; cv=none; d=google.com; s=arc-20160816; b=QOHfaT/HLyG2cMVzYVteReBjknoRcvHGRjaFBvKpHkAoRcwp6uR/fmVwi699yN6K+T BGfd8xtN1f8yT1YU8MpwpTmQMbP0eeR0tzuR3wusgbQ5DP1Azyxyf0alpPrcPZfu3ils F6maDa2WCkkVNiVanT/CeBHk/XK6oz2OEatEKciQIPcdz4x9X5eCShVXmEUgYlb1JZbf 6yKFYCSStK8Mydh0nTw1eVAgRYEOvcsvJFivlMerwCaCasanrMQcOElKy4S25gdHsgSh G9oY5htu3I1utTYOQSTZqb9df5qYy9YLUmFWRh2it+Aks43z5GwuNI284sRs+irsTjrt azog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wwSm7DyCnARpIdSwxH3vmSlfsp7NBEWVo6YbKdKznTY=; b=bWW558sS47tIDaDRoj/m7Qw21SB9t/Tqx+PpCV/8PMCKkNb84YVz0b3G2TgYZk/KAm vZXJMebEiRe540TXmWlCs7KlSXOoLkzWvvL644tdw4UdMYFA5+A4Z3bF85vcYPkmFCC3 gV6TV/u3rog5pD0Blw1+X5MTIhGY+eQizbLnicJhoFthSpGkdMXehJGuC3Z4aLklm5Yr R5juuZGeLuCbYwD9bZ1NKZJ1nM6hcNa1XhPtSPcW6Ry2Povx7z/dIwD9vKjdVBRl/lyF oZ3PTVYIAn8L3fONizCB4abGYb0SYLrpgnaxctqj+PAZNmaMArlkySLLHjOi36ztjSc+ 393A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QeJiaGfo; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si17093242ilv.25.2021.06.27.03.56.56; Sun, 27 Jun 2021 03:57:07 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=QeJiaGfo; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229921AbhF0K6l (ORCPT + 99 others); Sun, 27 Jun 2021 06:58:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:53664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbhF0K6j (ORCPT ); Sun, 27 Jun 2021 06:58:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A630B61C32; Sun, 27 Jun 2021 10:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624791375; bh=xs0Ga7yyhZsNXROXIVVWoDIcx1qs2TkJkZ9M6S2q3is=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QeJiaGforAIEgOuVUs2OVikq7+3xW61O85Ga3O1dPpmiRD2Zcz4M+67mPufmkraj7 H+//MUoPUWptI9mbUvsWeiSFyrpTvRGJRTEpZOB+K9FsMH8oIYNvPrSMSiHoRio961 Zp332abaAzcYgbzLcGV2RBxsqwl4KDYv7cGidx8c= Date: Sun, 27 Jun 2021 12:56:13 +0200 From: Greg KH To: Roberto Sassu Cc: zohar@linux.ibm.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH 04/12] digest_lists: Objects Message-ID: References: <20210625165614.2284243-1-roberto.sassu@huawei.com> <20210625165614.2284243-5-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210625165614.2284243-5-roberto.sassu@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 25, 2021 at 06:56:06PM +0200, Roberto Sassu wrote: > +++ b/security/integrity/digest_lists/digest_lists.h > @@ -0,0 +1,117 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (C) 2005,2006,2007,2008 IBM Corporation > + * Copyright (C) 2017-2021 Huawei Technologies Duesseldorf GmbH > + * > + * Author: Roberto Sassu > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License as > + * published by the Free Software Foundation, version 2 of the > + * License. > + * > + * File: digest_lists.h > + * Unexported definitions for digest lists. Unexported to whom? > + */ > + > +#ifndef __DIGEST_LISTS_INTERNAL_H > +#define __DIGEST_LISTS_INTERNAL_H > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MAX_DIGEST_SIZE 64 > +#define HASH_BITS 10 > +#define MEASURE_HTABLE_SIZE (1 << HASH_BITS) > + > +struct digest_list_item { > + loff_t size; > + u8 *buf; > + u8 actions; > + u8 digest[64]; > + enum hash_algo algo; > + const char *label; > +}; > + > +struct digest_list_item_ref { > + struct digest_list_item *digest_list; > + loff_t digest_offset; > + loff_t hdr_offset; > +}; > + > +struct digest_item { > + /* hash table pointers */ > + struct hlist_node hnext; > + /* digest list references (protected by RCU) */ > + struct digest_list_item_ref *refs; > +}; > + > +struct h_table { > + atomic_long_t len; Why is this atomic? Why would that matter? > + struct hlist_head queue[MEASURE_HTABLE_SIZE]; > +}; > + > +static inline unsigned int hash_key(u8 *digest) > +{ > + return (digest[0] | digest[1] << 8) % MEASURE_HTABLE_SIZE; > +} Don't we have hashing functions in the kernel already? > + > +static inline struct compact_list_hdr *get_hdr( > + struct digest_list_item *digest_list, > + loff_t hdr_offset) > +{ > + return (struct compact_list_hdr *)(digest_list->buf + hdr_offset); > +} pointer math feels rough, are you shure you want to do this this way? thanks, greg k-h