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: <1299776524.17443.14.camel@dcbw.foobar.com>
Date:	Thu, 10 Mar 2011 11:02:02 -0600
From:	Dan Williams <dcbw@...hat.com>
To:	Dan Carpenter <error27@...il.com>
Cc:	javier@...ybit.com, "John W. Linville" <linville@...driver.com>,
	libertas-dev@...ts.infradead.org, linux-wireless@...r.kernel.org,
	netdev@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [patch] libertas: fix write past end of array in mesh_id_get()

On Thu, 2011-03-10 at 18:23 +0300, Dan Carpenter wrote:
> defs.meshie.val.mesh_id is 32 chars long.  It's not supposed to be NUL
> terminated.  This code puts a terminator on the end to make it easier to
> print to sysfs.  The problem is that if the mesh_id fills the entire
> buffer the original code puts the terminator one spot past the end.
> 
> The way the original code was written, there was a check to make sure
> that maxlen was less than PAGE_SIZE.  Since we know that maxlen is at
> most 34 chars, I just removed the check.
> 
> Signed-off-by: Dan Carpenter <error27@...il.com>

Acked-by: Dan Williams <dcbw@...hat.com>

> diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
> index acf3bf6..9d097b9 100644
> --- a/drivers/net/wireless/libertas/mesh.c
> +++ b/drivers/net/wireless/libertas/mesh.c
> @@ -918,7 +918,6 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
>  			   char *buf)
>  {
>  	struct mrvl_mesh_defaults defs;
> -	int maxlen;
>  	int ret;
>  
>  	ret = mesh_get_default_parameters(dev, &defs);
> @@ -931,13 +930,11 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
>  		defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
>  	}
>  
> -	/* SSID not null terminated: reserve room for \0 + \n */
> -	maxlen = defs.meshie.val.mesh_id_len + 2;
> -	maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE;
> +	memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len);
> +	buf[defs.meshie.val.mesh_id_len] = '\n';
> +	buf[defs.meshie.val.mesh_id_len + 1] = '\0';
>  
> -	defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0';
> -
> -	return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id);
> +	return defs.meshie.val.mesh_id_len + 1;
>  }
>  
>  /**
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