[pve-devel] applied: [PATCH cluster] fix #1559: pmxcfs: add missing lock when dumping .rrd

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Nov 10 12:12:58 CET 2017


applied to master & stable-4

On Thu, Nov 09, 2017 at 01:24:05PM +0100, Thomas Lamprecht wrote:
> Adding our standard mutex for protecting cfs_status from multiple
> conflicting changes solves two things. First, it now protects
> cfs_status as it was changed here and secondly, it protects the
> global rrd_dump_buf and rrd_dump_last helper variables from
> incosistent access and a double free chance.
> 
> Fixes: #1559
> Reported-by: Tobias Böhm <tb at robhost.de>
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  data/src/status.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/data/src/status.c b/data/src/status.c
> index 030c003..a73fa87 100644
> --- a/data/src/status.c
> +++ b/data/src/status.c
> @@ -1076,10 +1076,13 @@ void
>  cfs_rrd_dump(GString *str)
>  {
>  	time_t ctime;
> +
> +	g_mutex_lock (&mutex);
> +
>  	time(&ctime);
> -
>  	if (rrd_dump_buf && (ctime - rrd_dump_last) < 2) {
>  		g_string_assign(str, rrd_dump_buf);
> +		g_mutex_unlock (&mutex);
>  		return;
>  	}
>  
> @@ -1108,6 +1111,8 @@ cfs_rrd_dump(GString *str)
>  	if (rrd_dump_buf)
>  		g_free(rrd_dump_buf);
>  	rrd_dump_buf = g_strdup(str->str);
> +
> +	g_mutex_unlock (&mutex);
>  }
>  
>  static gboolean
> -- 
> 2.11.0




More information about the pve-devel mailing list