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] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 13 Apr 2015 23:49:34 +0200 (CEST)
From:	Thomas Gleixner <tglx@...utronix.de>
To:	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Josh Triplett <josh@...htriplett.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Nicholas Miell <nmiell@...cast.net>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Ingo Molnar <mingo@...hat.com>,
	Alan Cox <gnomes@...rguk.ukuu.org.uk>,
	Lai Jiangshan <laijs@...fujitsu.com>,
	Stephen Hemminger <stephen@...workplumber.org>,
	Peter Zijlstra <peterz@...radead.org>,
	David Howells <dhowells@...hat.com>
Subject: Re: [PATCH v14 for 4.1] sys_membarrier(): system-wide memory barrier
 (x86)

On Mon, 13 Apr 2015, Mathieu Desnoyers wrote:

> [ Andrew, can you take this for the 4.1 merge window ? ]

You probably mean 4.2, right?

This fails the basic test for exposure in linux-next, adds syscalls
without the explicit ack of any x86 maintainer and exposes a user
space ABI with a magic undocumented flags argument.

> This patch only adds the system call to x86.

So the changes to 
 
>  include/uapi/asm-generic/unistd.h |    4 +-

are just cosmetic, right?

> +/* System call membarrier "flags" argument. */
> +enum {
> +	/*
> +	 * Query whether the rest of the specified flags are supported,
> +	 * without performing synchronization.
> +	 */

Docbook has support for enums.

> +	MEMBARRIER_QUERY = (1 << 31),
> +};

Why is this an anonymous enum?

> +#ifdef CONFIG_SMP

So documentation is SMP only, right?

> +/*

Docbook comments start with "/**"

> + * sys_membarrier - issue memory barrier on all running threads
> + * @flags: MEMBARRIER_QUERY:
> + *             Query whether the rest of the specified flags are supported,
> + *             without performing synchronization.

      @flags:	Explain what this is for, not what a particular implemented
      		value is used for. The values should be proper documented
		in the enum

Why is this an int and not a named enum?

Why is this named flags and not given a descriptive name? If I
understand your changelog correctly you want to implement other
synchronization modes than the current synchronize_sched. So mode
might be a proper name.

Why is MEMBARRIER_QUERY not a proper operation mode and simply returns
the supported modes instead of doing it backwards and asking whether
a specific value is supported?

> + * On uniprocessor systems, this system call simply returns 0 after
> + * validating the arguments, so user-space knows it is implemented.

And the exact point of knowing this is?

> + */
> +SYSCALL_DEFINE1(membarrier, int, flags)
> +{
> +	int retval;
> +
> +	retval = membarrier_validate_flags(flags);
> +	if (retval)
> +		goto end;
> +	if (unlikely(flags & MEMBARRIER_QUERY) || num_online_cpus() == 1)
> +		goto end;

So why not doing the obvious?

enum modes {
     QUERY     = 0,
     FULL_SYNC = 1 <<  0,
};

#define IMPLEMENTED_MODES	(FULL_SYNC)

	switch (mode) {
	case FULL_SYNC:
       		synchronize_sched_on_smp();
		return 0;
	case QUERY:
		return IMPLEMENTED_MODES;
	}
	return -EINVAL;

And later on you do

 enum modes {
     QUERY       = 0,
     FULL_SYNC   = 1 <<  0,
+    MAGIC_SYNC  = 1 <<  1,
 };

-#define IMPLEMENTED_MODES	(FULL_SYNC)
+#define IMPLEMENTED_MODES	(FULL_SYNC | MAGIC_SYNC)

All you need to make sure is that any mode is a power of 2.

Hmm?

Thanks,

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