From patchwork Tue Oct 4 13:37:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Savkov X-Patchwork-Id: 9361879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FAD2600C8 for ; Tue, 4 Oct 2016 13:38:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32DAC284C7 for ; Tue, 4 Oct 2016 13:38:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2768528765; Tue, 4 Oct 2016 13:38:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3959284C7 for ; Tue, 4 Oct 2016 13:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752452AbcJDNiA (ORCPT ); Tue, 4 Oct 2016 09:38:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52142 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbcJDNiA (ORCPT ); Tue, 4 Oct 2016 09:38:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A30479719; Tue, 4 Oct 2016 13:37:59 +0000 (UTC) Received: from shodan.usersys.redhat.com (dhcp-1-150.brq.redhat.com [10.34.1.150]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u94Dbw90021389; Tue, 4 Oct 2016 09:37:58 -0400 Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id CCA722C0379; Tue, 4 Oct 2016 15:37:57 +0200 (CEST) From: Artem Savkov To: linux-nfs@vger.kernel.org Cc: dhowells@redhat.com, trond.myklebust@primarydata.com, anna.schumaker@netapp.com, linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH] Fix suspicious RCU usage in nfs_idmap_get_key. Date: Tue, 4 Oct 2016 15:37:40 +0200 Message-Id: <1475588260-10838-1-git-send-email-asavkov@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 04 Oct 2016 13:37:59 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nfs_idmap_get_key doesn't hold rkey->sem when calling user_key_payload resulting in a "suspicious RCU usage" lockdep splat. It does, however hold rcu_read_lock, so it either needs to use unprotected rcu_dereference, or take rkey->sem instead of rcu_read_lock. Signed-off-by: Artem Savkov --- fs/nfs/nfs4idmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index c444285..a67d1c0 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -309,7 +309,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, goto out; } - rcu_read_lock(); + down_read(&rkey->sem); rkey->perm |= KEY_USR_VIEW; ret = key_validate(rkey); @@ -329,7 +329,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, ret = -EINVAL; out_up: - rcu_read_unlock(); + up_read(&rkey->sem); key_put(rkey); out: return ret;