Skip to contentSkip to conversation

KVM: remove printing of token address

PATCH In review Tobin C. Harding 2 participants 7 messages Oct 9, 2017 – Oct 10, 2017 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: remove printing of token address

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Remove the consumer token address from error message output.

---
 virt/kvm/eventfd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
virt/kvm/eventfd.c +1 -2
index f2ac53ab8243..b54503ed60bd 100644
@@ -416,8 +416,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 		irqfd->consumer.start = kvm_arch_irq_bypass_start;
 		ret = irq_bypass_register_consumer(&irqfd->consumer);
 		if (ret)
-			pr_info("irq bypass consumer (token %p) registration fails: %d\n",
-				irqfd->consumer.token, ret);
+			pr_info("irq bypass consumer registration fails: %d\n", ret);
 	}
 #endif
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

----- Original Message -----

Quoted 11 lines

From: "Tobin C. Harding" <[email protected]>
To: "Paolo Bonzini" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "Tobin C. Harding" <[email protected]>
Sent: Monday, October 9, 2017 8:30:14 AM
Subject: [PATCH] KVM: remove printing of token address

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Remove the consumer token address from error message output.

It should use %pK instead. Also, please do the same change on the VFIO side (drivers/vfio/pci/vfio_pci_intrs.c, call to irq_bypass_register_producer).

Thanks,

Paolo

Quoted 24 lines
---
 virt/kvm/eventfd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
virt/kvm/eventfd.c +1 -3
index f2ac53ab8243..b54503ed60bd 100644
@@ -416,8 +416,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
 		irqfd->consumer.start = kvm_arch_irq_bypass_start;
 		ret = irq_bypass_register_consumer(&irqfd->consumer);
 		if (ret)
-			pr_info("irq bypass consumer (token %p) registration fails: %d\n",
-				irqfd->consumer.token, ret);
+			pr_info("irq bypass consumer registration fails: %d\n", ret);
 	}
 #endif
 
--

2.7.4

#2 lore raw
Quoted 9 lines · Paolo Bonzini

----- Original Message -----

Quoted 6 lines

From: "Tobin C. Harding" <[email protected]>
To: "Paolo Bonzini" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "Tobin C. Harding" <[email protected]>
Sent: Monday, October 9, 2017 8:30:14 AM
Subject: [PATCH] KVM: remove printing of token address

Quoted 7 lines
Quoted 5 lines

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Remove the consumer token address from error message output.

It should use %pK instead.

Is there any other way we can identify a token? There is some push back against kpt_restrict (as used by %pK) at the moment. If there is another sane way to do it perhaps we could consider that, else I'll use %pK for v2.

Quoted 2 lines

Also, please do the same change on the VFIO
side (drivers/vfio/pci/vfio_pci_intrs.c, call to irq_bypass_register_producer).

Oh, cool. I was wondering where the other side was. Will send v2

thanks,
Tobin.

maintainer
#3 lore raw
Quoted 14 lines · Tobin C. Harding
Quoted 13 lines · Paolo Bonzini

----- Original Message -----

Quoted 10 lines

From: "Tobin C. Harding" <[email protected]>
To: "Paolo Bonzini" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "Tobin C. Harding" <[email protected]>
Sent: Monday, October 9, 2017 8:30:14 AM
Subject: [PATCH] KVM: remove printing of token address

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Remove the consumer token address from error message output.

It should use %pK instead.

Is there any other way we can identify a token? There is some push back against kpt_restrict (as used by %pK) at the moment. If there is another sane way to do it perhaps we could consider that, else I'll use %pK for v2.

Not really, we know it is an eventfd but you can't go from the struct eventfd_ctx* (the token) to the corresponding struct file.

I'm not sure about the pushback... I've read your name in
https://lwn.net/Articles/735589/ :) and that article says "the same effect as a restrictive kptr_restrict setting could be achieved by searching for (and fixing) every use of unadorned "%p" directives in the kernel". As I understand it, the push back is against restrictive kptr_restrict settings, not against using "%pK" _to avoid the need_ for such a restrictive setting.

