From patchwork Fri Nov 15 15:02:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 3188601 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 C2821C045B for ; Fri, 15 Nov 2013 15:02:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93F4C20918 for ; Fri, 15 Nov 2013 15:02:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F635206D6 for ; Fri, 15 Nov 2013 15:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751407Ab3KOPCN (ORCPT ); Fri, 15 Nov 2013 10:02:13 -0500 Received: from mx11.netapp.com ([216.240.18.76]:32868 "EHLO mx11.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751346Ab3KOPCN (ORCPT ); Fri, 15 Nov 2013 10:02:13 -0500 X-IronPort-AV: E=Sophos;i="4.93,708,1378882800"; d="scan'208";a="75410491" Received: from vmwexceht04-prd.hq.netapp.com ([10.106.77.34]) by mx11-out.netapp.com with ESMTP; 15 Nov 2013 07:02:12 -0800 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCEHT04-PRD.hq.netapp.com (10.106.77.34) with Microsoft SMTP Server id 14.3.123.3; Fri, 15 Nov 2013 07:02:12 -0800 Received: from vpn2ntap-19511.vpn.netapp.com (vpn2ntap-19511.vpn.netapp.com [10.55.68.238]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id rAFF2BwA024941; Fri, 15 Nov 2013 07:02:12 -0800 (PST) From: Weston Andros Adamson To: CC: , Weston Andros Adamson Subject: [PATCH] NFSv4: fix getacl ERANGE for some ACL buffer sizes Date: Fri, 15 Nov 2013 10:02:08 -0500 Message-ID: <1384527728-1487-1-git-send-email-dros@netapp.com> X-Mailer: git-send-email 1.8.3.1 (Apple Git-46) MIME-Version: 1.0 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, 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 Besides storing the ACL buffer, the getacl decoder uses the inline pages for the attr bitmap and buffer length. __nfs4_get_acl_uncached must allocate enough page space for all of the data to be decoded. This bug results in getxattr() returning ERANGE when the attr buffer length is close enough to the nearest PAGE_SIZE multiple that adding the extra bytes leaves too little room for the ACL buffer. Signed-off-by: Weston Andros Adamson --- fs/nfs/nfs4proc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 5ab33c0..006cba1 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -4453,7 +4453,12 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu .rpc_argp = &args, .rpc_resp = &res, }; - unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE); + /* + * extra space needed for attr bitmap and length in getacl decoder. + * 1 word for bitmap len, 3 words for bitmaps and 1 word for attr len. + */ + unsigned int preamble_len = 20; + unsigned int npages = DIV_ROUND_UP(preamble_len + buflen, PAGE_SIZE); int ret = -ENOMEM, i; /* As long as we're doing a round trip to the server anyway,