Re: [PATCH v2 1/3] ima-evm-utils: Allow manual setting keyid for signing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dmitry,

On Wed, May 05, 2021 at 02:43:18AM +0300, Dmitry V. Levin wrote:
> On Wed, May 05, 2021 at 02:18:04AM +0300, Vitaly Chikunov wrote:
> > Stefan,
> > 
> > On Tue, May 04, 2021 at 08:51:03AM -0400, Stefan Berger wrote:
> > > > @@ -932,8 +932,10 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash,
> > > >   		return -1;
> > > >   	}
> > > > -	calc_keyid_v2(&keyid, name, pkey);
> > > > -	hdr->keyid = keyid;
> > > > +	if (imaevm_params.keyid)
> > > > +		hdr->keyid = htonl(imaevm_params.keyid);
> > > 
> > > 
> > > Nit: Since existing code uses __be32_to_cpup I would use __cpu_to_be32 here.
> > 
> > That __be32_to_cpup usage is highly dubious. Perhaps, it should be
> > converted to some user-space and standard functions like be32toh(3).
> 
> By the way, be32toh() is identical to ntohl().
> 
> I wonder what was the reason for the existing code to use these obscure
> linux-specific functions instead of posix interface described in
> byteorder(3)?

Perhaps, it's to simplify work with unaligned data, since __be32_to_cpup
accepts the pointer (without assumption of alignment), where you cannot
just call ntohl(*ptr) without possible sigbus on some platforms.

linux/byteorder/generic.h:

 * The "... p" macros, like le64_to_cpup, can be used with pointers
 * to unaligned data, but there will be a performance penalty on
 * some architectures.  Use get_unaligned for unaligned data.

Thanks,

> 
> 
> -- 
> ldv



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux