Received: by 10.213.65.68 with SMTP id h4csp179191imn; Wed, 28 Mar 2018 01:10:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+CAJ5lYXfWwB1qm4rrEO9GJFHgkkzU9SOuh2C5HoFuYLQlaGuSl6Mnj2WaaUR+wGHYo3Eg X-Received: by 10.99.127.89 with SMTP id p25mr1836178pgn.293.1522224604269; Wed, 28 Mar 2018 01:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522224604; cv=none; d=google.com; s=arc-20160816; b=tWY2WQ0sHY5woqK4wxVdyCU2rTckZkMh5DDDnFzToZVu5E2LPdv5utN7hF7zuzlJc0 cGzxbmsELait9s8vQcOoS7gRsKnHJWDPLZj3XhRM1AIZ9BGI4hCsK5LsXZ8lR+3vmU6W 6sKvkeXfolaq2Md4QPnzcCT38En3fHz624XTtQA8u+EP2XRfDylITADS8itBPstLL5Uq GTSxlJyhSDTa2F90ecTNmNMPJ+uLK9b/ltapHzXTqA/WieKHBOoy3bV53N6CvNoV7CMa 8xEni+QGhqqeXbyRMgRyc0+kTpTG3JX67KVAnc89cnnMNanJDUYkC6OYAU8yRsP7UHd1 k2ZQ== 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 :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=OEaHHz3s+4ZYeLvmxBCUil9P4swfwp0kv1dOO/zHMf8=; b=Qhr+A73ZD3mJEn+2k1tQldPB5ESGhaDh7fvYZcNmM2kgai6G5LX4Lhlb1LtIaC4lJl zkrccO3G/vlyGQWBAyjEGOxv+ilet+Km0/BUEj3pUrbT3MjnI8pYygKJ170oy51MkEZ2 h6HVHR5LcyVYAUUMqzqnqnT7EvHRlEt9eq/leweB0S1WwFD/iXtGtN2mxIwld7+oqgbK Ub0oZXt8HMEQuCWdXb1BmcD9b4slZjEbxjkR3TrBlzbumLERy6wO/Twl0TaP6g99tAdL J5YdCHlEqWyk+ilLFfrfenYeGvOggwPUWImcGmIrwQjPSv2cQxDfFk9kxjdQQlumKpkS xYpg== 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 m24si2132545pgn.21.2018.03.28.01.09.50; Wed, 28 Mar 2018 01:10:04 -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 S1752479AbeC1IId (ORCPT + 99 others); Wed, 28 Mar 2018 04:08:33 -0400 Received: from hermes2.dur.ac.uk ([129.234.7.139]:37676 "EHLO hermes2.dur.ac.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbeC1IIa (ORCPT ); Wed, 28 Mar 2018 04:08:30 -0400 X-Greylist: delayed 430 seconds by postgrey-1.27 at vger.kernel.org; Wed, 28 Mar 2018 04:08:29 EDT Received: from smtphost4.dur.ac.uk (smtphost4.dur.ac.uk [129.234.7.146]) by hermes2.dur.ac.uk (8.14.4/8.14.4) with ESMTP id w2S80RS3031317; Wed, 28 Mar 2018 09:00:31 +0100 Received: from algedi.dur.ac.uk (algedi.dur.ac.uk [129.234.2.28]) by smtphost4.dur.ac.uk (8.14.4/8.14.4) with ESMTP id w2S80J35003859; Wed, 28 Mar 2018 09:00:19 +0100 Received: by algedi.dur.ac.uk (Postfix, from userid 2742) id BBF2E2813C8; Wed, 28 Mar 2018 09:00:14 +0100 (BST) Received: from localhost (localhost [127.0.0.1]) by algedi.dur.ac.uk (Postfix) with ESMTP id 9D0BB280C8A; Wed, 28 Mar 2018 09:00:14 +0100 (BST) Date: Wed, 28 Mar 2018 09:00:14 +0100 (BST) From: M A Young To: Eric Biggers cc: Herbert Xu , "J. Bruce Fields" , 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 In-Reply-To: <20180327222950.GB257332@google.com> Message-ID: References: <20180327222950.GB257332@google.com> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-DurhamAcUk-MailScanner: Found to be clean, Found to be clean X-DurhamAcUk-MailScanner-ID: w2S80RS3031317 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Mar 2018, 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: > > 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 The patch fixes the problem. Michael Young