Received: by 10.223.164.221 with SMTP id h29csp1439887wrb; Fri, 13 Oct 2017 20:02:21 -0700 (PDT) X-Received: by 10.84.137.106 with SMTP id 97mr3010061plm.411.1507950141099; Fri, 13 Oct 2017 20:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507950141; cv=none; d=google.com; s=arc-20160816; b=y6oH62W9DpGph5aXDyUzXBR4omQqeBPzkrnQqsoOf96Z7NxGOB540YQ7dqiso+PVu1 /LOff5iNdRSdxBlPDwxIK+9ljral3tBcGvNuDjbc8oR5mSMUDgLpJ5f0Cdl/OQHUfUPK aoegaikLaoEWCOFSJrR8bxxd1X5EY87wbdG59ksQ6cFAP5Wf6OnEbsSM5ItJr6mqShXL 2E1Bkmk9PFk3jkbBRA1fzTytaekWFvy3zBbe0RkgL64VaJVsRnbuJUApDwBFrFhZvPbD YdrxYoUcdY01qWv9/5M5nKXTZITIsIp6sHhDIPpFunRTfa/SH4j7+Z9S+ONFhpULytF+ MukA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=6FEOn8iTvNUaOqLK6RQinEDmUpniaAVo15N5VRowTXI=; b=vFpyrad9eltsKh7JUzOaoZEfBIRi/HzlVdbWggHQbKGi5pHlDhwgsQnXOnii/CqSDw 5ZXf3Z9QkV75OEolyYpB7XRYmJbrENZjjLaT4f0nql0FvKk0KM+svX35O1FEngQ+vD2k C87+yP7FDkFPd4jcoKM0pIWXLlcUFz7CHnyjJy2DZPKAirfpCkq2UH/Y6mx359Fv33yx uqpAWrcY52n53/+TeNRx9fGewWp1bu95mtvXR3L8DL+QqAZAvqty1LpdY9rYIlKIJjXP lqd+PlcRoCD+5wUAyAwxwXewkCj90m2/2DgFdcJI7HltCDQI/jWPiAZv9/g57WQS3BnL 9E0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bx0t35uY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b36si1435250pli.766.2017.10.13.20.01.56; Fri, 13 Oct 2017 20:02:21 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bx0t35uY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753454AbdJNDBP (ORCPT + 99 others); Fri, 13 Oct 2017 23:01:15 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:56639 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753172AbdJNDBN (ORCPT ); Fri, 13 Oct 2017 23:01:13 -0400 Received: by mail-qt0-f194.google.com with SMTP id z28so20438162qtz.13; Fri, 13 Oct 2017 20:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6FEOn8iTvNUaOqLK6RQinEDmUpniaAVo15N5VRowTXI=; b=Bx0t35uYYQKLuAcw8wJeHu8+XTAqA5zaUjhvbZCBQHW9uD28kZIhf9FYJ5266pp5YD WXhNiUg8MKeJxikEsSV8S1tRbf71t3Pkne+NpH/HJNLwSAuCkiC060g4rUER5gLKDyIs 9RDAbVAI5CTXDb0keyzAA8wr82Ax/cLNrXC06fK02E9JLFKpiKuHjNkqW3iSrOliJyvD diAK5CUrRfPYikOEqrK5pHG6ecoMyOCGgblpGshPSwUKmwZ5c/AkxYbV5iMyUYbWfgUr 4suz6bO59jD8kmM/LJBuANLbLvJyq4jWXyEfodOL6EWO/dvqtLdTsbkF/y4+Yl62jPqZ Gjag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6FEOn8iTvNUaOqLK6RQinEDmUpniaAVo15N5VRowTXI=; b=GPXntMRdDFZJSbrgQ0bWWnatvvXL7LcyUUDIILILQQZeTVtbSxvnNZiqju2+m1o0Qj idT/dVM2ejSb96J7IT0miu+p21uDS0/Xj90oZdET9JPNB747XPiA8AFjMychCY6hHr0b af1FB3UpWt8lpg8s4iWycr8Ol3vUW+uV61KD1izipKgEySzeIckWsm/RW0q66OtRpd44 8CvGU6m5T61+sa82FlF3nJW7ooCiPItUSWkQs+8ilHw+exRAlUP/QuOseYVxiAkMbDSN exZctvtlrQg8elSKRv7J/yPfgvk8+ZGW7lh8y8+kxcERz0mINV3f3IZulG98j+brSxCt Wbiw== X-Gm-Message-State: AMCzsaWSVfjEkbjCJB9HyPcH1UvCRC3c5/MDyuIU7+1xhnE8J55uZZ5X gydcutAmf6Gq9SAhu5IAjBZZMEv8pWNjBXouY+k= X-Google-Smtp-Source: AOwi7QANj8EMzwvfkHjWaRnf5+mJOwEXDu9wVy4FTMRgnslTdXIZAPtgM2O0q+lnSwJXdD7LxHm+nzXd6icupjw4yek= X-Received: by 10.200.57.86 with SMTP id t22mr4737873qtb.113.1507950072616; Fri, 13 Oct 2017 20:01:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.191.67 with HTTP; Fri, 13 Oct 2017 20:00:32 -0700 (PDT) In-Reply-To: <1498116075-2195-1-git-send-email-kerneljasonxing@gmail.com> References: <1498116075-2195-1-git-send-email-kerneljasonxing@gmail.com> From: Jason Xing Date: Sat, 14 Oct 2017 11:00:32 +0800 Message-ID: Subject: Re: [PATCH] ecryptfs: Fix stat command displays wrong file size in xattr region To: ecryptfs@vger.kernel.org Cc: Tyler Hicks , linux-kernel@vger.kernel.org, Jason Xing Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Could anyone take a look at this patch which fixes the xattr-read issue? Thanks anyway. Jason On Thu, Jun 22, 2017 at 3:21 PM, Jason Xing wrote: > When doing ecryptfs_read_and_validate_xattr_region(), eCryptfs > reads only 16 bytes from xattr region. However, the lower filesystem > like ext4 always compares 16 with the size of ecryptfs xattr region > which is 81 bytes, and then it will return ERANGE (-34) and do not > read that region. > > Signed-off-by: Jason Xing > --- > fs/ecryptfs/crypto.c | 33 +++++++++++++++++++++++++-------- > 1 file changed, 25 insertions(+), 8 deletions(-) > > diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c > index e5e29f8..895140f 100644 > --- a/fs/ecryptfs/crypto.c > +++ b/fs/ecryptfs/crypto.c > @@ -1389,19 +1389,36 @@ int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode) > int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry, > struct inode *inode) > { > - u8 file_size[ECRYPTFS_SIZE_AND_MARKER_BYTES]; > - u8 *marker = file_size + ECRYPTFS_FILE_SIZE_BYTES; > + char *page_virt; > int rc; > > + page_virt = kmem_cache_alloc(ecryptfs_header_cache, GFP_USER); > + if (!page_virt) { > + rc = -ENOMEM; > + printk(KERN_ERR "%s: Unable to allocate page_virt\n", > + __func__); > + goto out; > + } > rc = ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry), > ecryptfs_inode_to_lower(inode), > - ECRYPTFS_XATTR_NAME, file_size, > - ECRYPTFS_SIZE_AND_MARKER_BYTES); > - if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES) > - return rc >= 0 ? -EINVAL : rc; > - rc = ecryptfs_validate_marker(marker); > + ECRYPTFS_XATTR_NAME, page_virt, > + ECRYPTFS_DEFAULT_EXTENT_SIZE); > + if (rc < 0) { > + if (unlikely(ecryptfs_verbosity > 0)) > + printk(KERN_INFO "Error attempting to read the [%s] " > + "xattr from the lower file; return value = " > + "[%d]\n", ECRYPTFS_XATTR_NAME, rc); > + rc = -EINVAL; > + goto out; > + } > + rc = ecryptfs_validate_marker(page_virt + ECRYPTFS_FILE_SIZE_BYTES); > if (!rc) > - ecryptfs_i_size_init(file_size, inode); > + ecryptfs_i_size_init(page_virt, inode); > +out: > + if (page_virt) { > + memset(page_virt, 0, PAGE_SIZE); > + kmem_cache_free(ecryptfs_header_cache, page_virt); > + } > return rc; > } > > -- > 2.7.4 > From 1570888797362860728@xxx Thu Jun 22 07:24:59 +0000 2017 X-GM-THRID: 1570888797362860728 X-Gmail-Labels: Inbox,Category Forums