Thanks,

Paolo

Quoted 8 lines
Quoted 2 lines

Also, please do the same change on the VFIO
side (drivers/vfio/pci/vfio_pci_intrs.c, call to irq_bypass_register_producer).

Oh, cool. I was wondering where the other side was. Will send v2

thanks,
Tobin.

#4 lore raw
Quoted 26 lines · Paolo Bonzini
Quoted 14 lines · Tobin C. Harding
Quoted 13 lines · Paolo Bonzini

----- Original Message -----

Quoted 10 lines

From: "Tobin C. Harding" <[email protected]>
To: "Paolo Bonzini" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "Tobin C. Harding" <[email protected]>
Sent: Monday, October 9, 2017 8:30:14 AM
Subject: [PATCH] KVM: remove printing of token address

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Remove the consumer token address from error message output.

It should use %pK instead.

Is there any other way we can identify a token? There is some push back against kpt_restrict (as used by %pK) at the moment. If there is another sane way to do it perhaps we could consider that, else I'll use %pK for v2.

Not really, we know it is an eventfd but you can't go from the struct eventfd_ctx* (the token) to the corresponding struct file.

Quoted 7 lines

I'm not sure about the pushback... I've read your name in
https://lwn.net/Articles/735589/ :) and that article says "the same effect as a restrictive kptr_restrict setting could be achieved by searching for (and fixing) every use of unadorned "%p" directives in the kernel". As I understand it, the push back is against restrictive kptr_restrict settings, not against using "%pK" _to avoid the need_ for such a restrictive setting.

In the thread that article is based on Linus airs his view that kptr_restrict is fundamentally broken.

Would you be happy if instead of printing the pointer we printed a unique identifier (some suitable hash of the pointer value)? I'm working on that patch ATM, if this sounds ok I'll leave this patch until unique identifiers are implemented.

But if we really want the address here I can put in the patch using %pK. What is your thoughts?

Quoted 6 lines

Thanks,

Paolo

Quoted 2 lines
Quoted 2 lines

Also, please do the same change on the VFIO
side (drivers/vfio/pci/vfio_pci_intrs.c, call to irq_bypass_register_producer).

And same here obviously.

thanks,
Tobin.

maintainer
#5 lore raw
Quoted 35 lines · Tobin C. Harding
Quoted 26 lines · Paolo Bonzini
Quoted 14 lines · Tobin C. Harding
Quoted 13 lines · Paolo Bonzini

----- Original Message -----

Quoted 10 lines

From: "Tobin C. Harding" <[email protected]>
To: "Paolo Bonzini" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "Tobin C. Harding" <[email protected]>
Sent: Monday, October 9, 2017 8:30:14 AM
Subject: [PATCH] KVM: remove printing of token address

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Remove the consumer token address from error message output.

It should use %pK instead.

Is there any other way we can identify a token? There is some push back against kpt_restrict (as used by %pK) at the moment. If there is another sane way to do it perhaps we could consider that, else I'll use %pK for v2.

Not really, we know it is an eventfd but you can't go from the struct eventfd_ctx* (the token) to the corresponding struct file.

Quoted 7 lines

I'm not sure about the pushback... I've read your name in
https://lwn.net/Articles/735589/ :) and that article says "the same effect as a restrictive kptr_restrict setting could be achieved by searching for (and fixing) every use of unadorned "%p" directives in the kernel". As I understand it, the push back is against restrictive kptr_restrict settings, not against using "%pK" _to avoid the need_ for such a restrictive setting.

Quoted 2 lines

In the thread that article is based on Linus airs his view that kptr_restrict is fundamentally broken.

And I agree with him that more restrictive kptr_restrict settings are kind of broken, because either no one would use them, or if you made them the default people would start using "%x". Further there is the issue that people are _already_ using "%x" already instead of e.g. "%pa". So yeah, kptr_restrict does look a bit like security theater.

