Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509AbbGWJQC (ORCPT ); Thu, 23 Jul 2015 05:16:02 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53166 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916AbbGWJPz (ORCPT ); Thu, 23 Jul 2015 05:15:55 -0400 Message-ID: <1437642952.4377.10.camel@suse.com> Subject: Re: Several races in "usbnet" module (kernel 4.1.x) From: Oliver Neukum To: Eugene Shatokhin Cc: LKML , linux-usb@vger.kernel.org, netdev@vger.kernel.org Date: Thu, 23 Jul 2015 11:15:52 +0200 In-Reply-To: <55AFE210.7030104@rosalab.ru> References: <55AD3A41.2040100@rosalab.ru> <1437488529.3823.16.camel@suse.com> <55AFE210.7030104@rosalab.ru> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 940 Lines: 34 On Wed, 2015-07-22 at 21:33 +0300, Eugene Shatokhin wrote: > The following part is not necessary, I think. usbnet_bh() does not > touch > EVENT_NO_RUNTIME_PM bit explicitly and these bit operations are > atomic > w.r.t. each other. > > > + mpn |= !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags); > > + /* in case the bh reset a flag */ Yes, they are atomic w.r.t. each other. And that limitation worries me. I am considering architectures which do atomic operations with spinlocks. And this code mixes another operation into it. Can this happen? CPU A CPU B take lock read old value set value to 0 clear bit write back changed value release lock Regards Oliver -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/