Received: by 10.223.185.116 with SMTP id b49csp2300560wrg; Thu, 15 Feb 2018 09:28:59 -0800 (PST) X-Google-Smtp-Source: AH8x227pj/6KazIzEA446hSbo2QbM3ozxi8OYkDqPmavnw/9HXnN+H86J22PumP7qt/z2GbbvS+y X-Received: by 2002:a17:902:6b82:: with SMTP id p2-v6mr3251357plk.30.1518715739303; Thu, 15 Feb 2018 09:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518715739; cv=none; d=google.com; s=arc-20160816; b=rSxd40DEbUriJQcO0CX+UdaZtdF/sKmoExIh9NBG/pJUVo+V0v5BuIOIsLkkf0c3+L iTNlktFFbrpevXtmAKFdrabeas7Mi/tIQIOrRY7X8PCgtwqzBnxTvkE4IY1Z1o8i8uQA /RBgCzxzxEcUQ7h39RaQ3xo9k2tpHhG9bKHjh/4J+V7DNJzB2swmTip+/eIZXIpM3rOA wk85Eg9ix7yKyii7ABRZlTrIGv2lvz2tGltewFUlmDA43OLVLUZZB9A77bIyKvX2rVc4 JYebRJIFj3+MFCTpGfT+BPxHLNwzqe2orQXDmLu80dWx2Q1ZqAulwS9Qd6hWD8qJuoPe sA1g== 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=dmLHSof0MU7t2Dgnnnc5NO1RZrFsWHe0p3yWmh8f4yY=; b=wZlucThoI5CpBAFzqU1aHVnZtx1UVM4mEuuA89D2KsOJ7JCClKL/2FjX/fLyHtxvgH Wiv/f8pUqsjj+kPndO3B1x9yqcLhZdVm3OV9mzL6+SU2JvQeeFt6yEpvvor6RnpFrSGj SHpKLXer6GwNb1YvDhUAyq6/hwUnKQ0UXZseGXzEfnU289kAijLNohPLBYXRSp7dusxe h74BgfMemRM/lwzgbsUGMDxVMQMTfsutANoOVfJ1wH+TW0jFQHCDbAF/5kk8xv3zci94 DWpg9uhHQFiy9YOJsmiFxIBJkxkOQvuDC5ypzIFSjEmrrSd8YiYnwzdCf3k5CuwvxE2n IWyg== 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 a23si1477958pff.83.2018.02.15.09.28.44; Thu, 15 Feb 2018 09:28:59 -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 S1165203AbeBOR1E (ORCPT + 99 others); Thu, 15 Feb 2018 12:27:04 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57144 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165080AbeBOPeX (ORCPT ); Thu, 15 Feb 2018 10:34:23 -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 3F7B010D2; Thu, 15 Feb 2018 15:34:22 +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.14 108/195] NFS: reject request for id_legacy key without auxdata Date: Thu, 15 Feb 2018 16:16:39 +0100 Message-Id: <20180215151711.089553032@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@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.14-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;