* [PATCH] TCG2 log support build fixes for non-x86_64 @ 2019-04-02 21:55 Matthew Garrett 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Matthew Garrett @ 2019-04-02 21:55 UTC (permalink / raw) To: linux-integrity Cc: peterhuewe, jarkko.sakkinen, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek Couple of patches to fix ktest reported issues with the crypto-agile log format support. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code 2019-04-02 21:55 [PATCH] TCG2 log support build fixes for non-x86_64 Matthew Garrett @ 2019-04-02 21:55 ` Matthew Garrett 2019-04-03 13:42 ` David Laight ` (2 more replies) 2019-04-02 21:55 ` [PATCH 2/2] tpm: Fix builds on platforms that lack early_memremap() Matthew Garrett ` (2 subsequent siblings) 3 siblings, 3 replies; 12+ messages in thread From: Matthew Garrett @ 2019-04-02 21:55 UTC (permalink / raw) To: linux-integrity Cc: peterhuewe, jarkko.sakkinen, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek, Matthew Garrett, Matthew Garrett 8bfcff4a6a1d9d7226bb63a7da758b82d9ab4373 introduced a cast from efi_physical_address_t to (void *), which are different sizes on 32-bit. Fix that. Caught by the 0-day test bot. Signed-off-by: Matthew Garrett <mjg59@google.com> --- drivers/firmware/efi/libstub/tpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index b6e93e14fcf1..6b3b507a54eb 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -114,8 +114,8 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) */ last_entry_size = __calc_tpm2_event_size((void *)last_entry_addr, - (void *)log_location, - false); + (void *)(long)log_location, + false); } else { last_entry_size = sizeof(struct tcpa_event) + ((struct tcpa_event *) last_entry_addr)->event_size; -- 2.21.0.392.gf8f6787159e-goog ^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett @ 2019-04-03 13:42 ` David Laight 2019-04-03 16:51 ` Matthew Garrett 2019-04-04 12:39 ` Jarkko Sakkinen 2019-04-04 12:54 ` Ard Biesheuvel 2 siblings, 1 reply; 12+ messages in thread From: David Laight @ 2019-04-03 13:42 UTC (permalink / raw) To: 'Matthew Garrett', linux-integrity Cc: peterhuewe, jarkko.sakkinen, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek, Matthew Garrett From: Matthew Garrett > Sent: 02 April 2019 22:56 > > 8bfcff4a6a1d9d7226bb63a7da758b82d9ab4373 introduced a cast from > efi_physical_address_t to (void *), which are different sizes on 32-bit. > Fix that. Caught by the 0-day test bot. Casting a physical address to 'void *' seems completely wrong. Also you'd need a guarantee that the address was below 4G or the result is meaningless. Looks to me like something is using the wrong types somewhere. David > Signed-off-by: Matthew Garrett <mjg59@google.com> > --- > drivers/firmware/efi/libstub/tpm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c > index b6e93e14fcf1..6b3b507a54eb 100644 > --- a/drivers/firmware/efi/libstub/tpm.c > +++ b/drivers/firmware/efi/libstub/tpm.c > @@ -114,8 +114,8 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) > */ > last_entry_size = > __calc_tpm2_event_size((void *)last_entry_addr, > - (void *)log_location, > - false); > + (void *)(long)log_location, > + false); > } else { > last_entry_size = sizeof(struct tcpa_event) + > ((struct tcpa_event *) last_entry_addr)->event_size; > -- > 2.21.0.392.gf8f6787159e-goog - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code 2019-04-03 13:42 ` David Laight @ 2019-04-03 16:51 ` Matthew Garrett 0 siblings, 0 replies; 12+ messages in thread From: Matthew Garrett @ 2019-04-03 16:51 UTC (permalink / raw) To: David Laight Cc: linux-integrity, peterhuewe, jarkko.sakkinen, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek On Wed, Apr 3, 2019 at 6:41 AM David Laight <David.Laight@aculab.com> wrote: > > From: Matthew Garrett > > Sent: 02 April 2019 22:56 > > > > 8bfcff4a6a1d9d7226bb63a7da758b82d9ab4373 introduced a cast from > > efi_physical_address_t to (void *), which are different sizes on 32-bit. > > Fix that. Caught by the 0-day test bot. > > Casting a physical address to 'void *' seems completely wrong. > Also you'd need a guarantee that the address was below 4G or the result > is meaningless. > Looks to me like something is using the wrong types somewhere. We're in UEFI here, not the kernel proper - the firmware functions we call give us back physical addresses, and we're operating with a 1:1 mapping. long is 64 bit on 64 bit systems, and on 32 bit systems we've already asserted that all firmware resources are under 4GB (obviously we're going to have a bad time if they're not, but there's not really anything we can do about that) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett 2019-04-03 13:42 ` David Laight @ 2019-04-04 12:39 ` Jarkko Sakkinen 2019-04-04 12:54 ` Ard Biesheuvel 2 siblings, 0 replies; 12+ messages in thread From: Jarkko Sakkinen @ 2019-04-04 12:39 UTC (permalink / raw) To: Matthew Garrett Cc: linux-integrity, peterhuewe, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek, Matthew Garrett On Tue, Apr 02, 2019 at 02:55:55PM -0700, Matthew Garrett wrote: > 8bfcff4a6a1d9d7226bb63a7da758b82d9ab4373 introduced a cast from > efi_physical_address_t to (void *), which are different sizes on 32-bit. > Fix that. Caught by the 0-day test bot. > > Signed-off-by: Matthew Garrett <mjg59@google.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> /Jarkko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett 2019-04-03 13:42 ` David Laight 2019-04-04 12:39 ` Jarkko Sakkinen @ 2019-04-04 12:54 ` Ard Biesheuvel 2019-04-04 17:23 ` Matthew Garrett 2 siblings, 1 reply; 12+ messages in thread From: Ard Biesheuvel @ 2019-04-04 12:54 UTC (permalink / raw) To: Matthew Garrett Cc: linux-integrity, Peter Hüwe, Jarkko Sakkinen, jgg, Roberto Sassu, linux-efi, linux-security-module, Linux Kernel Mailing List, Thiebaud Weksteen, Matthew Garrett On Wed, 3 Apr 2019 at 04:56, Matthew Garrett <matthewgarrett@google.com> wrote: > > 8bfcff4a6a1d9d7226bb63a7da758b82d9ab4373 Which tree is this commit in? > introduced a cast from > efi_physical_address_t to (void *), which are different sizes on 32-bit. > Fix that. Caught by the 0-day test bot. > > Signed-off-by: Matthew Garrett <mjg59@google.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> I'll pick this up as a fix if we can clean up the commit log so it doesn't refer to a commit that does not exist in mainline. > --- > drivers/firmware/efi/libstub/tpm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c > index b6e93e14fcf1..6b3b507a54eb 100644 > --- a/drivers/firmware/efi/libstub/tpm.c > +++ b/drivers/firmware/efi/libstub/tpm.c > @@ -114,8 +114,8 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) > */ > last_entry_size = > __calc_tpm2_event_size((void *)last_entry_addr, > - (void *)log_location, > - false); > + (void *)(long)log_location, > + false); > } else { > last_entry_size = sizeof(struct tcpa_event) + > ((struct tcpa_event *) last_entry_addr)->event_size; > -- > 2.21.0.392.gf8f6787159e-goog > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code 2019-04-04 12:54 ` Ard Biesheuvel @ 2019-04-04 17:23 ` Matthew Garrett 0 siblings, 0 replies; 12+ messages in thread From: Matthew Garrett @ 2019-04-04 17:23 UTC (permalink / raw) To: Ard Biesheuvel Cc: linux-integrity, Peter Hüwe, Jarkko Sakkinen, Jason Gunthorpe, Roberto Sassu, linux-efi, linux-security-module, Linux Kernel Mailing List, Thiebaud Weksteen On Thu, Apr 4, 2019 at 5:54 AM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote: > > On Wed, 3 Apr 2019 at 04:56, Matthew Garrett <matthewgarrett@google.com> wrote: > > > > 8bfcff4a6a1d9d7226bb63a7da758b82d9ab4373 > > Which tree is this commit in? Sorry, these are in the tpmdd-next tree. ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/2] tpm: Fix builds on platforms that lack early_memremap() 2019-04-02 21:55 [PATCH] TCG2 log support build fixes for non-x86_64 Matthew Garrett 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett @ 2019-04-02 21:55 ` Matthew Garrett 2019-04-04 12:40 ` Jarkko Sakkinen 2019-04-04 12:40 ` [PATCH] TCG2 log support build fixes for non-x86_64 Jarkko Sakkinen 2019-04-15 8:47 ` Jarkko Sakkinen 3 siblings, 1 reply; 12+ messages in thread From: Matthew Garrett @ 2019-04-02 21:55 UTC (permalink / raw) To: linux-integrity Cc: peterhuewe, jarkko.sakkinen, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek, Matthew Garrett, Matthew Garrett On EFI systems, __calc_tpm2_event_size() needs to be able to map tables at early boot time in order to extract information from them. Unfortunately this interacts badly with other architectures that don't provide the early_memremap() interface but which may still have other mechanisms for obtaining crypto-agile logs. Abstract this away so we can avoid the need for two implementations while still avoiding breakage on architectures that don't require remapping of the table. Signed-off-by: Matthew Garrett <mjg59@google.com> --- drivers/firmware/efi/tpm.c | 3 +++ include/linux/tpm_eventlog.h | 32 ++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c index f2a13cbb8688..fe48150f06d1 100644 --- a/drivers/firmware/efi/tpm.c +++ b/drivers/firmware/efi/tpm.c @@ -4,6 +4,9 @@ * Thiebaud Weksteen <tweek@google.com> */ +#define TPM_MEMREMAP(start, size) early_memremap(start, size) +#define TPM_MEMUNMAP(start, size) early_memunmap(start, size) + #include <linux/efi.h> #include <linux/init.h> #include <linux/memblock.h> diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h index d889e12047d9..0ca27bc053af 100644 --- a/include/linux/tpm_eventlog.h +++ b/include/linux/tpm_eventlog.h @@ -128,6 +128,14 @@ struct tcg_algorithm_info { struct tcg_algorithm_size digest_sizes[]; }; +#ifndef TPM_MEMREMAP +#define TPM_MEMREMAP(start, size) NULL +#endif + +#ifndef TPM_MEMUNMAP +#define TPM_MEMUNMAP(start, size) do{} while(0) +#endif + /** * __calc_tpm2_event_size - calculate the size of a TPM2 event log entry * @event: Pointer to the event whose size should be calculated @@ -171,8 +179,8 @@ static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event, /* Map the event header */ if (do_mapping) { mapping_size = marker - marker_start; - mapping = early_memremap((unsigned long)marker_start, - mapping_size); + mapping = TPM_MEMREMAP((unsigned long)marker_start, + mapping_size); if (!mapping) { size = 0; goto out; @@ -192,10 +200,10 @@ static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event, /* Map the digest's algorithm identifier */ if (do_mapping) { - early_memunmap(mapping, mapping_size); + TPM_MEMUNMAP(mapping, mapping_size); mapping_size = marker - marker_start + halg_size; - mapping = early_memremap((unsigned long)marker_start, - mapping_size); + mapping = TPM_MEMREMAP((unsigned long)marker_start, + mapping_size); if (!mapping) { size = 0; goto out; @@ -212,10 +220,10 @@ static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event, /* Map the digest content itself */ if (do_mapping) { - early_memunmap(mapping, mapping_size); + TPM_MEMUNMAP(mapping, mapping_size); mapping_size = marker - marker_start; - mapping = early_memremap((unsigned long)marker_start, - mapping_size); + mapping = TPM_MEMREMAP((unsigned long)marker_start, + mapping_size); if (!mapping) { size = 0; goto out; @@ -238,10 +246,10 @@ static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event, * we don't need to map it */ if (do_mapping) { - early_memunmap(marker_start, mapping_size); + TPM_MEMUNMAP(marker_start, mapping_size); mapping_size += sizeof(event_field->event_size); - mapping = early_memremap((unsigned long)marker_start, - mapping_size); + mapping = TPM_MEMREMAP((unsigned long)marker_start, + mapping_size); if (!mapping) { size = 0; goto out; @@ -256,7 +264,7 @@ static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event, size = 0; out: if (do_mapping) - early_memunmap(mapping, mapping_size); + TPM_MEMUNMAP(mapping, mapping_size); return size; } -- 2.21.0.392.gf8f6787159e-goog ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] tpm: Fix builds on platforms that lack early_memremap() 2019-04-02 21:55 ` [PATCH 2/2] tpm: Fix builds on platforms that lack early_memremap() Matthew Garrett @ 2019-04-04 12:40 ` Jarkko Sakkinen 0 siblings, 0 replies; 12+ messages in thread From: Jarkko Sakkinen @ 2019-04-04 12:40 UTC (permalink / raw) To: Matthew Garrett Cc: linux-integrity, peterhuewe, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek, Matthew Garrett On Tue, Apr 02, 2019 at 02:55:56PM -0700, Matthew Garrett wrote: > On EFI systems, __calc_tpm2_event_size() needs to be able to map tables > at early boot time in order to extract information from them. > Unfortunately this interacts badly with other architectures that don't > provide the early_memremap() interface but which may still have other > mechanisms for obtaining crypto-agile logs. Abstract this away so we > can avoid the need for two implementations while still avoiding breakage > on architectures that don't require remapping of the table. > > Signed-off-by: Matthew Garrett <mjg59@google.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> /Jarkko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] TCG2 log support build fixes for non-x86_64 2019-04-02 21:55 [PATCH] TCG2 log support build fixes for non-x86_64 Matthew Garrett 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett 2019-04-02 21:55 ` [PATCH 2/2] tpm: Fix builds on platforms that lack early_memremap() Matthew Garrett @ 2019-04-04 12:40 ` Jarkko Sakkinen 2019-04-04 17:24 ` Matthew Garrett 2019-04-15 8:47 ` Jarkko Sakkinen 3 siblings, 1 reply; 12+ messages in thread From: Jarkko Sakkinen @ 2019-04-04 12:40 UTC (permalink / raw) To: Matthew Garrett Cc: linux-integrity, peterhuewe, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek On Tue, Apr 02, 2019 at 02:55:54PM -0700, Matthew Garrett wrote: > Couple of patches to fix ktest reported issues with the crypto-agile log > format support. I guess I squash these to your earlier commits? /Jarkko ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] TCG2 log support build fixes for non-x86_64 2019-04-04 12:40 ` [PATCH] TCG2 log support build fixes for non-x86_64 Jarkko Sakkinen @ 2019-04-04 17:24 ` Matthew Garrett 0 siblings, 0 replies; 12+ messages in thread From: Matthew Garrett @ 2019-04-04 17:24 UTC (permalink / raw) To: Jarkko Sakkinen Cc: linux-integrity, Peter Huewe, Jason Gunthorpe, Roberto Sassu, linux-efi, LSM List, Linux Kernel Mailing List, Thiébaud Weksteen On Thu, Apr 4, 2019 at 5:41 AM Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> wrote: > > On Tue, Apr 02, 2019 at 02:55:54PM -0700, Matthew Garrett wrote: > > Couple of patches to fix ktest reported issues with the crypto-agile log > > format support. > > I guess I squash these to your earlier commits? Works for me. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] TCG2 log support build fixes for non-x86_64 2019-04-02 21:55 [PATCH] TCG2 log support build fixes for non-x86_64 Matthew Garrett ` (2 preceding siblings ...) 2019-04-04 12:40 ` [PATCH] TCG2 log support build fixes for non-x86_64 Jarkko Sakkinen @ 2019-04-15 8:47 ` Jarkko Sakkinen 3 siblings, 0 replies; 12+ messages in thread From: Jarkko Sakkinen @ 2019-04-15 8:47 UTC (permalink / raw) To: Matthew Garrett Cc: linux-integrity, peterhuewe, jgg, roberto.sassu, linux-efi, linux-security-module, linux-kernel, tweek On Tue, Apr 02, 2019 at 02:55:54PM -0700, Matthew Garrett wrote: > Couple of patches to fix ktest reported issues with the crypto-agile log > format support. Applied and squashed. Should be soon in linux-next. /Jarkko ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-04-15 8:47 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-04-02 21:55 [PATCH] TCG2 log support build fixes for non-x86_64 Matthew Garrett 2019-04-02 21:55 ` [PATCH 1/2] efi: Fix cast to pointer from integer of different size in TPM log code Matthew Garrett 2019-04-03 13:42 ` David Laight 2019-04-03 16:51 ` Matthew Garrett 2019-04-04 12:39 ` Jarkko Sakkinen 2019-04-04 12:54 ` Ard Biesheuvel 2019-04-04 17:23 ` Matthew Garrett 2019-04-02 21:55 ` [PATCH 2/2] tpm: Fix builds on platforms that lack early_memremap() Matthew Garrett 2019-04-04 12:40 ` Jarkko Sakkinen 2019-04-04 12:40 ` [PATCH] TCG2 log support build fixes for non-x86_64 Jarkko Sakkinen 2019-04-04 17:24 ` Matthew Garrett 2019-04-15 8:47 ` Jarkko Sakkinen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).