Received: by 10.223.185.116 with SMTP id b49csp694290wrg; Fri, 16 Feb 2018 05:49:14 -0800 (PST) X-Google-Smtp-Source: AH8x227BHxO3l7GuuATCORnH0aUQalDZl7GSxjeZbvLs+oVaS8doJxr8GHvo0LmbWYUH8WlGqgKw X-Received: by 2002:a17:902:aa8c:: with SMTP id d12-v6mr6003078plr.39.1518788954320; Fri, 16 Feb 2018 05:49:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518788954; cv=none; d=google.com; s=arc-20160816; b=bIFW8K5C12ksffhSrSTTO8dSlydrqUD8LZ/F28R7AQeqcPsdwDwaseYJK7ztI76eBF ymwEtCHT8GaxniKv5DlSS0tdY8f8mnoQkm/fiHhsLhtIrQZpbIbe+Lrt2uCVEKKZ1VVN lgXLCovOsSKe4H7wwivRUOPJo1SqSS42429u4gvBW5lDO4A8N5IpRZ3QmY5X0VkCxQW6 GIc6NSlwrG9vqRmmL9aIETr1pqtI7PX0kb0/Q+VLCEH8MGFIXkdIjR9PHvcF3YsEzbXG Vq8NzpopYRdPkaDaKSkZcz7250Qf24uhqDLy4AhfDcriXBERJwz7d7CdM4Hc8IM6hpH5 Ka9g== 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=h8/93a9l6SGcvV2nPhNCViY5klugKvxw4DvcbYxa5y0=; b=vYLWlp/iHbDHAIfH0idyQfY/15fcgsisgG9rxKTjpyimBt5xmMlVYnN4eAhNAp82Nk FMHOZYkPsFOXgB0leWTHqMitoPJli8koDmb950Qkz+ZBxCsreiQqgwE6zttfE8o7+Uib t9m6Ws57cP7XTTpjZy+1PyEM7bRvfCVKWxCQ03glT22+meZxl8W+PM95EP3uhvhtcfX6 6ILaWrK41i/z1gklBlzp3nopbHGqF8mxdNSMo7iK0uuZy+zfA7Oe2jKXWKRsm5k1Wns4 fm0FHcJXjYcI5NCUvGl9NZtxqWfc9ppvSw8V8R0r/VYqm3YqHpPRXE94V0M1ArL0ba8q 1zpg== 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 94-v6si4256290pla.215.2018.02.16.05.48.59; Fri, 16 Feb 2018 05:49:14 -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 S1166814AbeBOSmw (ORCPT + 99 others); Thu, 15 Feb 2018 13:42:52 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51124 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162659AbeBOPX1 (ORCPT ); Thu, 15 Feb 2018 10:23:27 -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 CD6E5ECC; Thu, 15 Feb 2018 15:23:08 +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.4 062/108] NFS: reject request for id_legacy key without auxdata Date: Thu, 15 Feb 2018 16:16:59 +0100 Message-Id: <20180215151231.080026460@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@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.4-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 @@ -567,9 +567,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;