From patchwork Wed Mar 2 15:51:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 8482721 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 93025C0553 for ; Wed, 2 Mar 2016 15:52:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95AC82013D for ; Wed, 2 Mar 2016 15:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 914AD20221 for ; Wed, 2 Mar 2016 15:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755698AbcCBPv5 (ORCPT ); Wed, 2 Mar 2016 10:51:57 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35073 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753629AbcCBPvz (ORCPT ); Wed, 2 Mar 2016 10:51:55 -0500 Received: by mail-pa0-f44.google.com with SMTP id bj10so66028299pad.2 for ; Wed, 02 Mar 2016 07:51:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=avaJTGwx/9y5PcN1yi2O4mJ4ObSdXW/tK1K7QPq3914=; b=DvJljK+1IXcatUTmby1mUrNweAmv/bA8IvX0mOfxlDB3SCkZJazMK/jl+A4xnVM5Np 1m6E8+KEe3FkUud8K9DjZUdWoYDYlGHxAhlWtXn9JlYmecUKt3d0VzzIrCWqEJLU8hpC oNhhSRrOPmNWV15DW/UjdFxADvekBkg1BTylp6HNq6fX4Y3J61edOipxHVUuf4qTXwJj HvBAZtOnbAY9usVC0yuhxuy9jFA49N8J7Ept2DtoTsR/Ihp/gngC2N2J7gKxFL7TApoW /E/obpiXon4OMBvJLbderfbyoLURHCpMtZ+QJf1D7MjsZywWELArSdhwAn11LF39XvDS Dnmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=avaJTGwx/9y5PcN1yi2O4mJ4ObSdXW/tK1K7QPq3914=; b=UcBjG3Wgg4BMBsQoJkZ5Xd1/UPETqic+4xedEBiTX8+Z1Yqd8I+90ri5MUVuYuc5va SGcrWgiOYhocqyl+yVRRPkruBk6yAYIwuaA+S8CZ8Sx8tHnjk3sgrCELf7EXOcUmwaSG l1L5QIq9lmdp3iMFTbDvxQX0qI+Zo3qSoKoInuuLy//FeGmrFTVzHdJpXu5jRp5VXLMV cAtTc0qOyT5zSB4a3Zeg7uV1yOFnx9wOytqi9e1pNW68Kjkk8ZpTUY/6XrKXTBJsDX4m z5dWWYA9yoxsZVZyBso2L9kAKyvBECdeFZr1INkQOkfYlBvyf/iCNKsQPfyr1fIJ60zI qtPA== X-Gm-Message-State: AD7BkJIKFOzxCml5Jpi8idOKXUYOegeJK8FS4F4wOYstOsZ1Ano51ioZCcVjDRL5wcOkYQ== X-Received: by 10.66.140.70 with SMTP id re6mr14299436pab.100.1456933914677; Wed, 02 Mar 2016 07:51:54 -0800 (PST) Received: from localhost.localdomain ([106.51.225.232]) by smtp.gmail.com with ESMTPSA id if4sm40849920pad.29.2016.03.02.07.51.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 07:51:54 -0800 (PST) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org Cc: viro@zeniv.linux.org.uk, tglx@linutronix.de, arnd@arndb.de Subject: [PATCH] vfs: Add support to check max and min inode times Date: Wed, 2 Mar 2016 07:51:34 -0800 Message-Id: <1456933894-17001-1-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This is a preparation patch to add range checking for inode timestamps. These range checks will be used to clamp timestamps to filesystem allowed ranges. Individual filesystems do not have the same on disk format as the in memory inodes. Range checking and clamping times assigned to inodes will help keep in memory and on-disk timestamps to be in sync. Extend struct super_block to include information about the max and min inode times each filesystem can hold. These are dependent on the on-disk format of filesystems. Every time a new superblock is created, make sure that the superblock max and min timestamp fields are assigned invalid values. Another series will initialize these fields to appropriate values for every filesystem. The values are currently ignored. The exact policy and behavior will be decided in a separate patch. MAX_INVALID_VFS_TIME and MIN_INVALID_VFS_TIME are initialized to S64_MIN and S64_MAX respectively so that even if one of the fields is uninitialized, it can be detected by using the condition max_time < min_time. The original idea for the feature comes from the discussion: https://lkml.org/lkml/2014/5/30/669 Signed-off-by: Deepa Dinamani Acked-by: Arnd Bergmann --- The intention is to include this as part of 4.6 so that the follow on patches can go into 4.7. The series and the plan have been discussed with Arnd Bergmann. fs/super.c | 2 ++ include/linux/fs.h | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index 1182af8..d70a8f6 100644 --- a/fs/super.c +++ b/fs/super.c @@ -239,6 +239,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags) s->s_maxbytes = MAX_NON_LFS; s->s_op = &default_op; s->s_time_gran = 1000000000; + s->s_time_max = MAX_INVALID_VFS_TIME; + s->s_time_min = MIN_INVALID_VFS_TIME; s->cleancache_poolid = CLEANCACHE_NO_POOL; s->s_shrink.seeks = DEFAULT_SEEKS; diff --git a/include/linux/fs.h b/include/linux/fs.h index 1af4727..15b41e6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -927,6 +927,12 @@ static inline struct file *get_file(struct file *f) #define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL) #endif +#define MAX_VFS_TIME S64_MAX +#define MIN_VFS_TIME S64_MIN + +#define MAX_INVALID_VFS_TIME S64_MIN +#define MIN_INVALID_VFS_TIME S64_MAX + #define FL_POSIX 1 #define FL_FLOCK 2 #define FL_DELEG 4 /* NFSv4 delegation */ @@ -1343,7 +1349,12 @@ struct super_block { /* Granularity of c/m/atime in ns. Cannot be worse than a second */ - u32 s_time_gran; + u32 s_time_gran; + /* Max and min values for timestamps + * according to the range supported by filesystems. + */ + time64_t s_time_max; + time64_t s_time_min; /* * The next field is for VFS *only*. No filesystems have any business