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] [thread-next>] [day] [month] [year] [list]
Message-ID: <4BC4A6B2.1090906@colorfullife.com>
Date:	Tue, 13 Apr 2010 19:15:30 +0200
From:	Manfred Spraul <manfred@...orfullife.com>
To:	Chris Mason <chris.mason@...cle.com>
CC:	zach.brown@...cle.com, jens.axboe@...cle.com,
	linux-kernel@...r.kernel.org, Nick Piggin <npiggin@...e.de>
Subject: Re: [PATCH 1/2] ipc semaphores: reduce ipc_lock contention in semtimedop

Hi Chris,


On 04/12/2010 08:49 PM, Chris Mason wrote:
>   /*
> + * when a semaphore is modified, we want to retry the series of operations
> + * for anyone that was blocking on that semaphore.  This breaks down into
> + * a few different common operations:
> + *
> + * 1) One modification releases one or more waiters for zero.
> + * 2) Many waiters are trying to get a single lock, only one will get it.
> + * 3) Many modifications to the count will succeed.
> + *
>    
Have you thought about odd corner cases:
Nick noticed the last time that it is possible to wait for arbitrary values:
in one semop:
     - decrease semaphore 5 by 10
     - wait until semaphore 5 is 0
     - increase semaphore 5 by 10.

>   SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
>   		unsigned, nsops, const struct timespec __user *, timeout)
>   {
> @@ -1129,6 +1306,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
>   	struct sem_queue queue;
>   	unsigned long jiffies_left = 0;
>   	struct ipc_namespace *ns;
> +	struct sem *blocker = NULL;
> +	LIST_HEAD(pending);
>
>   	ns = current->nsproxy->ipc_ns;
>
> @@ -1168,6 +1347,14 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
>   			alter = 1;
>   	}
>
> +	/*
> +	 * try_atomic_semop takes all the locks of all the semaphores in
> +	 * the sops array.  We have to make sure we don't deadlock if userland
> +	 * happens to send them out of order, so we sort them by semnum.
> +	 */
> +	if (nsops>  1)
> +		sort(sops, nsops, sizeof(*sops), sembuf_compare, NULL);
> +
>    
Does sorting preserve the behavior?
--
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