From deepa.kernel at gmail.com  Wed Nov  2 08:04:50 2016
From: deepa.kernel at gmail.com (Deepa Dinamani)
Date: Wed,  2 Nov 2016 08:04:50 -0700
Subject: [RFC 0/6] vfs: Add timestamp range check support
Message-ID: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>

The series is aimed at adding timestamp checking and policy
related to it to vfs.

The series was developed with discussions and guidance from
Arnd Bergmann.

The original idea for the series was the discussion:
https://lkml.org/lkml/2014/5/30/551

Patches 5 and 6 can be merged only after vfs is transitioned
to use 64 bit timestamps as noted in the respective commit
texts.

The series only includes adding range limits to filesystems:
ext4 and afs as examples to keep the series simple.
Every filesystem will be updated to add these limits.

There is an ext4 current_time() api replacement patch that the
series depends on:
https://lkml.org/lkml/2016/6/9/38 .
This needs reposting to the mailing list.

The branch for the tree along with dependency can be found at

https://github.com/deepa-hub/vfs.git refs/heads/vfs_timestamp_policy

Deepa Dinamani (6):
  vfs: Add file timestamp range support
  vfs: Add checks for filesystem timestamp limits
  afs: Add time limits in the super block
  ext4: Initialize timestamps limits
  vfs: Add timestamp_truncate() api
  utimes: Clamp the timestamps before update

 fs/afs/super.c          |  2 ++
 fs/ext4/ext4.h          |  4 ++++
 fs/ext4/super.c         |  7 ++++++-
 fs/inode.c              | 37 ++++++++++++++++++++++++++++++++++++-
 fs/internal.h           |  2 ++
 fs/libfs.c              |  4 ++++
 fs/namespace.c          | 12 ++++++++++++
 fs/super.c              |  8 ++++++++
 fs/utimes.c             | 17 +++++++++++++----
 include/linux/fs.h      |  4 ++++
 include/linux/time64.h  |  6 ++++++
 include/uapi/linux/fs.h |  6 +++++-
 kernel/sysctl.c         |  7 +++++++
 13 files changed, 109 insertions(+), 7 deletions(-)

-- 
2.7.4

Cc: linux-afs at lists.infradead.org
Cc: "Theodore Ts'o" <tytso at mit.edu>
Cc: Andreas Dilger <adilger.kernel at dilger.ca>
Cc: linux-ext4 at vger.kernel.org




From deepa.kernel at gmail.com  Wed Nov  2 08:04:53 2016
From: deepa.kernel at gmail.com (Deepa Dinamani)
Date: Wed,  2 Nov 2016 08:04:53 -0700
Subject: [RFC 3/6] afs: Add time limits in the super block
In-Reply-To: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
Message-ID: <1478099096-25637-4-git-send-email-deepa.kernel@gmail.com>

Note that all the filesystems that have such simple limits
will be initialized in the same patch.

