Received: by 10.223.185.116 with SMTP id b49csp2230129wrg; Thu, 15 Feb 2018 08:26:44 -0800 (PST) X-Google-Smtp-Source: AH8x2251KtzdPWOKQx8Y4eXRmjk9tdX4jF1KG5q2A2NesOE3ejdU05GAf/ndNkBqWNd3/BUOSB5t X-Received: by 10.98.52.194 with SMTP id b185mr3149552pfa.216.1518712004831; Thu, 15 Feb 2018 08:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518712004; cv=none; d=google.com; s=arc-20160816; b=XwTo+ozR/OA32knOoP4/Jp/OeLd5+mgaB49lKyzvv1UrU/mtFFkgwz8ymv/jvugafq MheDFXjaLLrdL7zFOq7/iW+v6V46ngwCLUly9FgO/l8+WdACVOyJxwkTb67+ImTZXVnK FVFOXEj6Ma0TtrB4rCIYrjIfjvFQ23pjsM+yYE9NAFiIM2IB19aSK2EkN96O9C3GSI1h Qkud1L0jAZBl5gZAs44iYRaeQ8xn+OFyD+i653fmqd4+sB6eDSMe6OcRzVkGhzWLGYdA sJrYrVXLk3272gADZo6jSt0l84yKHRPAfTas7D8tn16r00a/1/Nx8dIu1pRTDzKyiw2r a0gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=PEnAaVQIXDOaOAZcQT5TDwMV2FklhWaVwpNHFRWWbYQ=; b=eayx0WiB/rCDpvNr0+XdEdkfO75W4AdqTMWjN3NZbbD6oO0eGqRBQMdbO1UDD9jqqT WWmx64VZCNTIfMERSfIQrz1NFW8JF5qkpR/I308PrPUGSZZNqy2DGUQcqgUUkSId1Fl9 KLPzoJBnc1ZVJ401uFGJVAihPrMnF4YUqvYJm0DSh+LdSKA4sRkoYCT+ouAeHXP84j6O g+zAZaqnHksO7sovymjNRZR/rU3XFIaCXguIswH1z/QVFcLWBAmGKKgvNHxFdNFZdsUr FDJVB8SLuqbVDW2sG157puoZtRHOQeaEkSLCu3r5IIreHF9MXrFNBe681H1OiHVwDGy1 FEQg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19si1827018pfi.313.2018.02.15.08.26.30; Thu, 15 Feb 2018 08:26:44 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033970AbeBOPnN (ORCPT + 99 others); Thu, 15 Feb 2018 10:43:13 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33856 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033257AbeBOPnK (ORCPT ); Thu, 15 Feb 2018 10:43:10 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4DB0A1156; Thu, 15 Feb 2018 15:43:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+5dfdbcf7b3eb5912abbb@syzkaller.appspotmail.com, Eric Biggers , Trond Myklebust Subject: [PATCH 4.15 101/202] NFS: reject request for id_legacy key without auxdata Date: Thu, 15 Feb 2018 16:16:41 +0100 Message-Id: <20180215151718.592915136@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 49686cbbb3ebafe42e63868222f269d8053ead00 upstream. nfs_idmap_legacy_upcall() is supposed to be called with 'aux' pointing to a 'struct idmap', via the call to request_key_with_auxdata() in nfs_idmap_request_key(). However it can also be reached via the request_key() system call in which case 'aux' will be NULL, causing a NULL pointer dereference in nfs_idmap_prepare_pipe_upcall(), assuming that the key description is valid enough to get that far. Fix this by making nfs_idmap_legacy_upcall() negate the key if no auxdata is provided. As usual, this bug was found by syzkaller. A simple reproducer using the command-line keyctl program is: keyctl request2 id_legacy uid:0 '' @s Fixes: 57e62324e469 ("NFS: Store the legacy idmapper result in the keyring") Reported-by: syzbot+5dfdbcf7b3eb5912abbb@syzkaller.appspotmail.com Signed-off-by: Eric Biggers Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4idmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -568,9 +568,13 @@ static int nfs_idmap_legacy_upcall(struc struct idmap_msg *im; struct idmap *idmap = (struct idmap *)aux; struct key *key = cons->key; - int ret = -ENOMEM; + int ret = -ENOKEY; + + if (!aux) + goto out1; /* msg and im are freed in idmap_pipe_destroy_msg */ + ret = -ENOMEM; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) goto out1;