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:   Sat, 2 Mar 2019 18:39:30 +0000
From:   Michael Kelley <mikelley@...rosoft.com>
To:     kimbrownkd <kimbrownkd@...il.com>, Long Li <longli@...rosoft.com>,
        Sasha Levin <Alexander.Levin@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Dexuan Cui <decui@...rosoft.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC:     KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v4] Drivers: hv: vmbus: Expose monitor data only when
 monitor pages are used

From: Kimberly Brown <kimbrownkd@...il.com>  Sent: Friday, March 1, 2019 11:18 AM
> 
> +/*
> + * Channel-level attribute_group callback function. Returns the permission for
> + * each attribute, and returns 0 if an attribute is not visible.
> + */
> +static umode_t vmbus_chan_attr_is_visible(struct kobject *kobj,
> +					  struct attribute *attr, int idx)
> +{
> +	const struct vmbus_channel *channel =
> +		container_of(kobj, struct vmbus_channel, kobj);
> +
> +	/* Hide the monitor attributes if the monitor mechanism is not used. */
> +	if (!channel->offermsg.monitor_allocated &&
> +	    (attr == &chan_attr_pending.attr ||
> +	     attr == &chan_attr_latency.attr ||
> +	     attr == &chan_attr_monitor_id.attr))
> +		return 0;
> +
> +	return attr->mode;
> +}
> +
> +static struct attribute_group vmbus_chan_group = {
> +	.attrs = vmbus_chan_attrs,
> +	.is_visible = vmbus_chan_attr_is_visible
> +};
> +
>  static struct kobj_type vmbus_chan_ktype = {
>  	.sysfs_ops = &vmbus_chan_sysfs_ops,
>  	.release = vmbus_chan_release,
> -	.default_attrs = vmbus_chan_attrs,

Just to double-check my understanding, removing the default_attrs
here means that in vmbus_add_channel_kobj(), the call to
kobject_init_and_add() will only create the sub-directory that is the
channel number.  The sub-directory will be empty.  Then the new
call to sysfs_create_group() that you added below will populate
the subdirectory, as filtered by vmbus_chan_attr_is_visible().

>  };
> 
>  /*
> @@ -1571,6 +1624,12 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct
> vmbus_channel *channel)
>  	if (ret)
>  		return ret;
> 
> +	ret = sysfs_create_group(kobj, &vmbus_chan_group);
> +	if (ret) {
> +		pr_err("Unable to set up channel sysfs files\n");
> +		return ret;

In this error case, the previously created sub-directory that is the
channel number needs to be deleted/cleaned up.

> +	}
> +

Michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