From patchwork Fri Nov 14 14:06:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 5306711 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 17733C11AC for ; Fri, 14 Nov 2014 14:06:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E27620142 for ; Fri, 14 Nov 2014 14:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64A5D20123 for ; Fri, 14 Nov 2014 14:06:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755075AbaKNOGl (ORCPT ); Fri, 14 Nov 2014 09:06:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52016 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755072AbaKNOGk (ORCPT ); Fri, 14 Nov 2014 09:06:40 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAEE6XFT022219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 14 Nov 2014 09:06:34 -0500 Received: from warthog.procyon.org.uk ([10.3.112.3]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAEE6TU1009747; Fri, 14 Nov 2014 09:06:30 -0500 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 2/3] KEYS: When searching a keyring, restore KEYRING_SEARCH_DO_STATE_CHECK From: David Howells To: chuck.lever@oracle.com Cc: dhowells@redhat.com, neilb@suse.de, linux-nfs@vger.kernel.org, keyrings@linux-nfs.org Date: Fri, 14 Nov 2014 14:06:29 +0000 Message-ID: <20141114140629.2927.82977.stgit@warthog.procyon.org.uk> In-Reply-To: <20141030174612.10093.61557.stgit@manet.1015granger.net> References: <20141030174612.10093.61557.stgit@manet.1015granger.net> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When searching a keyring or iterating over all the contents of a keyring, we set KEYRING_SEARCH_DO_STATE_CHECK before checking the root keyring so that the iterator function will ensure that we have permission to search that keyring. However, we should restore the value of the flag afterwards as it will otherwise affect all other keys checked by the iterator. Signed-off-by: David Howells --- security/keys/keyring.c | 2 ++ 1 file changed, 2 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 8177010174f7..f44b3a8d605a 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -636,6 +636,7 @@ static bool search_nested_keyrings(struct key *keyring, */ if (ctx->match_data.lookup_type == KEYRING_SEARCH_LOOKUP_ITERATE || keyring_compare_object(keyring, &ctx->index_key)) { + unsigned long saved_flags = ctx->flags; ctx->skipped_ret = 2; ctx->flags |= KEYRING_SEARCH_DO_STATE_CHECK; switch (ctx->iterator(keyring_key_to_ptr(keyring), ctx)) { @@ -644,6 +645,7 @@ static bool search_nested_keyrings(struct key *keyring, case 2: return false; default: + ctx->flags = saved_flags; break; } }