Received: by 10.223.185.116 with SMTP id b49csp4081315wrg; Tue, 6 Mar 2018 09:29:28 -0800 (PST) X-Google-Smtp-Source: AG47ELsAB8evmrSTrO9bexUnKQhp/7fU/cqjjHp06fqHdoj7RAxKL5kQWYP8oD7fr+B88ah2zPYd X-Received: by 10.98.62.14 with SMTP id l14mr19808773pfa.206.1520357368654; Tue, 06 Mar 2018 09:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520357368; cv=none; d=google.com; s=arc-20160816; b=NenqNATvFcIrrs23QyxpfcXd6+HGOJ3DfAlowc2z/EqcWsvIMS0qOJw/CZZBuKFDU+ u+vHPrcEQg4BODYrWpjR7IJqeAgygNnapI3ZpMAu7+DSiYzNhoXrsymRM2PxJ1rdTr0p kKuSHQC06XtgcC2S04L3PiprSz/CGs7Op8FBsjXQKsDtQeJzFFsNL5Wu05lDYQM0H4bZ 1UXWF2l7IfN14uIJ6eHIJtUvkEjYmuX77GP5EfXPh3s4YuyQ/1PVwxgDq717c7uz4ogU sbt+2p2FDMaFcCE1wDnIqiQMU/hFLBvqWEQGRMOtEbcKLi4ITXu6N3u7CcTWVZddl6ML flXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lEZC/w/RiKT3EeWuSZhdzLiS3CqbZloT0713vm1tHEQ=; b=vH3yVhtonJAl4ZXcawogHyCLnaCpk93rRVQRZBpArI0iGqK0fsUYgdDfalRaBt/6bb LSYn4YdPm8kWvowUNLXkB0boKExDVf8UEYy5m9ACu0prBku0t8mOGMObvOAPjD4/BbTP MDLP6DnBAwJU+MIJ9kWylwv1qDSwQIyfn9BhfUtQqHwjMFC4g2bdD5hjqrcwFr2pjwSB BvI60JpEs5ZibBziq8dxjN6NLP3278Z1m+b8iwPQCYTprbl7u/2HWeL+fIbNKCzoXg02 GSyMSWZmzMHiFcWQXwcGq3wc+yt/fOFBdlxPlhyDXdVi/WyeB1Zv8TzDbpTOGfObS5FT bFlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GCxJ8tG7; 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 x61-v6si11273730plb.741.2018.03.06.09.29.14; Tue, 06 Mar 2018 09:29:28 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GCxJ8tG7; 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 S1754053AbeCFR1W (ORCPT + 99 others); Tue, 6 Mar 2018 12:27:22 -0500 Received: from mail-yb0-f195.google.com ([209.85.213.195]:44655 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753070AbeCFR1U (ORCPT ); Tue, 6 Mar 2018 12:27:20 -0500 Received: by mail-yb0-f195.google.com with SMTP id h19-v6so7347773ybj.11 for ; Tue, 06 Mar 2018 09:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=lEZC/w/RiKT3EeWuSZhdzLiS3CqbZloT0713vm1tHEQ=; b=GCxJ8tG74A5D9nFelxf8zKhPXacF7jIibip1qZqiPzxF8H638UdsMfBK+lzSRgyPJX q1UHGKExFHjttiKFUE4dhKH9bUnEsI40cc5UhSyV90587tMnqRpJcrYUMYxz3M+lINRP unyFkeFAHpXRtk6aTodFL5mxHiPuptkPoqUOXz7l4pwoAedNBsZi7M5uYfQMT1WJNA8U WqclP8waXkb3Xl2ZMmrXbzIXMDoQB87TFeVuPDeD9Y4GowwTU0N0cw3uyY20491ceRmZ IdCifctd9wj3LxkWzzBM9jrNRC2fZIgzOZJ20pbjK281yM9Dxfspx0rCuv5t8RH1CD+g 3xGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=lEZC/w/RiKT3EeWuSZhdzLiS3CqbZloT0713vm1tHEQ=; b=q9pb717NW40RNT8ZiHjjEefy7h0IvmoiLglk6ddjtg5BDogVmQH8B3sMp7LFzw4LPq r3h04IMXeGLU4euW0XR8jfFaMsKhKiQav0zvWoruPmg3dat7Y3bKzJgURmrNEJ7j59+a szGx/GQLbpKQgyaol+7N1ciZfSN+lN1Zj8CB7mF2Nvuthj0t5fEeVhkr9Fb2G61sP1Hv CJkWDXLqGYC9iYOE/TixFnTFdYycrqYR4SZSa9hJkfC/x8tYn9RRpVCF/jW5bFRWdyT7 UPfPdIDcOVJfbJ9xo+RBVdPVh1U5OI/FvaRxKp+fKpLk1w8y4nGT+V+4YpuhuPcAmO37 iCJQ== X-Gm-Message-State: AElRT7H8SJ3Ta+PlaqQth0rEVtIeU0XNoUBSt520uVGdpZPfuynx2oGY WNuVTV32MuuxuTnhA0z5r2g= X-Received: by 2002:a25:c3c2:: with SMTP id t185-v6mr6737187ybf.487.1520357239474; Tue, 06 Mar 2018 09:27:19 -0800 (PST) Received: from localhost ([2620:10d:c091:180::1:af9]) by smtp.gmail.com with ESMTPSA id l134sm6101185ywe.103.2018.03.06.09.27.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 09:27:18 -0800 (PST) From: Tejun Heo To: torvalds@linux-foundation.org, jannh@google.com, paulmck@linux.vnet.ibm.com, bcrl@kvack.org, viro@zeniv.linux.org.uk, kent.overstreet@gmail.com Cc: security@kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCHSET] percpu_ref, RCU: Audit RCU usages in percpu_ref users Date: Tue, 6 Mar 2018 09:26:50 -0800 Message-Id: <20180306172657.3060270-1-tj@kernel.org> X-Mailer: git-send-email 2.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Jann Horn found that aio was depending on the internal RCU grace periods of percpu-ref and that it's broken because aio uses regular RCU while percpu_ref uses sched-RCU. Depending on percpu_ref's internal grace periods isn't a good idea because * The RCU type might not match. * percpu_ref's grace periods are used to switch to atomic mode. They aren't between the last put and the invocation of the last release. This is easy to get confused about and can lead to subtle bugs. * percpu_ref might not have grace periods at all depending on its current operation mode. This patchset audits all percpu_ref users for their RCU usages, clarifies percpu_ref documentation that the internal grace periods must not be depended upon, and introduces rcu_work to simplify bouncing to a workqueue after an RCU grace period. This patchset contains the following seven patches. 0001-fs-aio-Add-explicit-RCU-grace-period-when-freeing-ki.patch 0002-fs-aio-Use-RCU-accessors-for-kioctx_table-table.patch 0003-RDMAVT-Fix-synchronization-around-percpu_ref.patch 0004-HMM-Remove-superflous-RCU-protection-around-radix-tr.patch 0005-block-Remove-superflous-rcu_read_-un-lock_sched-in-b.patch 0006-percpu_ref-Update-doc-to-dissuade-users-from-dependi.patch 0007-RCU-workqueue-Implement-rcu_work.patch 0001-0003 are fixes and tagged -stable. 0004-0005 remove (seemingly) superflous RCU read lock usages. 0006 updates the doc and 0007 introduces rcu_work. This patchset is also available in the following git tree. git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git percpu_ref-rcu-audit diffstat follows. Thanks. block/blk-core.c | 2 - drivers/infiniband/sw/rdmavt/mr.c | 10 ++++--- fs/aio.c | 39 ++++++++++++++++----------- include/linux/cgroup-defs.h | 2 - include/linux/percpu-refcount.h | 18 ++++++++---- include/linux/workqueue.h | 38 ++++++++++++++++++++++++++ kernel/cgroup/cgroup.c | 21 ++++---------- kernel/workqueue.c | 54 ++++++++++++++++++++++++++++++++++++++ lib/percpu-refcount.c | 2 + mm/hmm.c | 12 +------- 10 files changed, 145 insertions(+), 53 deletions(-) -- tejun