Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4452060imm; Mon, 30 Jul 2018 15:09:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFjWtlu9blcStMUqtV7BdfI+Y87jX94rO5Ep7pXp7Y7jhwKkCKZS6XIMIqZZBhvoYCNb0S X-Received: by 2002:a63:2106:: with SMTP id h6-v6mr17953478pgh.161.1532988585761; Mon, 30 Jul 2018 15:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532988585; cv=none; d=google.com; s=arc-20160816; b=hgw3bxozqsc1n5cktKFHCklc2njlsHJ+lFNmq+18TqcZ2CAg/BzJFnoQt7UP7EPOrW RmhwtGO2FALkY3N0EDaOj2GB/onS1Hi4wMr9dgozJAuzbEMFYGQ4pFmgWirvDWrVKkKZ dkiBr2qelYfGiAW9yG9GJUk2BpZn2beBQYurGw6p0WhUiZ5RCgH0GYUZX3iSveT5OTI9 EbboQ/VJCI2/JyKdISYCHMG/s4yPQ8rDfChP0teYDuvilhnNzb5ABsXboELmCu5MtMbt nD6znxCpoqZdSYhASk9CyXtteC0rJOamPAdK9AM4A/9UjgoehBJ7Ea4pWiVFAKq+T99M HIcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=eTl6ATA4tdRrwve8FhvJvWCh1oZxZJM6RUJY/+NqFZA=; b=Bi9gFKUhc++ko4LWL7GLlrUGk8WAzIUJgr7ZaBC1+ent2hNazhM38zRAu8OSLhsPcg /CaP7A7mcI+bNYHFyupj8AHGyB2QdNnc1YdQH9+Sx9ABGOWWdA0Xclm7j9ytyov8Pqy4 nl0TzWoj/p3kD7RFqAkgsfV4ZwjDRJlOnhosZUf/ajxtSoqL0fmXxe+S/1NDYDcdfMjR DlMCPKlHCVyILiQOmfCfhm0li9SgFIXxjlD812gzYtm8Cjk0MBHUTQSafFXUJI0lp3oc 6Xp0pKgmX6lKBtbgc6M+4hUNXMQtbfdQYVE9gRrZowL7TDIGkaVG02oVBEZaCy6VUvH+ Hbnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f62-v6si13074315pfa.73.2018.07.30.15.09.31; Mon, 30 Jul 2018 15:09:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731968AbeG3Xpp (ORCPT + 99 others); Mon, 30 Jul 2018 19:45:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:43404 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726622AbeG3Xpo (ORCPT ); Mon, 30 Jul 2018 19:45:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0551AAFC2; Mon, 30 Jul 2018 22:08:41 +0000 (UTC) Date: Mon, 30 Jul 2018 15:08:37 -0700 From: Davidlohr Bueso To: Manfred Spraul Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH -next] ipc/sem: prevent queue.status tearing in semop Message-ID: <20180730220837.iojrnvdb3lippfj7@linux-r8p5> References: <20180717052654.676-1-dave@stgolabs.net> <7909e12b-6dd7-e28a-010c-003545a8e4b5@colorfullife.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <7909e12b-6dd7-e28a-010c-003545a8e4b5@colorfullife.com> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Jul 2018, Manfred Spraul wrote: >sma->use_global_lock is sometimes used with smp_load_acquire(), >sometimes without. >So far, I assumed that this is safe. > >The same applies for nf_conntrack_locks_all, in nf_conntrack_all_lock() So the netfilter code is safe wrt tearing as _all_ accesses are done with barriers and/or under spinlock. However, this isn't always the case for sma->use_global_lock, albeit harmless. - sem_lock(): It doesn't matter if we get the first check right as we end up rechecking with locks held. /* * Initial check for use_global_lock. Just an optimization, * no locking, no memory barrier. */ if (!sma->use_global_lock) { - complexmode_enter/tryleave() are called under the ipc object lock, so that is safe: spin_lock() complexmode_enter() ... complexmode_tryleave() spin_unlock() - newary(): Init, no concurrency, of course. So while I also like READ/WRITE_ONCE() calls in that it helps document the code, I don't think we need/want want this. There's a comment there in the first place. Thanks, Davidlohr