Received: by 10.213.65.68 with SMTP id h4csp597219imn; Wed, 28 Mar 2018 09:12:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/u9Zu36y97/r6hOpdU06OJUxDXmuerFQwmzUxVJZ3ArxmHC+Fdg2foTTSuiKnI+DrtutCn X-Received: by 10.98.186.2 with SMTP id k2mr3463659pff.225.1522253529565; Wed, 28 Mar 2018 09:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522253529; cv=none; d=google.com; s=arc-20160816; b=VoNjFirB8rWxiuhI9L+eOlfAZXdjjvSCp4N/ExbOEjV5bk0EbRHZEixOt8JNacDbhp DVLsPQpoJ43HCxvWK0tZdVKiDZgVSe8Lji8BHgan+EqKRuhymz/4cIFJsudXUy0HwHAX rb3HB/STxxLwSvAYS3bW0i3vFwpd61xJy24nrBR3CO33NmdNPOpUVHAeTKqWUcZb3JwI SdXL5ahE3GvprsDu6zQmWpiFchaaZQVtbGc32uczZx7r2HGVZXG8GDc7wXBneEU2pt27 rZgvP20SyoMJovojPvdejyeO7se/BcHi0og3wtcKl96zIoLgwfJ7Q6f1dEApY4zi++rp 99Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=DWhuFPgZqyXrj68EbBjsfkDIhJi+KmG8GHLK4VDlTYY=; b=bdbn8bXSmswQ0CMHU9gzTLriftC4pKeieLCZXso53j8UMrh1om2Nw8Qun71FnyPO2u xXlAp9G4ITdeQThs8t8HkuGUvLRaMqKdsUIeq1JkIIJXOrjpIHR680ZzPpmrlsP9e0gc EW7ulMoTUwgUOeMEPUJ9Eun/YtvblbWWOY0gjAuEQBi3wYmyirSmyOssVa59m6g0leml sDDTKwu0MXYrelIZtIW0mJRDa3gp/PlEd2GG0LTzcYqBOF6euzjewlN2alJgykLs+eV+ XHINNsVG8px9jNx9gIb3ndL2vWcTKtkfDm57YX/c4/1hMfpssFQeul6JJafXAFovQALh LfBA== 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 b2si2653368pgq.646.2018.03.28.09.11.53; Wed, 28 Mar 2018 09:12:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754181AbeC1Pqc (ORCPT + 99 others); Wed, 28 Mar 2018 11:46:32 -0400 Received: from fieldses.org ([173.255.197.46]:59234 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753816AbeC1Pq2 (ORCPT ); Wed, 28 Mar 2018 11:46:28 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 69B2824CA; Wed, 28 Mar 2018 11:46:28 -0400 (EDT) Date: Wed, 28 Mar 2018 11:46:28 -0400 From: "J. Bruce Fields" To: Eric Biggers Cc: Michael Young , Herbert Xu , Jeff Layton , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: NFS mounts failing when keytab present on client Message-ID: <20180328154628.GA3038@fieldses.org> References: <20180327222950.GB257332@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180327222950.GB257332@google.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 03:29:50PM -0700, Eric Biggers wrote: > Hi Michael, > > On Tue, Mar 27, 2018 at 11:06:14PM +0100, Michael Young wrote: > > NFS mounts stopped working on one of my computers after a kernel update from > > 4.15.3 to 4.15.4. I traced the problem to the commit > > [46e8d06e423c4f35eac7a8b677b713b3ec9b0684] crypto: hash - prevent using > > keyed hashes without setting key > > and a later kernel with this patch reverted works normally. > > > > The problem seems to be related to kerberos as the mount fails when the > > keytab is present, but works if I rename the keytab file. This is true even > > though the mount is with sec=sys . The mount should also work with sec=krb5 > > but that also fails in the same way. When the mount fails there are errors > > in dmesg like > > [ 1232.522816] gss_marshal: gss_get_mic FAILED (851968) > > [ 1232.522819] RPC: couldn't encode RPC header, exit EIO > > [ 1232.522856] gss_marshal: gss_get_mic FAILED (851968) > > [ 1232.522857] RPC: couldn't encode RPC header, exit EIO > > [ 1232.522863] NFS: nfs4_discover_server_trunking unhandled error -5. > > Exiting with error EIO > > [ 1232.525039] gss_marshal: gss_get_mic FAILED (851968) > > [ 1232.525042] RPC: couldn't encode RPC header, exit EIO > > > > Michael Young > > Thanks for the bug report. I think the error is coming from > net/sunrpc/auth_gss/gss_krb5_crypto.c. There are two potential problems I see. > The first one, which is definitely a bug, is that make_checksum_hmac_md5() > allocates an HMAC transform and request, then does these crypto API calls: > > crypto_ahash_init() > crypto_ahash_setkey() > crypto_ahash_digest() > > This is wrong because it makes no sense to init() the HMAC request before the > key has been set, and doubly so when it's calling digest() which is shorthand > for init() + update() + final(). So I think it just needs to be removed. You > can test the following patch: When was this introduced? 3b5cf20cf439 "sunrpc: Use skcipher and ahash/shash" - probably not, assuming the above was still just as wrong with crypto_hash_{init,setkey,digest} as it is with crypto_ahash_{init,setkey,digest} So I'm guessing it was wrong from the start when it was added by fffdaef2eb4a "gss_krb5: Add support for rc4-hmac encryption" 8 years ago. Wonder why it took this long to notice? Did something else change? --b. > > diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c > index 12649c9fedab..8654494b4d0a 100644 > --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c > +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c > @@ -237,9 +237,6 @@ make_checksum_hmac_md5(struct krb5_ctx *kctx, char *header, int hdrlen, > > ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); > > - err = crypto_ahash_init(req); > - if (err) > - goto out; > err = crypto_ahash_setkey(hmac_md5, cksumkey, kctx->gk5e->keylength); > if (err) > goto out; > > If that's not it, it's also possible that the error is coming from the > crypto_ahash_init() in make_checksum(). That can only happen if 'cksumkey' is > NULL and the hash algorithm is keyed, which implies a logical error as it > doesn't make sense to use a keyed hash algorithm without the key. The callers > do check kctx->gk5e->keyed_cksum which I'd hope would prevent this, though > perhaps kctx->cksum can be NULL. > > Eric