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]
Message-Id: <20140620155426.1c4d0a9936859d1b20679bdf@linux-foundation.org>
Date:	Fri, 20 Jun 2014 15:54:26 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	rtc-linux@...glegroups.com
Cc:	Raghavendra Ganiga <ravi23ganiga@...il.com>, a.zummo@...ertech.it,
	linux-kernel@...r.kernel.org
Subject: Re: [rtc-linux] [PATCH] rtc: add support of nvram for maxim dallas
 rtc ds1343

On Sat, 24 May 2014 21:34:33 +0530 Raghavendra Ganiga <ravi23ganiga@...il.com> wrote:

> This is a patch to add support of nvram for maxim dallas
> rtc ds1343
> 
> ...
>
> --- a/drivers/rtc/rtc-ds1343.c
> +++ b/drivers/rtc/rtc-ds1343.c
> @@ -4,6 +4,7 @@
>   * Real Time Clock
>   *
>   * Author : Raghavendra Chandra Ganiga <ravi23ganiga@...il.com>
> + *	    Ankur Srivastava <sankurece@...il.com> : DS1343 Nvram Support
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License version 2 as
> @@ -45,6 +46,9 @@
>  #define DS1343_CONTROL_REG	0x0F
>  #define DS1343_STATUS_REG	0x10
>  #define DS1343_TRICKLE_REG	0x11
> +#define DS1343_NVRAM		0x20
> +
> +#define DS1343_NVRAM_LEN	96
>  
>  /* DS1343 Control Registers bits */
>  #define DS1343_EOSC		0x80
> @@ -149,6 +153,64 @@ static ssize_t ds1343_store_glitchfilter(struct device *dev,
>  static DEVICE_ATTR(glitch_filter, S_IRUGO | S_IWUSR, ds1343_show_glitchfilter,
>  			ds1343_store_glitchfilter);
>  
> +static ssize_t ds1343_nvram_write(struct file *filp, struct kobject *kobj,
> +			struct bin_attribute *attr,
> +			char *buf, loff_t off, size_t count)
> +{
> +	int ret;
> +	unsigned char address;
> +	struct device *dev = kobj_to_dev(kobj);
> +	struct ds1343_priv *priv = dev_get_drvdata(dev);
> +
> +	if (unlikely(!count))
> +		return count;
> +
> +	if ((count + off) > DS1343_NVRAM_LEN)

I worry about what happens if (count + off) wraps through zero.

> +		count = DS1343_NVRAM_LEN - off;

We might end up with an enormous value in `count'?

> +	address = DS1343_NVRAM + off;
> +
> +	ret = regmap_bulk_write(priv->map, address, buf, count);
> +	if (ret < 0)
> +		dev_err(&priv->spi->dev, "Error in nvram write %d", ret);
> +
> +	return (ret < 0) ? ret : count;
> +}
> +
> +
> +static ssize_t ds1343_nvram_read(struct file *filp, struct kobject *kobj,
> +				struct bin_attribute *attr,
> +				char *buf, loff_t off, size_t count)
> +{
> +	int ret;
> +	unsigned char address;
> +	struct device *dev = kobj_to_dev(kobj);
> +	struct ds1343_priv *priv = dev_get_drvdata(dev);
> +
> +	if (unlikely(!count))
> +		return count;
> +
> +	if ((count + off) > DS1343_NVRAM_LEN)
> +		count = DS1343_NVRAM_LEN - off;

Here too.

> +	address = DS1343_NVRAM + off;
> +
> +	ret = regmap_bulk_read(priv->map, address, buf, count);
> +	if (ret < 0)
> +		dev_err(&priv->spi->dev, "Error in nvram read %d\n", ret);
> +
> +	return (ret < 0) ? ret : count;
> +}
> +
> +

--
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