From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753767Ab3FYSv5 (ORCPT ); Tue, 25 Jun 2013 14:51:57 -0400 Received: from mail-qa0-f53.google.com ([209.85.216.53]:37398 "EHLO mail-qa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753082Ab3FYSvw (ORCPT ); Tue, 25 Jun 2013 14:51:52 -0400 Date: Tue, 25 Jun 2013 11:51:46 -0700 From: Tejun Heo To: "Paul E. McKenney" , Dipankar Sarma Cc: Fengguang Wu , "David S. Miller" , Li Zefan , Patrick McHardy , linux-kernel@vger.kernel.org Subject: Re: [PATCH] rculist: list_first_or_null_rcu() should use list_entry_rcu() Message-ID: <20130625185146.GE20051@mtj.dyndns.org> References: <20130621003244.GD11837@mtj.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130621003244.GD11837@mtj.dyndns.org> 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 On Thu, Jun 20, 2013 at 05:32:44PM -0700, Tejun Heo wrote: > list_first_or_null() should test whether the list is empty and return > pointer to the first entry if not in a RCU safe manner. It's broken > in two ways. > > * It compares __kernel @__ptr with __rcu @__next triggering the > following sparse warning. > > net/core/dev.c:4331:17: error: incompatible types in comparison expression (different address spaces) > > * It doesn't perform rcu_dereference*() and computes the entry address > using container_of() directly from the __rcu pointer which is > inconsitent with other rculist interface. As a result, all three > in-kernel users - net/core/dev.c, macvlan, cgroup - are buggy. They > dereference the pointer w/o going through read barrier. > > Fix it by making list_first_or_null_rcu() dereference ->next directly > and then use list_entry_rcu() on it like other rculist accessors. > > Signed-off-by: Tejun Heo > Reported-by: Fengguang Wu > Cc: Dipankar Sarma > Cc: "Paul E. McKenney" > Cc: "David S. Miller" > Cc: Li Zefan > Cc: Patrick McHardy > Cc: stable@vger.kernel.org Paul, ping. -- tejun