From patchwork Thu Sep 21 20:57:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9964817 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 2FFF26056A for ; Thu, 21 Sep 2017 21:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AF0726D05 for ; Thu, 21 Sep 2017 21:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F9F829390; Thu, 21 Sep 2017 21:00:52 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 A240E26D05 for ; Thu, 21 Sep 2017 21:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751898AbdIUU7k (ORCPT ); Thu, 21 Sep 2017 16:59:40 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34133 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751838AbdIUU7K (ORCPT ); Thu, 21 Sep 2017 16:59:10 -0400 Received: by mail-pf0-f195.google.com with SMTP id g65so2925790pfe.1; Thu, 21 Sep 2017 13:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2dFjCY2N9faWUqJ6nmOT5NkSAnQFcCYJ47bQzfLDj9s=; b=UNoCwr1FKHbL6LoRONR8j3WnC7e1TnMovSWDI6Gmw6hhoF7ndgh1+xgeTR9imKkvnR lqrhrxH4ib9a7L2yLslllYgw9WMksKbE+t+jwQL+X/HG4XiOB8aSpwZmQew3TYZCm3Tc aSHlCcy90phTkAt2iT4aNgtYfqM4EiA7GVphcEGmGiLmnQE8Lgx6CEnlvOcK+25Y3L37 r63rA9yRYUBtQipUWAy+sF75nuKv9f38BGZCtZ/wpDwdmxVKYh9QZBDQ/wQftrEOJucI 091YBiiOKv+tuvUTPAxexzizXLMjv98UrUQGZe+2hIsrqvMq8oWhxPZJJXUq4I3P61k0 /5lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2dFjCY2N9faWUqJ6nmOT5NkSAnQFcCYJ47bQzfLDj9s=; b=PitaA5KMOUXleU2BOxFnXXYcPSu4Uvc/Lez5p9/2rbOQdStoiV1qABpQ7sdN9JkQ+I TOs5yTXiS1KaiJtmNmR7tp0nF8CFf0lNekvVVWSdk2ztUoffTt/tFtbNxcHJ5fmJE++n xU6hUnvSQlenSf0gufHwWWXjmQRdvIs4m2woewv/1NsjPSn1Bw/50nfyys7D5x2H3W5L 06S/BjYiGRYTpbb3S2UqA5TwM+fDyLZzfz1smwqD4O932BQuS5SmElWV8xSdTEcZTZYZ dbFEPp78I+fAcwmiIaKYxeSjo7MSMnkxsj4IyhSX7nynpqaBafiC4qVvAxRDispboCqZ HCKw== X-Gm-Message-State: AHPjjUjbseZVzK9z4P+Uuu5ky18XmA1JQAQfs1kKriZoanvjWRIigkHa d/KaLSLYySaO8y9wSFHE1Zq1ILthwUo= X-Google-Smtp-Source: AOwi7QAnm+qk9VuHGy50hKElTG4AbyYQcBuJnSGb/g72g0AMlQXNgUVJH0YkqceIku5udVIp2Lfo+A== X-Received: by 10.99.185.86 with SMTP id v22mr7275617pgo.236.1506027549424; Thu, 21 Sep 2017 13:59:09 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id k13sm3488028pgo.51.2017.09.21.13.59.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Sep 2017 13:59:08 -0700 (PDT) From: Eric Biggers To: keyrings@vger.kernel.org Cc: David Howells , Michael Halcrow , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH v2 2/3] KEYS: don't revoke uninstantiated key in request_key_auth_new() Date: Thu, 21 Sep 2017 13:57:41 -0700 Message-Id: <20170921205742.144596-3-ebiggers3@gmail.com> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog In-Reply-To: <20170921205742.144596-1-ebiggers3@gmail.com> References: <20170921205742.144596-1-ebiggers3@gmail.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers If key_instantiate_and_link() were to fail (which fortunately isn't possible currently), the call to key_revoke(authkey) would crash with a NULL pointer dereference in request_key_auth_revoke() because the key has not yet been instantiated. Fix this by removing the call to key_revoke(). key_put() is sufficient, as it's not possible for an uninstantiated authkey to have been used for anything yet. Fixes: b5f545c880a2 ("[PATCH] keys: Permit running process to instantiate keys") Signed-off-by: Eric Biggers --- security/keys/request_key_auth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index 8f12645945ca..2df92b619a38 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c @@ -220,7 +220,6 @@ struct key *request_key_auth_new(struct key *target, const void *callout_info, return authkey; error_put_authkey: - key_revoke(authkey); key_put(authkey); error_free_rka: free_request_key_auth(rka);