Signed-off-by: Deepa Dinamani <deepa.kernel at gmail.com>
Cc: linux-afs at lists.infradead.org
---
 fs/afs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index fbdb022..ab00434 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -321,6 +321,8 @@ static int afs_fill_super(struct super_block *sb,
 	sb->s_op		= &afs_super_ops;
 	sb->s_bdi		= &as->volume->bdi;
 	strlcpy(sb->s_id, as->volume->vlocation->vldb.name, sizeof(sb->s_id));
+	sb->s_time_max = Y2106_EXPIRY_TIMESTAMP;
+	sb->s_time_min = 0;
 
 	/* allocate the root inode and dentry */
 	fid.vid		= as->volume->vid;
-- 
2.7.4



From david at fromorbit.com  Wed Nov  2 15:48:27 2016
From: david at fromorbit.com (Dave Chinner)
Date: Thu, 3 Nov 2016 09:48:27 +1100
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
Message-ID: <20161102224827.GJ14023@dastard>

On Wed, Nov 02, 2016 at 08:04:50AM -0700, Deepa Dinamani wrote:
> The series is aimed at adding timestamp checking and policy
> related to it to vfs.
> 
> The series was developed with discussions and guidance from
> Arnd Bergmann.
> 
> The original idea for the series was the discussion:
> https://lkml.org/lkml/2014/5/30/551
> 
> Patches 5 and 6 can be merged only after vfs is transitioned
> to use 64 bit timestamps as noted in the respective commit
> texts.
> 
> The series only includes adding range limits to filesystems:
> ext4 and afs as examples to keep the series simple.
> Every filesystem will be updated to add these limits.

We're going to need regression tests for this to ensure that it
works properly and that we don't inadvertantly break it in future.
Can you write some xfstests that exercise this functionality and
validate that the mount behaviour, clamping and range limiting is
working as intended?

Cheers,

Dave.
-- 
Dave Chinner
david at fromorbit.com


From darrick.wong at oracle.com  Wed Nov  2 23:54:19 2016
From: darrick.wong at oracle.com (Darrick J. Wong)
Date: Wed, 2 Nov 2016 23:54:19 -0700
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <20161102224827.GJ14023@dastard>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <20161102224827.GJ14023@dastard>
Message-ID: <20161103065419.GA5248@birch.djwong.org>

On Thu, Nov 03, 2016 at 09:48:27AM +1100, Dave Chinner wrote:
> On Wed, Nov 02, 2016 at 08:04:50AM -0700, Deepa Dinamani wrote:
> > The series is aimed at adding timestamp checking and policy
> > related to it to vfs.
> > 
> > The series was developed with discussions and guidance from
> > Arnd Bergmann.
> > 
> > The original idea for the series was the discussion:
> > https://lkml.org/lkml/2014/5/30/551
> > 
> > Patches 5 and 6 can be merged only after vfs is transitioned
> > to use 64 bit timestamps as noted in the respective commit
> > texts.
> > 
> > The series only includes adding range limits to filesystems:
> > ext4 and afs as examples to keep the series simple.
> > Every filesystem will be updated to add these limits.
> 
> We're going to need regression tests for this to ensure that it
> works properly and that we don't inadvertantly break it in future.
> Can you write some xfstests that exercise this functionality and
> validate that the mount behaviour, clamping and range limiting is
> working as intended?

Seconded. :)

I guess the only way to tell if a mountpoint can do 64 bit times is to
try it and see what happens?  Unless you enable the procfs thing that
prints to dmesg.  Evidently turning on the knob won't cause complaints
if there's already a mounted fs that didn't have 64-bit time support.
I'd go look at the testcases to corroborate this, but I don't know
that there are any?

(It was a big help to write a big pile of tests for adding reflink to
XFS.  It helped us find some btrfs reflink bugs too.)

--D

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david at fromorbit.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


