Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753978AbcJDNiq (ORCPT ); Tue, 4 Oct 2016 09:38:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36658 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753873AbcJDNin (ORCPT ); Tue, 4 Oct 2016 09:38:43 -0400 From: Artem Savkov To: dhowells@redhat.com Cc: linux-cachefs@redhat.com, linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH] Use proper lock in fscache_objlist_config. Date: Tue, 4 Oct 2016 15:38:30 +0200 Message-Id: <1475588310-10910-1-git-send-email-asavkov@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 04 Oct 2016 13:38:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1039 Lines: 34 fscache_objlist_config doesn't hold rkey->sem when calling user_key_payload, that can result in a "suspicious RCU usage" warning. It does 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/fscache/object-list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c index 5d5ddaa..26c20e9 100644 --- a/fs/fscache/object-list.c +++ b/fs/fscache/object-list.c @@ -327,7 +327,7 @@ static void fscache_objlist_config(struct fscache_objlist_data *data) goto no_config; config = 0; - rcu_read_lock(); + down_read(&key->sem); confkey = user_key_payload(key); buf = confkey->data; @@ -349,7 +349,7 @@ static void fscache_objlist_config(struct fscache_objlist_data *data) } } - rcu_read_unlock(); + up_read(&key->sem); key_put(key); if (!(config & (FSCACHE_OBJLIST_CONFIG_COOKIE | FSCACHE_OBJLIST_CONFIG_NOCOOKIE))) -- 2.7.4