* [PATCH 3/3] thunderbolt: Allow clearing the key
@ 2017-08-15 5:19 Bernat, Yehezkel
2017-08-15 7:11 ` Mika Westerberg
0 siblings, 1 reply; 2+ messages in thread
From: Bernat, Yehezkel @ 2017-08-15 5:19 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Andreas Noever, Michael Jamet, Mika Westerberg, Lukas Wunner,
Andy Shevchenko, linux-kernel
If secure authentication of a devices fails, either because the device
already has another key uploaded, or there is some other error sending
challenge to the device, and the user only wants to approve the device
just once (without a new key being uploaded to the device) the current
implementation does not allow this because the key cannot be cleared
once set even if we allow it to be changed.
Make this scenario possible and allow clearing the key by writing
empty string to the key sysfs file.
Signed-off-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
---
Documentation/ABI/testing/sysfs-bus-thunderbolt | 2 ++
drivers/thunderbolt/switch.c | 15 +++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-thunderbolt b/Documentation/ABI/testing/sysfs-bus-thunderbolt
index 2a98149..392bef5 100644
--- a/Documentation/ABI/testing/sysfs-bus-thunderbolt
+++ b/Documentation/ABI/testing/sysfs-bus-thunderbolt
@@ -45,6 +45,8 @@ Contact: thunderbolt-software@lists.01.org
Description: When a devices supports Thunderbolt secure connect it will
have this attribute. Writing 32 byte hex string changes
authorization to use the secure connection method instead.
+ Writing an empty string clears the key and regular connection
+ method can be used again.
What: /sys/bus/thunderbolt/devices/.../device
Date: Sep 2017
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 8510abc..53f40c5 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -807,8 +807,11 @@ static ssize_t key_store(struct device *dev, struct device_attribute *attr,
struct tb_switch *sw = tb_to_switch(dev);
u8 key[TB_SWITCH_KEY_SIZE];
ssize_t ret = count;
+ bool clear = false;
- if (hex2bin(key, buf, sizeof(key)))
+ if (!strcmp(buf, "\n"))
+ clear = true;
+ else if (hex2bin(key, buf, sizeof(key)))
return -EINVAL;
if (mutex_lock_interruptible(&switch_lock))
@@ -818,9 +821,13 @@ static ssize_t key_store(struct device *dev, struct device_attribute *attr,
ret = -EBUSY;
} else {
kfree(sw->key);
- sw->key = kmemdup(key, sizeof(key), GFP_KERNEL);
- if (!sw->key)
- ret = -ENOMEM;
+ if (clear) {
+ sw->key = NULL;
+ } else {
+ sw->key = kmemdup(key, sizeof(key), GFP_KERNEL);
+ if (!sw->key)
+ ret = -ENOMEM;
+ }
}
mutex_unlock(&switch_lock);
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] thunderbolt: Allow clearing the key
2017-08-15 5:19 [PATCH 3/3] thunderbolt: Allow clearing the key Bernat, Yehezkel
@ 2017-08-15 7:11 ` Mika Westerberg
0 siblings, 0 replies; 2+ messages in thread
From: Mika Westerberg @ 2017-08-15 7:11 UTC (permalink / raw)
To: Bernat, Yehezkel
Cc: Greg Kroah-Hartman, Andreas Noever, Michael Jamet, Lukas Wunner,
Andy Shevchenko, linux-kernel
On Tue, Aug 15, 2017 at 08:19:20AM +0300, Bernat, Yehezkel wrote:
> If secure authentication of a devices fails, either because the device
> already has another key uploaded, or there is some other error sending
> challenge to the device, and the user only wants to approve the device
> just once (without a new key being uploaded to the device) the current
> implementation does not allow this because the key cannot be cleared
> once set even if we allow it to be changed.
>
> Make this scenario possible and allow clearing the key by writing
> empty string to the key sysfs file.
>
> Signed-off-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-15 7:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-15 5:19 [PATCH 3/3] thunderbolt: Allow clearing the key Bernat, Yehezkel
2017-08-15 7:11 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®