From tytso at mit.edu  Thu Nov  3 13:43:57 2016
From: tytso at mit.edu (Theodore Ts'o)
Date: Thu, 3 Nov 2016 16:43:57 -0400
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <20161102224827.GJ14023@dastard>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <20161102224827.GJ14023@dastard>
Message-ID: <20161103204357.r7lgvbsv3euujijn@thunk.org>

On Thu, Nov 03, 2016 at 09:48:27AM +1100, Dave Chinner wrote:
> 
> We're going to need regression tests for this to ensure that it
> works properly and that we don't inadvertantly break it in future.
> Can you write some xfstests that exercise this functionality and
> validate that the mount behaviour, clamping and range limiting is
> working as intended?

In order to have automated regression tests which are file system
independent, we need a way to query what are the timestamps that a
particular mounted file systme supports.  One approach would be to use
fsinfo, which David Howells had been working on, but which has been
bike-shedded to death for the last n years, and I'd hate to block this
patch series behind a proposed new fsinfo(2) system call.
Alternatively, we can just create a specialized ioctl to return that
information which is non-ideal in other dimensions.

The last option, which is admittedly ugly, would be to create an shell
function which knows how to figure out the max_timestamp and
min_timestamp by using the file system name and querying the
superblock using dumpe2fs, xfs_db, etc.

I'd argue for the last option because once we do get a programmtic way
to get the information via a system call such as fsinfo(2), we can
convert xfstests to use it, where as if we add an ioctl to return this
information, we'll have to support the ioctl forever.

Does this make sense?   Any objections?

Cheers,

						- Ted


From david at fromorbit.com  Thu Nov  3 16:48:02 2016
From: david at fromorbit.com (Dave Chinner)
Date: Fri, 4 Nov 2016 10:48:02 +1100
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <20161103204357.r7lgvbsv3euujijn@thunk.org>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <20161102224827.GJ14023@dastard>
 <20161103204357.r7lgvbsv3euujijn@thunk.org>
Message-ID: <20161103234802.GK14023@dastard>

On Thu, Nov 03, 2016 at 04:43:57PM -0400, Theodore Ts'o wrote:
> On Thu, Nov 03, 2016 at 09:48:27AM +1100, Dave Chinner wrote:
> > 
> > We're going to need regression tests for this to ensure that it
> > works properly and that we don't inadvertantly break it in future.
> > Can you write some xfstests that exercise this functionality and
> > validate that the mount behaviour, clamping and range limiting is
> > working as intended?
> 
> In order to have automated regression tests which are file system
> independent, we need a way to query what are the timestamps that a
> particular mounted file systme supports.

We don't need that - we simply code it directly into the test
infrastructure, like we've done for things like the maximum number
of ACLs a filesystem supports (common/attr::_acl_get_max()).

> The last option, which is admittedly ugly, would be to create an shell
> function which knows how to figure out the max_timestamp and
> min_timestamp by using the file system name and querying the
> superblock using dumpe2fs, xfs_db, etc.

Yup, precisely that. We shouldn't trust the kernel to tell us the
correct thing to enable the test that tells us that thing is working
correctly or not...

> I'd argue for the last option because once we do get a programmtic way
> to get the information via a system call such as fsinfo(2), we can
> convert xfstests to use it, where as if we add an ioctl to return this
> information, we'll have to support the ioctl forever.

We have to support kernels that won't ever have something like
fsinfo, so it has to be done the "ugly way".

Cheers,

Dave.
-- 
Dave Chinner
david at fromorbit.com


From adilger at dilger.ca  Thu Nov  3 17:27:26 2016
From: adilger at dilger.ca (Andreas Dilger)
Date: Thu, 3 Nov 2016 18:27:26 -0600
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <20161103204357.r7lgvbsv3euujijn@thunk.org>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <20161102224827.GJ14023@dastard> <20161103204357.r7lgvbsv3euujijn@thunk.org>
Message-ID: <1206C36E-9CB4-47B3-A891-8EA94C3220E0@dilger.ca>


> On Nov 3, 2016, at 2:43 PM, Theodore Ts'o <tytso at mit.edu> wrote:
> 
> On Thu, Nov 03, 2016 at 09:48:27AM +1100, Dave Chinner wrote:
>> 
>> We're going to need regression tests for this to ensure that it
>> works properly and that we don't inadvertantly break it in future.
>> Can you write some xfstests that exercise this functionality and
>> validate that the mount behaviour, clamping and range limiting is
>> working as intended?
> 
> In order to have automated regression tests which are file system
> independent, we need a way to query what are the timestamps that a
> particular mounted file systme supports.  One approach would be to use
> fsinfo, which David Howells had been working on, but which has been
> bike-shedded to death for the last n years, and I'd hate to block this
> patch series behind a proposed new fsinfo(2) system call.

I wish we could just get the fsinfo and statx calls landed, but I agree
it would be a DOS to block any other patches waiting for that to land...

or maybe we _should_ block other patches behind that patch, and force it
to be landed... :-)

> Alternatively, we can just create a specialized ioctl to return that
> information which is non-ideal in other dimensions.
> 
> The last option, which is admittedly ugly, would be to create an shell
> function which knows how to figure out the max_timestamp and
> min_timestamp by using the file system name and querying the
> superblock using dumpe2fs, xfs_db, etc.
> 
> I'd argue for the last option because once we do get a programmtic way
> to get the information via a system call such as fsinfo(2), we can
> convert xfstests to use it, where as if we add an ioctl to return this
> information, we'll have to support the ioctl forever.
> 
> Does this make sense?   Any objections?

Realistically, there are only a handful of filesystems being tested by
xfstests, and it is simple enough to hard-code these limits into the
test script for ext4, xfs, btrfs, etc. since the limits will not be
changing very often (and it is noteworthy when they do).  If and when
there is an interface to query these values from the kernel, it may
still make sense to keep the hard-coded limits to verify the syscall
against...

Cheers, Andreas





-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.infradead.org/pipermail/linux-afs/attachments/20161103/3f7f12c9/attachment.sig>

