Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp864428ybl; Fri, 30 Aug 2019 08:14:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyc46mf3m2+BbzkmMjmEazVpJPPs19WDADoBTXOEhQTyFw1MnmncKee5sFdseRHIZtbMpbH X-Received: by 2002:aa7:8a0a:: with SMTP id m10mr19251559pfa.100.1567178079650; Fri, 30 Aug 2019 08:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567178079; cv=none; d=google.com; s=arc-20160816; b=CFmgM3REDn0DRSIuCDVhQd0KNhPzztGj17HMwFotWVtPr0v6emgzky0OFwmc1GFRBG P6TXWR0P6bLcrU6ngPLRrjMmC+o/FlOHK7pxUz4C3uiQKVgL01j5sM4Jl9im+5qE8oXN J+NPN08CkA7/UXJGjsYU9uc+7jKsJunHbVxjZcFK9QNO6YI4GX7flp0cVaBSAUslEgjy n6vzwqh3zjRVDbmEY1kR6gvXrBTYdPZguP/xqd08BBvMrJ5F/aT9I2APumsnYO1jHHIf hUHdAdCQ6WIFy7qSwAuHHIqyv5zQrwU24k48PGxkQoNvokmS2jxcN+WJPWhcvq1zCKXU d2Yg== 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:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization; bh=TFLV38C17bMg2d9PzRidjlbPRpcRrGTN8M2Xzjf7mcg=; b=Tz7F0mQ/4JXW1Da3Mpj9QAn0cEEc4BgsiwO67rVgHHeJGZjmJGTGTWhAT5JXUHH7Xu EZ59Rq3M+F2U+CloShTYHeBgnSlY9OELFghiCReOcJMsXPwQzCLWl50C2QTH8RoqTZsP 0LMX4rq33XH/JsFvYS0kKci/hhNOqw09c78AjTys2Max48mk6Wat3as2cvfLsH2kuYvb dtc8hR47YEGbCLL5TBxVIXKKKWHbGIhfq3iVVapbfcpsarmQRDjQDoTnX8r4/LxQUmVP jfDIIz8r6V0SL0hLxuGvnD6BPOyb3854TIB2aR4kfSHOU/m+TsZfZgx6fmGk5iYKHsgw Yzvg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si4625100pgi.450.2019.08.30.08.14.24; Fri, 30 Aug 2019 08:14:39 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728151AbfH3PNh convert rfc822-to-8bit (ORCPT + 99 others); Fri, 30 Aug 2019 11:13:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43354 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727891AbfH3PNg (ORCPT ); Fri, 30 Aug 2019 11:13:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95434308FEC1; Fri, 30 Aug 2019 15:13:36 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-255.rdu2.redhat.com [10.10.120.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47D8E60BE1; Fri, 30 Aug 2019 15:13:35 +0000 (UTC) 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 From: David Howells In-Reply-To: <85B7196E-D717-4F19-A7E8-82A18287A3DE@linux.vnet.ibm.com> References: <85B7196E-D717-4F19-A7E8-82A18287A3DE@linux.vnet.ibm.com> To: Sachin Sant Cc: dhowells@redhat.com, Hillf Danton , linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org, keyrings@vger.kernel.org Subject: Re: Oops (request_key_auth_describe) while running cve-2016-7042 from LTP MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11985.1567178014.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Fri, 30 Aug 2019 16:13:34 +0100 Message-ID: <11986.1567178014@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 30 Aug 2019 15:13:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Can you try this patch instead of Hillf's? David --- commit df882ad6d4e24a3763719c1798ea58e87d56c2d7 Author: Hillf Danton Date: Fri Aug 30 15:54:33 2019 +0100 keys: Fix missing null pointer check in request_key_auth_describe() If a request_key authentication token key gets revoked, there's a window in which request_key_auth_describe() can see it with a NULL payload - but it makes no check for this and something like the following oops may occur: BUG: Kernel NULL pointer dereference at 0x00000038 Faulting instruction address: 0xc0000000004ddf30 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP [...] request_key_auth_describe+0x90/0xd0 LR [...] request_key_auth_describe+0x54/0xd0 Call Trace: [...] request_key_auth_describe+0x54/0xd0 (unreliable) [...] proc_keys_show+0x308/0x4c0 [...] seq_read+0x3d0/0x540 [...] proc_reg_read+0x90/0x110 [...] __vfs_read+0x3c/0x70 [...] vfs_read+0xb4/0x1b0 [...] ksys_read+0x7c/0x130 [...] system_call+0x5c/0x70 Fix this by checking for a NULL pointer when describing such a key. Also make the read routine check for a NULL pointer to be on the safe side. Fixes: 04c567d9313e ("[PATCH] Keys: Fix race between two instantiators of a key") Reported-by: Sachin Sant Signed-off-by: David Howells diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index e73ec040e250..ecba39c93fd9 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c @@ -66,6 +66,9 @@ static void request_key_auth_describe(const struct key *key, { struct request_key_auth *rka = dereference_key_rcu(key); + if (!rka) + return; + seq_puts(m, "key:"); seq_puts(m, key->description); if (key_is_positive(key)) @@ -83,6 +86,9 @@ static long request_key_auth_read(const struct key *key, size_t datalen; long ret; + if (!rka) + return -EKEYREVOKED; + datalen = rka->callout_len; ret = datalen;