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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 21 Sep 2015 17:40:35 -0600
From:	Toshi Kani <toshi.kani@....com>
To:	mchehab@....samsung.com, bp@...en8.de, dougthompson@...ssion.com
Cc:	linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org,
	elliott@....com, tony.luck@...el.com
Subject: Re: [PATCH 2/2] EDAC: Fix sysfs dimm_label store operation

On Mon, 2015-09-21 at 13:19 -0600, Toshi Kani wrote:
 :
> 
> diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
> index 8983755..f2ea914 100644
> --- a/drivers/edac/edac_mc_sysfs.c
> +++ b/drivers/edac/edac_mc_sysfs.c
> @@ -241,13 +241,14 @@ static ssize_t channel_dimm_label_store(struct
> device *dev,
>  	unsigned chan = to_channel(mattr);
>  	struct rank_info *rank = csrow->channels[chan];
>  
> -	ssize_t max_size = 0;
> +	if (count == 0 || count > sizeof(rank->dimm->label))
> +		return -EINVAL;
>  
> -	max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1);
> -	strncpy(rank->dimm->label, data, max_size);
> -	rank->dimm->label[max_size] = '\0';
> +	strncpy(rank->dimm->label, data, count);
> +	if (rank->dimm->label[count - 1] == '\n')
> +		rank->dimm->label[count - 1] = '\0';

Thinking further, it'd be safer to always set a null at the end.  I will
update the patch.

-Toshi

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