From deepa.kernel at gmail.com  Sun Nov  6 09:44:33 2016
From: deepa.kernel at gmail.com (Deepa Dinamani)
Date: Sun, 6 Nov 2016 09:44:33 -0800
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <1206C36E-9CB4-47B3-A891-8EA94C3220E0@dilger.ca>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <20161102224827.GJ14023@dastard> <20161103204357.r7lgvbsv3euujijn@thunk.org>
 <1206C36E-9CB4-47B3-A891-8EA94C3220E0@dilger.ca>
Message-ID: <CABeXuvoCANJohBWy4mpJFiYvJj0XNHKVpW1RWhXVrd9ZjT5FSQ@mail.gmail.com>

I will post xfs tests that validate mount and range checking.
I will keep the policy same as what the RFC suggests for now.

Clamping can be verified once vfs is transitioned to using time64_t.

Thanks,
Deepa


From arnd at arndb.de  Sun Nov  6 12:28:37 2016
From: arnd at arndb.de (Arnd Bergmann)
Date: Sun, 06 Nov 2016 21:28:37 +0100
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <CABeXuvoCANJohBWy4mpJFiYvJj0XNHKVpW1RWhXVrd9ZjT5FSQ@mail.gmail.com>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <1206C36E-9CB4-47B3-A891-8EA94C3220E0@dilger.ca>
 <CABeXuvoCANJohBWy4mpJFiYvJj0XNHKVpW1RWhXVrd9ZjT5FSQ@mail.gmail.com>
Message-ID: <147897712.8Iuj6e9dPp@wuerfel>

On Sunday, November 6, 2016 9:44:33 AM CET Deepa Dinamani wrote:
> I will post xfs tests that validate mount and range checking.
> I will keep the policy same as what the RFC suggests for now.
> 
> Clamping can be verified once vfs is transitioned to using time64_t.

Won't it already work as expected on 64-bit architectures as they
have a 64-bit time_t?

	Arnd


From deepa.kernel at gmail.com  Sun Nov  6 13:14:05 2016
From: deepa.kernel at gmail.com (Deepa Dinamani)
Date: Sun, 6 Nov 2016 13:14:05 -0800
Subject: [RFC 0/6] vfs: Add timestamp range check support
In-Reply-To: <147897712.8Iuj6e9dPp@wuerfel>
References: <1478099096-25637-1-git-send-email-deepa.kernel@gmail.com>
 <1206C36E-9CB4-47B3-A891-8EA94C3220E0@dilger.ca>
 <CABeXuvoCANJohBWy4mpJFiYvJj0XNHKVpW1RWhXVrd9ZjT5FSQ@mail.gmail.com>
 <147897712.8Iuj6e9dPp@wuerfel>
Message-ID: <CABeXuvq5LyREPV1OqFvXb7HKXxQ9hQBh4G5oYTg-jchRwKa-EA@mail.gmail.com>

On Sun, Nov 6, 2016 at 12:28 PM, Arnd Bergmann <arnd at arndb.de> wrote:
> On Sunday, November 6, 2016 9:44:33 AM CET Deepa Dinamani wrote:
>> I will post xfs tests that validate mount and range checking.
>> I will keep the policy same as what the RFC suggests for now.
>>
>> Clamping can be verified once vfs is transitioned to using time64_t.
>
> Won't it already work as expected on 64-bit architectures as they
> have a 64-bit time_t?

Yes, on 64 bit architectures, it should work fine.
32 bit machines will have wrong clamped timestamps though for some filesystems.

I can post a test for clamping that only works on 64 bit machines.

Thanks,
-Deepa


From deepa.kernel at gmail.com  Wed Nov 23 16:47:47 2016
From: deepa.kernel at gmail.com (Deepa Dinamani)
Date: Wed, 23 Nov 2016 16:47:47 -0800
Subject: [RFC 3/6] afs: Add time limits in the super block
In-Reply-To: <1479948470-2397-1-git-send-email-deepa.kernel@gmail.com>
References: <1479948470-2397-1-git-send-email-deepa.kernel@gmail.com>
Message-ID: <1479948470-2397-4-git-send-email-deepa.kernel@gmail.com>

Note that all the filesystems that have such simple limits
will be initialized in the same patch.

