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] [day] [month] [year] [list]
Date:	Thu, 22 Oct 2015 23:25:45 +0300
From:	Pantelis Antoniou <panto@...oniou-consulting.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	Rob Herring <robherring2@...il.com>,
	Frank Rowand <frowand.list@...il.com>,
	Matt Porter <mporter@...sulko.com>,
	Koen Kooi <koen@...inion.thruhere.net>,
	Guenter Roeck <linux@...ck-us.net>,
	Devicetree List <devicetree@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>, linux-api@...r.kernel.org
Subject: Re: [PATCH v7 2/6] of: overlay: global sysfs enable attribute

Hi Greg,

> On Oct 22, 2015, at 23:19 , Greg Kroah-Hartman <gregkh@...uxfoundation.org> wrote:
> 
> On Thu, Oct 22, 2015 at 10:50:23PM +0300, Pantelis Antoniou wrote:
>> A throw once master enable switch to protect against any
>> further overlay applications if the administrator desires so.
>> 
>> A kernel command line option is provided as well.
>> 
>> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@...sulko.com>
>> ---
>> drivers/of/overlay.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 49 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
>> index 12c3e47..91f10ed 100644
>> --- a/drivers/of/overlay.c
>> +++ b/drivers/of/overlay.c
>> @@ -21,6 +21,7 @@
>> #include <linux/err.h>
>> #include <linux/idr.h>
>> #include <linux/sysfs.h>
>> +#include <linux/atomic.h>
>> 
>> #include "of_private.h"
>> 
>> @@ -55,8 +56,19 @@ struct of_overlay {
>> 	struct kobject kobj;
>> };
>> 
>> +/* master enable switch; once set to 0 can't be re-enabled */
>> +static atomic_t ov_enable = ATOMIC_INIT(1);
>> +
>> +static int __init of_overlay_disable_setup(char *str __always_unused)
>> +{
>> +	atomic_set(&ov_enable, 0);
>> +	return 1;
>> +}
>> +__setup("of_overlay_disable", of_overlay_disable_setup);
>> +
>> static int of_overlay_apply_one(struct of_overlay *ov,
>> 		struct device_node *target, const struct device_node *overlay);
>> +static int overlay_removal_is_ok(struct of_overlay *ov);
>> 
>> static int of_overlay_apply_single_property(struct of_overlay *ov,
>> 		struct device_node *target, struct property *prop)
>> @@ -339,6 +351,35 @@ void of_overlay_release(struct kobject *kobj)
>> 	kfree(ov);
>> }
>> 
>> +static ssize_t enable_show(struct kobject *kobj,
>> +		struct kobj_attribute *attr, char *buf)
>> +{
>> +	return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&ov_enable));
> 
> Minor nit, you never need to care about the size of the buffer for a
> sysfs file, if you do, you are doing something wrong.  So this can just
> be:
> 	return sprintf(buf, "%d\n", atomic_read(&ov_enable));
> 
> 

Nice to know; I have a ingrained habit to avoid standard sprintf, so..

> Anyway, nothing worth keeping this from being merged:
> 


Thanks!

> Acked-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> 

Regards

— Pantelis

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