Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2191169ybl; Thu, 5 Dec 2019 13:42:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwFER5em1oBNoDW3CXkjsm/fJq6Uo+aHTDLJf6u6bVln6/B6KXY5QwVbgT8gm4HuJjOegqU X-Received: by 2002:aca:49d0:: with SMTP id w199mr9035104oia.14.1575582139828; Thu, 05 Dec 2019 13:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575582139; cv=none; d=google.com; s=arc-20160816; b=vVTPff3mlAm34/t5VPvmhopSBSIAvy21iqyvANPDnvEX1pRQ9amsFIgnVy0sFbP8cM uREVhgbAHdm6n4prm3HzuTCaVp1wbMItgw3juP9uxPAywgwQ3d9AzK2J1JzfPIUF+kPG y9IOf8u/7VWBvBNEG4sUEbSWsugsAfWDz2pZ/41U1uJ8RL+iuP0c/DFzddbjXzAK3xpt agApLyDVepMUv/4f9mCFc5wm0uvC/i3AJpC1Ud82yx0HWdP5TSRUad2u5D0EGTXeOIYL 4xYDB37JbQCky+MEQbt1cWUz5Bzo83PgHqgMSRZjUNtyywoeLRBNuBrTMupF5HLQ5mCN OHIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:from:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date; bh=FROwPSvd2LvcynwOAdg7EkYGz0CkjruqVWN/yqV2ZLo=; b=OJy6eJzyBQCcv9O7N9MWXEXF2dSE5HWQtxCDF275j2A2hYChsKoqC6znISY5TdJMez SZRvDnSN27Q6LETQ9LsabweGvJ23ChGzt8mbdpw6aC7EjBT2IcvSWUftBXx8dP5VIB9X GgZlrsmm6e8NdX9hubsDVIyTnvE5fp3CYeE57/cs2vmr8rwkTDn1GzC8utnOA2ybQ2b3 4iYIBUHcIZR6oJs9StE9270PVMWLkED8QE/g0yrG7vmP4gj64QJmSWr4Vmf5yN9uzmDR T6NARBGFbRkQ4MKXxK32mC+2nl97xcMLUiSG0WahBOMytNBO4IisyfxjcjOnqBfwSZHk kpFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-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 h184si5843508oia.19.2019.12.05.13.41.57; Thu, 05 Dec 2019 13:42:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729900AbfLEVja (ORCPT + 99 others); Thu, 5 Dec 2019 16:39:30 -0500 Received: from fieldses.org ([173.255.197.46]:53370 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729396AbfLEVja (ORCPT ); Thu, 5 Dec 2019 16:39:30 -0500 Received: by fieldses.org (Postfix, from userid 2815) id 243511511; Thu, 5 Dec 2019 16:39:30 -0500 (EST) Date: Thu, 5 Dec 2019 16:39:30 -0500 To: Olga Kornievskaia Cc: bfields@redhat.com, linux-nfs@vger.kernel.org Subject: Re: [PATCH 2/3] NFSD fix nfserro errno mismatch Message-ID: <20191205213930.GB29765@fieldses.org> References: <20191204201354.17557-1-olga.kornievskaia@gmail.com> <20191204201354.17557-3-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191204201354.17557-3-olga.kornievskaia@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Dec 04, 2019 at 03:13:53PM -0500, Olga Kornievskaia wrote: > There is mismatch between __be32 and u32 in nfserr and errno. > ... > @@ -1280,7 +1279,7 @@ extern struct file *nfs42_ssc_open(struct vfsmount *ss_mnt, > > copy->c_fh.size = s_fh->fh_handle.fh_size; > memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_base, copy->c_fh.size); > - copy->stateid.seqid = s_stid->si_generation; > + copy->stateid.seqid = cpu_to_be32(s_stid->si_generation); This one isn't an errno, and should really be its own patch. I've split it out as follows.--b. commit a1f3cb8bb088 Author: Olga Kornievskaia Date: Wed Dec 4 15:13:53 2019 -0500 NFSD: fix seqid in copy stateid s_stid->si_generation is a u32, copy->stateid.seqid is a __be32, so we should be byte-swapping here if necessary. This effectively undoes the byte-swap performed when reading s_stid->s_generation in nfsd4_decode_copy(). Without this second swap, the stateid we sent to the source in READ could be different from the one the client provided us in the COPY. We didn't spot this in testing since our implementation always uses a 0 in the seqid field. But other implementations might not do that. You'd think we should just skip the byte-swapping entirely, but the s_stid field can be used for either our own stateids (in the intra-server case) or foreign stateids (in the inter-server case), and the former are interpreted by us and need byte-swapping. Reported-by: kbuild test robot Fixes: d5e54eeb0e3d ("NFSD add nfs4 inter ssc to nfsd4_copy") Signed-off-by: Olga Kornievskaia Signed-off-by: J. Bruce Fields diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index ec4f79c8f71e..9a8debc0d725 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1280,7 +1280,7 @@ nfsd4_setup_inter_ssc(struct svc_rqst *rqstp, copy->c_fh.size = s_fh->fh_handle.fh_size; memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_base, copy->c_fh.size); - copy->stateid.seqid = s_stid->si_generation; + copy->stateid.seqid = cpu_to_be32(s_stid->si_generation); memcpy(copy->stateid.other, (void *)&s_stid->si_opaque, sizeof(stateid_opaque_t));