Re: [RFC][PATCH 04/12] digest_lists: Objects

From: Greg KH
Date: Mon Jun 28 2021 - 04:47:19 EST


On Mon, Jun 28, 2021 at 08:14:41AM +0000, Roberto Sassu wrote:
> > From: Greg KH [mailto:gregkh@xxxxxxxxxxxxxxxxxxx]
> > Sent: Sunday, June 27, 2021 12:56 PM
> > 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 <roberto.sassu@xxxxxxxxxx>
> > > + *
> > > + * 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?
>
> Hi Greg
>
> I meant not placed in include/linux.

That's obvious based on the location of the file :)

> > > +
> > > +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?
>
> Maybe, I could change digest_list_item_ref to:
>
> struct digest_list_item_ref {
> struct digest_list_item *digest_list;
> u8 *digest;
> struct compact_list_hdr *hdr;
> };
>
> where digest and hdr are calculated in the same way.

That works better, no need to do pointer math if you do not have to.

thanks,

greg k-h