From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753400AbcEROEt (ORCPT ); Wed, 18 May 2016 10:04:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:40523 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751062AbcEROEs (ORCPT ); Wed, 18 May 2016 10:04:48 -0400 Date: Wed, 18 May 2016 07:04:36 -0700 From: Davidlohr Bueso To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, Jason Low , Dave Chinner , Peter Hurley , "Paul E. McKenney" , Scott J Norton , Douglas Hatch Subject: Re: [PATCH v4 2/5] locking/rwsem: Protect all writes to owner by WRITE_ONCE() Message-ID: <20160518140436.GA6273@linux-uzut.site> References: <1463534783-38814-1-git-send-email-Waiman.Long@hpe.com> <1463534783-38814-3-git-send-email-Waiman.Long@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1463534783-38814-3-git-send-email-Waiman.Long@hpe.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 May 2016, Waiman Long wrote: >Without using WRITE_ONCE(), the compiler can potentially break a >write into multiple smaller ones (store tearing). So a read from the >same data by another task concurrently may return a partial result. >This can result in a kernel crash if the data is a memory address >that is being dereferenced. > >This patch changes all write to rwsem->owner to use WRITE_ONCE() >to make sure that store tearing will not happen. READ_ONCE() may >not be needed for rwsem->owner as long as the value is only used for >comparison and not dereferencing. > >Signed-off-by: Waiman Long Yes, ->owner can obviously be handled locklessly during optimistic spinning. Acked-by: Davidlohr Bueso