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: <4A474FB5.4070901@gmail.com>
Date:	Sun, 28 Jun 2009 13:10:45 +0200
From:	Jarek Poplawski <jarkao2@...il.com>
To:	Oleg Nesterov <oleg@...hat.com>
CC:	Davide Libenzi <davidel@...ilserver.org>,
	Eric Dumazet <eric.dumazet@...il.com>,
	Jiri Olsa <jolsa@...hat.com>, netdev@...r.kernel.org,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	fbl@...hat.com, nhorman@...hat.com, davem@...hat.com,
	Tejun Heo <htejun@...il.com>
Subject: Re: [PATCH] net: fix race in the receive/select

Oleg Nesterov wrote, On 06/26/2009 04:50 PM:

> On 06/26, Davide Libenzi wrote:
>> On Fri, 26 Jun 2009, Oleg Nesterov wrote:
>>
>>> And if we remove waitqueue_active() in xxx_update(), then lock/unlock is
>>> not needed too.
>>>
>>> If xxx_poll() takes q->lock first, it can safely miss the changes in ->status
>>> and schedule(): xxx_update() will take q->lock, notice the sleeper and wake
>>> it up (ok, it will set ->triggered but this doesn't matter).
>>>
>>> If xxx_update() takes q->lock first, xxx_poll() must see the changes in
>>> status after poll_wait()->unlock(&q->lock) (in fact, after lock, not unlock).
>> Sure. The snippet above was just to show what typically the code does, not
>> a suggestion on how to solve the socket case.
> 
> Yes, yes. I just meant you are right imho, we shouldn't add mb() into
> add_wait_queue().
> 
>> But yeah, the problem in this case is the waitqueue_active() call. Without
>> that, the wait queue lock/unlock in poll_wait() and the one in wake_up()
>> guarantees the necessary barriers.
>> Some might argue the costs of the lock/unlock of q->lock, and wonder if
>> MBs are a more efficient solution. This is something I'm not going into.
>> To me, it just looked not right having cross-matching MB in different
>> subsystems.
> 
> This is subjective and thus up to maintainers, but personally I think you
> are very, very right.
> 
> Perhaps we can add
> 
> 	void sock_poll_wait(struct file *file, struct sock *sk, poll_table *pt)
> 	{
> 		if (pt) {
> 			poll_wait(file, sk->sk_sleep, pt);
> 			/*
> 			 * fat comment
> 			 */
> 			smp_mb(); // or smp_mb__after_unlock();
> 		}
> 	}
> 
> Oleg.


Maybe 'a bit' further?:

static inline void __poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
{
	p->qproc(filp, wait_address, p);
}

static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
{
	if (p && wait_address)
		__poll_wait(filp, wait_address, p);
}

static inline void sock_poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
{
	if (p && wait_address) {
		__poll_wait(filp, wait_address, p);
		/*
		 * fat comment
		 */
		smp_mb(); // or smp_mb__after_unlock();
	}
}

Jarek P.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