Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp234508ybe; Mon, 2 Sep 2019 00:15:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1SOwDIFZ/jISxv6stH+PFdrazy7zLLu5DQAybexCVDM4InEJtujjq6LmTpynDL1RLWqaD X-Received: by 2002:a63:1f1f:: with SMTP id f31mr21364678pgf.353.1567408545891; Mon, 02 Sep 2019 00:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567408545; cv=none; d=google.com; s=arc-20160816; b=mGGrSQqnLhRGZmvB2/lf5CQd8G5BSiVkkudkwJctDzXqBuBhp4Dqzz7cljMUHgLFQK PPVU9W1ypFIPbZiN9CXjZhOE34niEgQvqwKJhl5qkkHxaiFEzqw6urmzkiihpkSU0b9t 3uDTNAlFK+0/nS+40PxWPpcKesG/j2Fh+bdhayGudvf8XRqb6ZldJQLnnx59wwcmH9u1 5qFpsAYBWpA7jF8/DYOvm8LOoL8Jc4VydCOphwv9Inbt/olz8woUvN9GYuVuJaVu5RR5 I5tWBgM6NQRllRYqFmNH2EZFwOz2WWZeilQQyYzMNT51DxK6tMj0w210w/8HS7y5N78U SnzQ== 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=U8NcbZ5w3x5jysWPM+kmGfaC25r0LhgjraEPldKaQgc=; b=g6HeK8mToP6hir6Xw0IhqVlLEh050JZjRCDKB0zroEtULXPEdnvLaaFLqN4NlMqgSU 13VnA1DBer6mRu+ntHZ6yb6Xw6w65VLzvwfuPXjY08mUUAuVc2J8Vo/hN+M4Q1OGVAAs RRclT2ZocCq1FdgH2RJ3LmLAf6ulW+sXm3G7u16iQU/jTuTx3e3wz/WEInVY//x8XbOe n6rs7pDhovtrCv1DkxbSo11PgTvm4C8orxFKushGTBVyw/+HcjFvvc7AOa+XlooLNPLI lGYdOA1gfE6SwFCMIZ7S7+FidLdCgTxZ/iXferyjPJk3ZCmfLwEJKIdA2f8PFdXaHQ3e UxBQ== 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 a203si6303277pfa.82.2019.09.02.00.15.30; Mon, 02 Sep 2019 00:15:45 -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 S1729671AbfIBHOS convert rfc822-to-8bit (ORCPT + 99 others); Mon, 2 Sep 2019 03:14:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729330AbfIBHOS (ORCPT ); Mon, 2 Sep 2019 03:14:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 506FA81F1B; Mon, 2 Sep 2019 07:14:17 +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 0256360920; Mon, 2 Sep 2019 07:14:15 +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: <11986.1567178014@warthog.procyon.org.uk> References: <11986.1567178014@warthog.procyon.org.uk> <85B7196E-D717-4F19-A7E8-82A18287A3DE@linux.vnet.ibm.com> To: Hillf Danton Cc: dhowells@redhat.com, Sachin Sant , 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: <760.1567408455.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Mon, 02 Sep 2019 08:14:15 +0100 Message-ID: <761.1567408455@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 02 Sep 2019 07:14:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hillf, Would you like to me to put you down as the author of this patch? If so, I'll need a Signed-off-by from you. 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 Tested-by: Sachin Sant 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;