public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] s390/ipl: fix virtual vs physical address confusion
@ 2023-08-16 13:29 Alexander Gordeev
  2023-08-16 15:44 ` Heiko Carstens
  2023-08-16 16:13 ` Mimi Zohar
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Gordeev @ 2023-08-16 13:29 UTC (permalink / raw)
  To: Mimi Zohar, Jarkko Sakkinen, Vasily Gorbik, Heiko Carstens
  Cc: linux-kernel, linux-s390, linux-integrity

The value of ipl_cert_list_addr boot variable contains
a physical address, which is used directly. That works
because virtual and physical address spaces are currently
the same, but otherwise it is wrong.

While at it, fix also a comment for the platform keyring.

Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
---
 arch/s390/kernel/machine_kexec_file.c             | 4 ++--
 arch/s390/kernel/setup.c                          | 2 +-
 security/integrity/platform_certs/load_ipl_s390.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c
index 2df94d32140c..8d207b82d9fe 100644
--- a/arch/s390/kernel/machine_kexec_file.c
+++ b/arch/s390/kernel/machine_kexec_file.c
@@ -188,7 +188,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
 	data->memsz = ALIGN(data->memsz, PAGE_SIZE);
 	buf.mem = data->memsz;
 
-	ptr = (void *)ipl_cert_list_addr;
+	ptr = __va(ipl_cert_list_addr);
 	end = ptr + ipl_cert_list_size;
 	ncerts = 0;
 	while (ptr < end) {
@@ -200,7 +200,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
 
 	addr = data->memsz + data->report->size;
 	addr += ncerts * sizeof(struct ipl_rb_certificate_entry);
-	ptr = (void *)ipl_cert_list_addr;
+	ptr = __va(ipl_cert_list_addr);
 	while (ptr < end) {
 		len = *(unsigned int *)ptr;
 		ptr += sizeof(len);
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 393dd8385506..c744104e4a9c 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -875,7 +875,7 @@ static void __init log_component_list(void)
 		pr_info("Linux is running with Secure-IPL enabled\n");
 	else
 		pr_info("Linux is running with Secure-IPL disabled\n");
-	ptr = (void *) early_ipl_comp_list_addr;
+	ptr = __va(early_ipl_comp_list_addr);
 	end = (void *) ptr + early_ipl_comp_list_size;
 	pr_info("The IPL report contains the following components:\n");
 	while (ptr < end) {
diff --git a/security/integrity/platform_certs/load_ipl_s390.c b/security/integrity/platform_certs/load_ipl_s390.c
index e769dcb7ea94..c7c381a9ddaa 100644
--- a/security/integrity/platform_certs/load_ipl_s390.c
+++ b/security/integrity/platform_certs/load_ipl_s390.c
@@ -22,8 +22,8 @@ static int __init load_ipl_certs(void)
 
 	if (!ipl_cert_list_addr)
 		return 0;
-	/* Copy the certificates to the system keyring */
-	ptr = (void *) ipl_cert_list_addr;
+	/* Copy the certificates to the platform keyring */
+	ptr = __va(ipl_cert_list_addr);
 	end = ptr + ipl_cert_list_size;
 	while ((void *) ptr < end) {
 		len = *(unsigned int *) ptr;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] s390/ipl: fix virtual vs physical address confusion
  2023-08-16 13:29 [PATCH v2] s390/ipl: fix virtual vs physical address confusion Alexander Gordeev
@ 2023-08-16 15:44 ` Heiko Carstens
  2023-08-16 17:34   ` Mimi Zohar
  2023-08-16 19:32   ` Jarkko Sakkinen
  2023-08-16 16:13 ` Mimi Zohar
  1 sibling, 2 replies; 6+ messages in thread
From: Heiko Carstens @ 2023-08-16 15:44 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: Mimi Zohar, Jarkko Sakkinen, Vasily Gorbik, linux-kernel,
	linux-s390, linux-integrity

On Wed, Aug 16, 2023 at 03:29:42PM +0200, Alexander Gordeev wrote:
> The value of ipl_cert_list_addr boot variable contains
> a physical address, which is used directly. That works
> because virtual and physical address spaces are currently
> the same, but otherwise it is wrong.
> 
> While at it, fix also a comment for the platform keyring.
> 
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
>  arch/s390/kernel/machine_kexec_file.c             | 4 ++--
>  arch/s390/kernel/setup.c                          | 2 +-
>  security/integrity/platform_certs/load_ipl_s390.c | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)

Mimi, Jarkko, any objections from your side?
I would take this via the s390 tree.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] s390/ipl: fix virtual vs physical address confusion
  2023-08-16 13:29 [PATCH v2] s390/ipl: fix virtual vs physical address confusion Alexander Gordeev
  2023-08-16 15:44 ` Heiko Carstens
@ 2023-08-16 16:13 ` Mimi Zohar
  2023-08-16 17:07   ` Alexander Gordeev
  1 sibling, 1 reply; 6+ messages in thread
From: Mimi Zohar @ 2023-08-16 16:13 UTC (permalink / raw)
  To: Alexander Gordeev, Jarkko Sakkinen, Vasily Gorbik, Heiko Carstens
  Cc: linux-kernel, linux-s390, linux-integrity

On Wed, 2023-08-16 at 15:29 +0200, Alexander Gordeev wrote:
> The value of ipl_cert_list_addr boot variable contains
> a physical address, which is used directly. That works
> because virtual and physical address spaces are currently
> the same, but otherwise it is wrong.
> 
> While at it, fix also a comment for the platform keyring.
> 
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
>  arch/s390/kernel/machine_kexec_file.c             | 4 ++--
>  arch/s390/kernel/setup.c                          | 2 +-
>  security/integrity/platform_certs/load_ipl_s390.c | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c
> index 2df94d32140c..8d207b82d9fe 100644
> --- a/arch/s390/kernel/machine_kexec_file.c
> +++ b/arch/s390/kernel/machine_kexec_file.c
> @@ -188,7 +188,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
>  	data->memsz = ALIGN(data->memsz, PAGE_SIZE);
>  	buf.mem = data->memsz;
>  
> -	ptr = (void *)ipl_cert_list_addr;
> +	ptr = __va(ipl_cert_list_addr);
>  	end = ptr + ipl_cert_list_size;
>  	ncerts = 0;
>  	while (ptr < end) {
> @@ -200,7 +200,7 @@ static int kexec_file_add_ipl_report(struct kimage *image,
>  
>  	addr = data->memsz + data->report->size;
>  	addr += ncerts * sizeof(struct ipl_rb_certificate_entry);
> -	ptr = (void *)ipl_cert_list_addr;
> +	ptr = __va(ipl_cert_list_addr);
>  	while (ptr < end) {
>  		len = *(unsigned int *)ptr;
>  		ptr += sizeof(len);
> diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
> index 393dd8385506..c744104e4a9c 100644
> --- a/arch/s390/kernel/setup.c
> +++ b/arch/s390/kernel/setup.c
> @@ -875,7 +875,7 @@ static void __init log_component_list(void)
>  		pr_info("Linux is running with Secure-IPL enabled\n");
>  	else
>  		pr_info("Linux is running with Secure-IPL disabled\n");
> -	ptr = (void *) early_ipl_comp_list_addr;
> +	ptr = __va(early_ipl_comp_list_addr);
>  	end = (void *) ptr + early_ipl_comp_list_size;
>  	pr_info("The IPL report contains the following components:\n");
>  	while (ptr < end) {
> diff --git a/security/integrity/platform_certs/load_ipl_s390.c b/security/integrity/platform_certs/load_ipl_s390.c
> index e769dcb7ea94..c7c381a9ddaa 100644
> --- a/security/integrity/platform_certs/load_ipl_s390.c
> +++ b/security/integrity/platform_certs/load_ipl_s390.c
> @@ -22,8 +22,8 @@ static int __init load_ipl_certs(void)
>  
>  	if (!ipl_cert_list_addr)
>  		return 0;
> -	/* Copy the certificates to the system keyring */
> -	ptr = (void *) ipl_cert_list_addr;
> +	/* Copy the certificates to the platform keyring */
> +	ptr = __va(ipl_cert_list_addr);
>  	end = ptr + ipl_cert_list_size;
>  	while ((void *) ptr < end) {
>  		len = *(unsigned int *) ptr;

ipl_cert_list_addr is defined as an unsigned long.  At this point, the
changes are simple cleanup of removing "(void *)" and replacing it with
__va().

From arch/s390/include/asm/page.h:
#define __pa(x)                 ((unsigned long)(x))
#define __va(x)                 ((void *)(unsigned long)(x))

So, Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>

I'm trying to understand if there is a difference between the other
archs and s390; and whether a similar change is needed for the other
archs.  Loading certificates on the other archs call kmalloc to
allocate memory for the certs. Is the memory being allocated on x390
using kmalloc?

-- 
thanks,

Mimi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] s390/ipl: fix virtual vs physical address confusion
  2023-08-16 16:13 ` Mimi Zohar
@ 2023-08-16 17:07   ` Alexander Gordeev
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Gordeev @ 2023-08-16 17:07 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Jarkko Sakkinen, Vasily Gorbik, Heiko Carstens, linux-kernel,
	linux-s390, linux-integrity

On Wed, Aug 16, 2023 at 12:13:24PM -0400, Mimi Zohar wrote:
...
> I'm trying to understand if there is a difference between the other
> archs and s390; and whether a similar change is needed for the other
> archs.  Loading certificates on the other archs call kmalloc to
> allocate memory for the certs. Is the memory being allocated on x390
> using kmalloc?

No. The memory is allocated in the decompressor and passed to
the uncompressed kernel. I do not think anything needs to be
done for other archs.

> -- 
> thanks,
> 
> Mimi

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] s390/ipl: fix virtual vs physical address confusion
  2023-08-16 15:44 ` Heiko Carstens
@ 2023-08-16 17:34   ` Mimi Zohar
  2023-08-16 19:32   ` Jarkko Sakkinen
  1 sibling, 0 replies; 6+ messages in thread
From: Mimi Zohar @ 2023-08-16 17:34 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev
  Cc: Jarkko Sakkinen, Vasily Gorbik, linux-kernel, linux-s390,
	linux-integrity

On Wed, 2023-08-16 at 17:44 +0200, Heiko Carstens wrote:
> On Wed, Aug 16, 2023 at 03:29:42PM +0200, Alexander Gordeev wrote:
> > The value of ipl_cert_list_addr boot variable contains
> > a physical address, which is used directly. That works
> > because virtual and physical address spaces are currently
> > the same, but otherwise it is wrong.
> > 
> > While at it, fix also a comment for the platform keyring.
> > 
> > Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> > ---
> >  arch/s390/kernel/machine_kexec_file.c             | 4 ++--
> >  arch/s390/kernel/setup.c                          | 2 +-
> >  security/integrity/platform_certs/load_ipl_s390.c | 4 ++--
> >  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> Mimi, Jarkko, any objections from your side?
> I would take this via the s390 tree.

No objections from my side.

-- 
thanks,

Mimi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] s390/ipl: fix virtual vs physical address confusion
  2023-08-16 15:44 ` Heiko Carstens
  2023-08-16 17:34   ` Mimi Zohar
