From patchwork Thu Jun 26 14:23:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 4427871 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4FE85BEEAA for ; Thu, 26 Jun 2014 14:23:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 713212025B for ; Thu, 26 Jun 2014 14:23:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 653022038F for ; Thu, 26 Jun 2014 14:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753575AbaFZOXS (ORCPT ); Thu, 26 Jun 2014 10:23:18 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:35551 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbaFZOXR (ORCPT ); Thu, 26 Jun 2014 10:23:17 -0400 Received: by mail-wg0-f41.google.com with SMTP id a1so3724662wgh.12 for ; Thu, 26 Jun 2014 07:23:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=lVYRL/kNcAT0aBL0Bc+pvf27w+v4ORlRMQt5fs7cJ2Q=; b=DFfvcWEIplIwy6y/lpnEQncuTkUAFk+EgluAwTViZNCFrReBwxEpwfgpkci2lckVyD s7Fnk7Rhp4zOpgIBDl+agKc42nx4+pkaD4VIJVTPzQN8kYJclg4th6jIpK+vgFPMf9tV /RqNQ76BDIi1S0GcoI0rs2BZ/05nXmxVIVWnqUw7EK2dgtuNT5bZ3NCDDQMm6sAmOeWl uPpMfVlWRcUjXv875fo3eb7srXnBvnF7BmhBjUi3B6yW7t7Wl0b43bDzsZksaFqNEzJM kAExO/ymVcJSjyhTTKxrtCES6r64xdhvzJr9Asjwzwem2PEVvv0THIFfkhSEyCDJRYm+ CtYA== X-Gm-Message-State: ALoCoQkDWYDOMgonbQAvK3z2Lj7OepWSE8h72VCwHvDGuDANyZrrpWSO7PKKrrRKUed3T8MWyEb2 X-Received: by 10.194.90.106 with SMTP id bv10mr18780743wjb.20.1403792596169; Thu, 26 Jun 2014 07:23:16 -0700 (PDT) Received: from avi.cloudius (84.94.198.183.cable.012.net.il. [84.94.198.183]) by mx.google.com with ESMTPSA id u10sm25038430wix.11.2014.06.26.07.23.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jun 2014 07:23:15 -0700 (PDT) From: Avi Kivity To: linux-nfs@vger.kernel.org Subject: [PATCH] nfs: fix nfs4d readlink truncated packet Date: Thu, 26 Jun 2014 17:23:12 +0300 Message-Id: <1403792592-1517-1-git-send-email-avi@cloudius-systems.com> X-Mailer: git-send-email 1.9.3 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP XDR requires 4-byte alignment; nfs4d READLINK reply writes out the padding, but truncates the packet to the padding-less size. Fix by taking the padding into consideration when truncating the packet. Signed-off-by: Avi Kivity Reviewed-by: Kinglong Mee --- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 83baf2b..cba93ea 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3267,7 +3267,7 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd wire_count = htonl(maxcount); write_bytes_to_xdr_buf(xdr->buf, length_offset, &wire_count, 4); - xdr_truncate_encode(xdr, length_offset + 4 + maxcount); + xdr_truncate_encode(xdr, length_offset + 4 + ALIGN(maxcount, 4)); if (maxcount & 3) write_bytes_to_xdr_buf(xdr->buf, length_offset + 4 + maxcount, &zero, 4 - (maxcount&3));