Signed-off-by: Deepa Dinamani <deepa.kernel at gmail.com>
Cc: linux-afs at lists.infradead.org
---
 fs/afs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index fbdb022..ab00434 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -321,6 +321,8 @@ static int afs_fill_super(struct super_block *sb,
 	sb->s_op		= &afs_super_ops;
 	sb->s_bdi		= &as->volume->bdi;
 	strlcpy(sb->s_id, as->volume->vlocation->vldb.name, sizeof(sb->s_id));
+	sb->s_time_max = Y2106_EXPIRY_TIMESTAMP;
+	sb->s_time_min = 0;
 
 	/* allocate the root inode and dentry */
 	fid.vid		= as->volume->vid;
-- 
2.7.4



From jaltman at auristor.com  Thu Nov 24 07:37:35 2016
From: jaltman at auristor.com (Jeffrey Altman)
Date: Thu, 24 Nov 2016 10:37:35 -0500
Subject: [RFC 3/6] afs: Add time limits in the super block
In-Reply-To: <1479948470-2397-4-git-send-email-deepa.kernel@gmail.com>
References: <1479948470-2397-1-git-send-email-deepa.kernel@gmail.com>
 <1479948470-2397-4-git-send-email-deepa.kernel@gmail.com>
Message-ID: <9522bd08-a08d-df04-edef-f3d3bb60ec03@auristor.com>

Timestamps in afs3 are signed 32-bit.   The range is from -2^31-1 to
2^31 not 0 to 2^32.

Jeffrey Altman

On 11/23/2016 7:47 PM, Deepa Dinamani wrote:
> Note that all the filesystems that have such simple limits
> will be initialized in the same patch.
> 
> Signed-off-by: Deepa Dinamani <deepa.kernel at gmail.com>
> Cc: linux-afs at lists.infradead.org
> ---
>  fs/afs/super.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/afs/super.c b/fs/afs/super.c
> index fbdb022..ab00434 100644
> --- a/fs/afs/super.c
> +++ b/fs/afs/super.c
> @@ -321,6 +321,8 @@ static int afs_fill_super(struct super_block *sb,
>  	sb->s_op		= &afs_super_ops;
>  	sb->s_bdi		= &as->volume->bdi;
>  	strlcpy(sb->s_id, as->volume->vlocation->vldb.name, sizeof(sb->s_id));
> +	sb->s_time_max = Y2106_EXPIRY_TIMESTAMP;
> +	sb->s_time_min = 0;
>  
>  	/* allocate the root inode and dentry */
>  	fid.vid		= as->volume->vid;
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: jaltman.vcf
Type: text/x-vcard
Size: 395 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-afs/attachments/20161124/2447828f/attachment.vcf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4057 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.infradead.org/pipermail/linux-afs/attachments/20161124/2447828f/attachment.p7s>

From dan.carpenter at oracle.com  Wed Nov 30 13:12:04 2016
From: dan.carpenter at oracle.com (Dan Carpenter)
Date: Thu, 1 Dec 2016 00:12:04 +0300
Subject: [bug report] [AF_RXRPC]: Make the in-kernel AFS filesystem use
 AF_RXRPC.
Message-ID: <20161130211203.GA9389@mwanda>

Hello David Howells,

The patch 08e0e7c82eea: "[AF_RXRPC]: Make the in-kernel AFS
filesystem use AF_RXRPC." from Apr 26, 2007, leads to the following
static checker warning:

	fs/afs/cmservice.c:155 SRXAFSCB_CallBack()
	error: dereferencing freed memory 'call'

fs/afs/cmservice.c
   139  /*
   140   * allow the fileserver to see if the cache manager is still alive
   141   */
   142  static void SRXAFSCB_CallBack(struct work_struct *work)
   143  {
   144          struct afs_call *call = container_of(work, struct afs_call, work);
   145  
   146          _enter("");
   147  
   148          /* be sure to send the reply *before* attempting to spam the AFS server
   149           * with FSFetchStatus requests on the vnodes with broken callbacks lest
   150           * the AFS server get into a vicious cycle of trying to break further
   151           * callbacks because it hadn't received completion of the CBCallBack op
   152           * yet */
   153          afs_send_empty_reply(call);

If afs_send_empty_reply() has an error besides -ENOMEM then it frees
call.

   154  
   155          afs_break_callbacks(call->server, call->count, call->request);
                                    ^^^^^^^^^^^^
NULL dereference.  I feel like the fix is to not free call but really I
have no idea.

   156          _leave("");
   157  }

regards,
dan carpenter


