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: <20081126133353.GA6562@elte.hu>
Date:	Wed, 26 Nov 2008 14:33:53 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	eranian@...glemail.com
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	x86@...nel.org, andi@...stfloor.org, eranian@...il.com,
	sfr@...b.auug.org.au
Subject: Re: [patch 15/24] perfmon: context creation


* eranian@...glemail.com <eranian@...glemail.com> wrote:

> +/**
> + * pfm_undo_create -- undo context creation
> + * @fd: file descriptor to close
> + * @ctx: newly created context
> + *
> + * upon return neither fd nor ctx are useable
> + */
> +void pfm_undo_create(int fd, struct pfm_context *ctx)
> +{
> +       struct files_struct *files = current->files;
> +       struct file *file;
> +       int fput_needed;
> +
> +       file = fget_light(fd, &fput_needed);
> +       /*
> +	* there is no fd_uninstall(), so we do it
> +	* here. put_unused_fd() does not remove the
> +	* effect of fd_install().
> +	*/
> +
> +       spin_lock(&files->file_lock);
> +       files->fd_array[fd] = NULL;
> +       spin_unlock(&files->file_lock);
> +
> +       fput_light(file, fput_needed);
> +
> +       /*
> +	* decrement ref count and kill file
> +	*/
> +       put_filp(file);
> +
> +       put_unused_fd(fd);
> +
> +       pfm_free_context(ctx);
> +}

This function is superfluous.

The only place where this is used is when a fresh sys_pfm_create() 
fails to do a user-copy of the sif:

+       if (ureq && copy_to_user(ureq, &sif, sizeof(sif))) {
+               pfm_undo_create(ret, new_ctx);
+               ret  = -EFAULT;
+       }

but this code should be calling sys_close(fd) instead - the fd is 
already set up with pfm_fs so it will tear down the context if this 
was the last user of the perfmon context.

So basically pfm_undo_create() is an open-coded sys_close(fd).

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