Re: [PATCH bpf-next 2/3] bpf: Add a BPF helper for getting the IMA hash of an inode

From: KP Singh
Date: Fri Nov 20 2020 - 19:14:45 EST


[...]

> > + * long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size)
> > + * Description
> > + * Returns the stored IMA hash of the *inode* (if it's avaialable).
> > + * If the hash is larger than *size*, then only *size*
> > + * bytes will be copied to *dst*
> > + * Return > + * The **hash_algo** of is returned on success,
>
> of => if?

Just changed it to:

"The **hash_algo** is returned on success"

>
> > + * **-EOPNOTSUP** if IMA is disabled and **-EINVAL** if
>
> and => or

Done. (and the same for tools/)

>

[...]

> > + .gpl_only = false,
> > + .ret_type = RET_INTEGER,
> > + .arg1_type = ARG_PTR_TO_BTF_ID,
> > + .arg1_btf_id = &bpf_ima_inode_hash_btf_ids[0],
> > + .arg2_type = ARG_PTR_TO_UNINIT_MEM,
> > + .arg3_type = ARG_CONST_SIZE_OR_ZERO,
>
> I know ARG_CONST_SIZE_OR_ZERO provides some flexibility and may
> make verifier easier to verify programs. But beyond that did
> you see any real use case user will pass a zero size buf to
> get hash value?
>

I agree, in this case it makes more sense to ARG_CONST_SIZE.

> > + .allowed = bpf_ima_inode_hash_allowed,
> > +};

[...]