lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 02 Aug 2019 09:34:40 +0200
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Branden Bonaby <brandonbonaby94@...il.com>
Cc:     linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
        kys@...rosoft.com, haiyangz@...rosoft.com, sthemmin@...rosoft.com,
        sashal@...nel.org
Subject: Re: [PATCH 2/3] drivers: hv: vmbus: add fuzz test attributes to sysfs

Branden Bonaby <brandonbonaby94@...il.com> writes:

> Expose the test parameters as part of the sysfs channel attributes.
> We will control the testing state via these attributes.
>
> Signed-off-by: Branden Bonaby <brandonbonaby94@...il.com>
> ---
>  Documentation/ABI/stable/sysfs-bus-vmbus | 22 ++++++
>  drivers/hv/vmbus_drv.c                   | 97 +++++++++++++++++++++++-
>  2 files changed, 118 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/ABI/stable/sysfs-bus-vmbus b/Documentation/ABI/stable/sysfs-bus-vmbus
> index 8e8d167eca31..239fcb6fdc75 100644
> --- a/Documentation/ABI/stable/sysfs-bus-vmbus
> +++ b/Documentation/ABI/stable/sysfs-bus-vmbus
> @@ -185,3 +185,25 @@ Contact:        Michael Kelley <mikelley@...rosoft.com>
>  Description:    Total number of write operations that encountered an outbound
>  		ring buffer full condition
>  Users:          Debugging tools
> +
> +What:           /sys/bus/vmbus/devices/<UUID>/fuzz_test_state

I would prefer this to go under /sys/kernel/debug/ as this is clearly a
debug/test feature.


> +Date:           July 2019
> +KernelVersion:  5.2
> +Contact:        Branden Bonaby <brandonbonaby94@...il.com>
> +Description:    Fuzz testing status of a vmbus device, whether its in an ON
> +		 state or a OFF state
> +Users:          Debugging tools
> +
> +What:           /sys/bus/vmbus/devices/<UUID>/fuzz_test_buffer_delay
> +Date:           July 2019
> +KernelVersion:  5.2
> +Contact:        Branden Bonaby <brandonbonaby94@...il.com>
> +Description:    Fuzz testing buffer delay value between 0 - 1000
> +Users:          Debugging tools
> +
> +What:           /sys/bus/vmbus/devices/<UUID>/fuzz_test_message_delay
> +Date:           July 2019
> +KernelVersion:  5.2
> +Contact:        Branden Bonaby <brandonbonaby94@...il.com>
> +Description:    Fuzz testing message delay value between 0 - 1000
> +Users:          Debugging tools
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 92b1874b3eb3..0c71fd66ef81 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -22,7 +22,7 @@
>  #include <linux/clockchips.h>
>  #include <linux/cpu.h>
>  #include <linux/sched/task_stack.h>
> -
> +#include <linux/kernel.h>
>  #include <asm/mshyperv.h>
>  #include <linux/notifier.h>
>  #include <linux/ptrace.h>
> @@ -584,6 +584,98 @@ static ssize_t driver_override_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(driver_override);
>  
> +static ssize_t fuzz_test_state_store(struct device *dev,
> +				     struct device_attribute *attr,
> +				     const char *buf, size_t count)
> +{
> +	struct hv_device *hv_dev = device_to_hv_device(dev);
> +	struct vmbus_channel *channel = hv_dev->channel;
> +	int state;
> +	int delay = kstrtoint(buf, 0, &state);
> +
> +	if (delay)
> +		return count;
> +	if (state)
> +		channel->fuzz_testing_state = 1;
> +	else
> +		channel->fuzz_testing_state = 0;
> +	return count;
> +}
> +
> +static ssize_t fuzz_test_state_show(struct device *dev,
> +				    struct device_attribute *dev_attr,
> +				    char *buf)
> +{
> +	struct hv_device *hv_dev = device_to_hv_device(dev);
> +	struct vmbus_channel *channel = hv_dev->channel;
> +
> +	return sprintf(buf, "%u\n", channel->fuzz_testing_state);
> +}
> +static DEVICE_ATTR_RW(fuzz_test_state);
> +
> +static ssize_t fuzz_test_buffer_delay_store(struct device *dev,
> +					    struct device_attribute *attr,
> +					    const char *buf, size_t count)
> +{
> +	struct hv_device *hv_dev = device_to_hv_device(dev);
> +	struct vmbus_channel *channel = hv_dev->channel;
> +	int val;
> +	int delay = kstrtoint(buf, 0, &val);
> +
> +	if (delay)
> +		return count;
> +	if (val >= 1 && val <= 1000)
> +		channel->fuzz_testing_buffer_delay = val;
> +	/*Best to not use else statement here since we want
> +	 *the buffer delay to remain the same if val > 1000
> +	 */
> +	else if (val <= 0)
> +		channel->fuzz_testing_buffer_delay = 0;
> +	return count;
> +}
> +
> +static ssize_t fuzz_test_buffer_delay_show(struct device *dev,
> +					   struct device_attribute *dev_attr,
> +					   char *buf)
> +{
> +	struct hv_device *hv_dev = device_to_hv_device(dev);
> +	struct vmbus_channel *channel = hv_dev->channel;
> +
> +	return sprintf(buf, "%u\n", channel->fuzz_testing_buffer_delay);
> +}
> +static DEVICE_ATTR_RW(fuzz_test_buffer_delay);
> +
> +static ssize_t fuzz_test_message_delay_store(struct device *dev,
> +					     struct device_attribute *attr,
> +					     const char *buf, size_t count)
> +{
> +	struct hv_device *hv_dev = device_to_hv_device(dev);
> +	struct vmbus_channel *channel = hv_dev->channel;
> +	int val;
> +	int delay = kstrtoint(buf, 0, &val);
> +
> +	if (delay)
> +		return count;
> +	if (val >= 1 && val <= 1000)
> +		channel->fuzz_testing_message_delay = val;
> +	/*Best to not use else statement here since we want
> +	 *the message delay to remain the same if val > 1000
> +	 */
> +	else if (val <= 0)
> +		channel->fuzz_testing_message_delay = 0;
> +	return count;
> +}
> +
> +static ssize_t fuzz_test_message_delay_show(struct device *dev,
> +					    struct device_attribute *dev_attr,
> +					    char *buf)
> +{
> +	struct hv_device *hv_dev = device_to_hv_device(dev);
> +	struct vmbus_channel *channel = hv_dev->channel;
> +
> +	return sprintf(buf, "%u\n", channel->fuzz_testing_message_delay);
> +}
> +static DEVICE_ATTR_RW(fuzz_test_message_delay);
>  /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */
>  static struct attribute *vmbus_dev_attrs[] = {
>  	&dev_attr_id.attr,
> @@ -615,6 +707,9 @@ static struct attribute *vmbus_dev_attrs[] = {
>  	&dev_attr_vendor.attr,
>  	&dev_attr_device.attr,
>  	&dev_attr_driver_override.attr,
> +	&dev_attr_fuzz_test_state.attr,
> +	&dev_attr_fuzz_test_buffer_delay.attr,
> +	&dev_attr_fuzz_test_message_delay.attr,
>  	NULL,
>  };

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