Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4059172pxu; Wed, 9 Dec 2020 07:24:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwruEk90MTCR1BCFDF7vwTg3w8TtVgXVA7Si66P3sm1ufvdgOwy5oRgj0/QMb2GVlx01DNm X-Received: by 2002:aa7:c58a:: with SMTP id g10mr2459172edq.315.1607527492693; Wed, 09 Dec 2020 07:24:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607527492; cv=none; d=google.com; s=arc-20160816; b=mKEaMAWIuD6ew435HB1x/rNdvZ8u9K6sgRIwNyYmoU4XhJtkr72xDMKgIzZd+JHzlf uQq9iReFZm8epgESnl6WTSKyy8ozYgP9pHexQG4S79k8VpptC1ovTjm7rOb+TlMIpnfc P5HEuEbwBqUhOti+8zAF5yPbXqiYK45tCZNu5EuNjF+4LdrG74+8ljBvQAi8kyvipMFc PTRoYO7ZVc92MugUHQqywvfvnTCaltDUEl3lFFLRgVOZZ4a9p1ur+WoNBEkLGtz1hW+U otaci5jDbTIwjWydRrbwsKwKcZuG02aMpGver6/jBuiQGLEmDQMGJfuCRML00kDZnqdy Gm6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=K0nMg5WVHYxWyCXNGYxNzAQFjXZB3sPfjlIvVCRuQFQ=; b=MvAKuY1WJfD9NiQylyjeRjLN/fjgGi1TxZY6ycPnFx3omvJ8mFSnAlwsPFAMzSgvsM /jzHSnOpB62G/betS2NIcurPRZZaCJwQZA69oWRUbhQKzthHv3oksk5kwFviZiWWosoA Ek7I4cEHOgrPpbYSZELB1QNLnEimrRCv72Cet/THZ8b6K3xqtFH0YpVx4hubI4kX2KPq w/u6a/s/3oiiNLJ/RTAdU1xV68hRDccAp5JacABIqLjjcgaRTVPjyWkQrkBbtZNDkSTt jatBDL6/dCdUD5qgUSfiM0nb/R4EX8RoISM/3SU/z6NsW1QQ5iU3ZxFHoMHrI3Q86tUf MUgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd3si976173edb.558.2020.12.09.07.24.29; Wed, 09 Dec 2020 07:24:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733111AbgLIOto (ORCPT + 99 others); Wed, 9 Dec 2020 09:49:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:50666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733105AbgLIOto (ORCPT ); Wed, 9 Dec 2020 09:49:44 -0500 From: trondmy@kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-nfs@vger.kernel.org Subject: [PATCH 15/16] nfsd: Fixes for nfsd4_encode_read_plus_data() Date: Wed, 9 Dec 2020 09:48:00 -0500 Message-Id: <20201209144801.700778-16-trondmy@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201209144801.700778-15-trondmy@kernel.org> References: <20201209144801.700778-1-trondmy@kernel.org> <20201209144801.700778-2-trondmy@kernel.org> <20201209144801.700778-3-trondmy@kernel.org> <20201209144801.700778-4-trondmy@kernel.org> <20201209144801.700778-5-trondmy@kernel.org> <20201209144801.700778-6-trondmy@kernel.org> <20201209144801.700778-7-trondmy@kernel.org> <20201209144801.700778-8-trondmy@kernel.org> <20201209144801.700778-9-trondmy@kernel.org> <20201209144801.700778-10-trondmy@kernel.org> <20201209144801.700778-11-trondmy@kernel.org> <20201209144801.700778-12-trondmy@kernel.org> <20201209144801.700778-13-trondmy@kernel.org> <20201209144801.700778-14-trondmy@kernel.org> <20201209144801.700778-15-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Ensure that we encode the data payload + padding, and that we truncate the preallocated buffer to the actual read size. Signed-off-by: Trond Myklebust --- fs/nfsd/nfs4xdr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 833a2c64dfe8..26f6e277101d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4632,6 +4632,7 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp, resp->rqstp->rq_vec, read->rd_vlen, maxcount, eof); if (nfserr) return nfserr; + xdr_truncate_encode(xdr, starting_len + 16 + xdr_align_size(*maxcount)); tmp = htonl(NFS4_CONTENT_DATA); write_bytes_to_xdr_buf(xdr->buf, starting_len, &tmp, 4); @@ -4639,6 +4640,10 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp, write_bytes_to_xdr_buf(xdr->buf, starting_len + 4, &tmp64, 8); tmp = htonl(*maxcount); write_bytes_to_xdr_buf(xdr->buf, starting_len + 12, &tmp, 4); + + tmp = xdr_zero; + write_bytes_to_xdr_buf(xdr->buf, starting_len + 16 + *maxcount, &tmp, + xdr_pad_size(*maxcount)); return nfs_ok; } -- 2.29.2