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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 25 Jul 2014 14:42:49 -0400 (EDT)
From:	Bob Peterson <rpeterso@...hat.com>
To:	Abhi Das <adas@...hat.com>
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	cluster-devel@...hat.com
Subject: Re: [Cluster-devel] [RFC PATCH 3/5] gfs2: Add a dynamic buffer
 backed	by a vector of pages

----- Original Message -----
> +static int vp_alloc_pages(struct vp_ctx *vpx, int start, int end)
> +{
> +	int i;
> +
> +	for (i = start; i < end; i++) {
> +		vpx->vp_pages[i] = alloc_page(GFP_KERNEL | GFP_NOFS);
> +		if (vpx->vp_pages[i] == NULL)
> +			goto free;
> +	}
> +	return 0;
> +free:
> +	for (i = start; i < end; i++)
> +		if (vpx->vp_pages[i]) {
> +			__free_page(vpx->vp_pages[i]);
> +			vpx->vp_pages[i] = NULL;
> +		}
> +	return -ENOMEM;
> +}

I'm concerned that if we have a value for vpx->vp_pages[i] that is
nonzero (uninitialized) _after_ an element in which we couldn't
allocate a page, we could try to free the nonzero value. For that
reason, I always prefer to do something like this instead:

free:
     while (i > start) {
          i--;
          __free_page(vpx->vp_pages[i]);
          vpx->vp_pages[i] = NULL;
     }
     return -ENOMEM;

(snip)
> +struct vp_ctx* vp_get_vpx(struct vbuf *vb)
> +{
> +	struct vp_ctx *vpx = NULL;
> +
> +	if (!vb || !vb->v_opaque)
> +		goto out;
> +
> +	vpx = vb->v_opaque;
> +	if (vpx->vp_magic != VP_MAGIC) {
> +		vpx = NULL;
> +		goto out;

This goto is unnecessary, and if you eliminate it, you don't need the brackets.

> +	}
> +out:
> +	return vpx;
> +}

Regards,

Bob Peterson
Red Hat File Systems
--
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