From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752796Ab3ABTcb (ORCPT ); Wed, 2 Jan 2013 14:32:31 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:42222 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752668Ab3ABTc2 (ORCPT ); Wed, 2 Jan 2013 14:32:28 -0500 Date: Wed, 2 Jan 2013 19:32:27 +0000 From: Eric Wong To: Eric Dumazet Cc: Linus Torvalds , Linux Kernel Mailing List , Hans Verkuil , Jiri Olsa , Jonathan Corbet , Al Viro , Davide Libenzi , Hans de Goede , Mauro Carvalho Chehab , David Miller , Andrew Morton , Andreas Voellmy , "Junchang(Jason) Wang" , Network Development , linux-fsdevel Subject: Re: [PATCH] epoll: prevent missed events on EPOLL_CTL_MOD Message-ID: <20130102193227.GA13566@dcvr.yhbt.net> References: <20121228014503.GA5017@dcvr.yhbt.net> <1356960060-1263-1-git-send-email-normalperson@yhbt.net> <1357065750.21409.12527.camel@edumazet-glaptop> <20130101210033.GA13255@dcvr.yhbt.net> <20130101211728.GA13380@dcvr.yhbt.net> <20130101235605.GA17168@dcvr.yhbt.net> <1357148750.21409.17169.camel@edumazet-glaptop> <20130102184010.GA21780@dcvr.yhbt.net> <1357153416.21409.17488.camel@edumazet-glaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1357153416.21409.17488.camel@edumazet-glaptop> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eric Dumazet wrote: > On Wed, 2013-01-02 at 18:40 +0000, Eric Wong wrote: > > Eric Dumazet wrote: > > > It seems the real problem is the epi->event.events = event->events; > > > which is done without taking ep->lock > > > > Yes. I am hoping it is possible to do it without a lock there, > > but your change is more obviously correct. > > > > > While a smp_mb() could reduce the race window, I believe there is still > > > a race, and the following patch would close it. > > > > I'm not an experienced kernel hacker, can you describe where the race > > would be? > > It would be for example in ep_send_events_proc() doing : > > if (epi->event.events & EPOLLONESHOT) > epi->event.events &= EP_PRIVATE_BITS; > > And this could happen at the same time. That modification in ep_send_events_proc() is protected by ep->mtx (as is ep_modify()), though. Maybe there are other places, but I don't see it.