However, issues with kptr_restrict do not necessarily extend to "%pK" or "%pa". The problem is that there are too many instances of "%p", and I'm happy that you want to fix them. Since we _do_ have kptr_restrict, I don't see anything wrong with converting them to "%pK".

And if everybody started using "%pK" and "%pa" appropriately, then 1) you wouldn't need restrictive kptr_restrict settings anymore; 2) kptr_restrict would actually prevent address leaks.

Quoted 2 lines

Would you be happy if instead of printing the pointer we printed a unique identifier (some suitable hash of the pointer value)?

As long as the "suitable hash" is computed inside printk, I don't care. If the suitable hash would be in KVM or VFIO code, then please no. :)

Paolo

Quoted 17 lines

I'm working on that patch ATM, if this sounds ok I'll leave this patch until unique identifiers are implemented.

But if we really want the address here I can put in the patch using %pK. What is your thoughts?

Quoted 6 lines

Thanks,

Paolo

Quoted 2 lines
Quoted 2 lines

Also, please do the same change on the VFIO
side (drivers/vfio/pci/vfio_pci_intrs.c, call to irq_bypass_register_producer).

And same here obviously.

thanks,
Tobin.

#6 lore raw
Quoted 54 lines · Paolo Bonzini
Quoted 35 lines · Tobin C. Harding
Quoted 26 lines · Paolo Bonzini
Quoted 14 lines · Tobin C. Harding
Quoted 13 lines · Paolo Bonzini

----- Original Message -----

Quoted 10 lines

From: "Tobin C. Harding" <[email protected]>
To: "Paolo Bonzini" <[email protected]>, [email protected]
Cc: [email protected], [email protected], "Tobin C. Harding" <[email protected]>
Sent: Monday, October 9, 2017 8:30:14 AM
Subject: [PATCH] KVM: remove printing of token address

KVM currently prints the address of the consumer token. It is not immediately clear what benefit it is to see this address. Printing this address leaks kernel pointers into dmesg and is a security risk.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Remove the consumer token address from error message output.

It should use %pK instead.

Is there any other way we can identify a token? There is some push back against kpt_restrict (as used by %pK) at the moment. If there is another sane way to do it perhaps we could consider that, else I'll use %pK for v2.

Not really, we know it is an eventfd but you can't go from the struct eventfd_ctx* (the token) to the corresponding struct file.

Quoted 7 lines

I'm not sure about the pushback... I've read your name in
https://lwn.net/Articles/735589/ :) and that article says "the same effect as a restrictive kptr_restrict setting could be achieved by searching for (and fixing) every use of unadorned "%p" directives in the kernel". As I understand it, the push back is against restrictive kptr_restrict settings, not against using "%pK" _to avoid the need_ for such a restrictive setting.

Quoted 2 lines

In the thread that article is based on Linus airs his view that kptr_restrict is fundamentally broken.

And I agree with him that more restrictive kptr_restrict settings are kind of broken, because either no one would use them, or if you made them the default people would start using "%x". Further there is the issue that people are _already_ using "%x" already instead of e.g. "%pa". So yeah, kptr_restrict does look a bit like security theater.

However, issues with kptr_restrict do not necessarily extend to "%pK" or "%pa". The problem is that there are too many instances of "%p", and I'm happy that you want to fix them. Since we _do_ have kptr_restrict, I don't see anything wrong with converting them to "%pK".

And if everybody started using "%pK" and "%pa" appropriately, then 1) you wouldn't need restrictive kptr_restrict settings anymore; 2) kptr_restrict would actually prevent address leaks.

Quoted 5 lines
Quoted 2 lines

Would you be happy if instead of printing the pointer we printed a unique identifier (some suitable hash of the pointer value)?

As long as the "suitable hash" is computed inside printk, I don't care. If the suitable hash would be in KVM or VFIO code, then please no. :)

I wouldn't do that to you :)

Quoted 1 line

Paolo

Thanks for you explanations Paolo.

Tobin.