@ 2023-08-16 19:32   ` Jarkko Sakkinen
  1 sibling, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2023-08-16 19:32 UTC (permalink / raw)
  To: Heiko Carstens, Alexander Gordeev
  Cc: Mimi Zohar, Vasily Gorbik, linux-kernel, linux-s390,
	linux-integrity

On Wed Aug 16, 2023 at 6:44 PM EEST, Heiko Carstens wrote:
> On Wed, Aug 16, 2023 at 03:29:42PM +0200, Alexander Gordeev wrote:
> > The value of ipl_cert_list_addr boot variable contains
> > a physical address, which is used directly. That works
> > because virtual and physical address spaces are currently
> > the same, but otherwise it is wrong.
> > 
> > While at it, fix also a comment for the platform keyring.
> > 
> > Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> > ---
> >  arch/s390/kernel/machine_kexec_file.c             | 4 ++--
> >  arch/s390/kernel/setup.c                          | 2 +-
> >  security/integrity/platform_certs/load_ipl_s390.c | 4 ++--
> >  3 files changed, 5 insertions(+), 5 deletions(-)
>
> Mimi, Jarkko, any objections from your side?
> I would take this via the s390 tree.

No objections.

Acked-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-16 19:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 13:29 [PATCH v2] s390/ipl: fix virtual vs physical address confusion Alexander Gordeev
2023-08-16 15:44 ` Heiko Carstens
2023-08-16 17:34   ` Mimi Zohar
2023-08-16 19:32   ` Jarkko Sakkinen
2023-08-16 16:13 ` Mimi Zohar
2023-08-16 17:07   ` Alexander Gordeev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox