All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] squashfs: fix mtime underflow on 64 bit system
@ 2019-01-17  8:21 zhengbin
  2019-01-21  2:18 ` zhengbin (A)
  2019-01-23  9:00 ` zhengbin (A)
  0 siblings, 2 replies; 3+ messages in thread
From: zhengbin @ 2019-01-17  8:21 UTC (permalink / raw)
  To: phillip, linux-kernel; +Cc: houtao1, zhaohongjiang, zhengbin13

If we change the file mtime to 1969, mksquashfs and mount,
the atime/mtime of this file will be underflow. The reason is
treating timestamps with the high bit set as positive
times(before 1970), which should be set as negative times
just like on 32 bit system. After this, the poissble range
of timestamps will be 1901-2038(prev is 1970-2106) on 64
bit system.

Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/squashfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index e9793b1e49a5..03a6ef77a2d2 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -72,7 +72,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
 	i_uid_write(inode, i_uid);
 	i_gid_write(inode, i_gid);
 	inode->i_ino = le32_to_cpu(sqsh_ino->inode_number);
-	inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime);
+	inode->i_mtime.tv_sec = (signed int)le32_to_cpu(sqsh_ino->mtime);
 	inode->i_atime.tv_sec = inode->i_mtime.tv_sec;
 	inode->i_ctime.tv_sec = inode->i_mtime.tv_sec;
 	inode->i_mode = le16_to_cpu(sqsh_ino->mode);
--
2.16.2.dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] squashfs: fix mtime underflow on 64 bit system
  2019-01-17  8:21 [PATCH] squashfs: fix mtime underflow on 64 bit system zhengbin
@ 2019-01-21  2:18 ` zhengbin (A)
  2019-01-23  9:00 ` zhengbin (A)
  1 sibling, 0 replies; 3+ messages in thread
From: zhengbin (A) @ 2019-01-21  2:18 UTC (permalink / raw)
  To: phillip, linux-kernel; +Cc: houtao1, zhaohongjiang

hi Phillip, when you have time, help to confirm it?

Looking forward to your reply.

On 2019/1/17 16:21, zhengbin wrote:
> If we change the file mtime to 1969, mksquashfs and mount,
> the atime/mtime of this file will be underflow. The reason is
> treating timestamps with the high bit set as positive
> times(before 1970), which should be set as negative times
> just like on 32 bit system. After this, the poissble range
> of timestamps will be 1901-2038(prev is 1970-2106) on 64
> bit system.
> 
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/squashfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
> index e9793b1e49a5..03a6ef77a2d2 100644
> --- a/fs/squashfs/inode.c
> +++ b/fs/squashfs/inode.c
> @@ -72,7 +72,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
>  	i_uid_write(inode, i_uid);
>  	i_gid_write(inode, i_gid);
>  	inode->i_ino = le32_to_cpu(sqsh_ino->inode_number);
> -	inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime);
> +	inode->i_mtime.tv_sec = (signed int)le32_to_cpu(sqsh_ino->mtime);
>  	inode->i_atime.tv_sec = inode->i_mtime.tv_sec;
>  	inode->i_ctime.tv_sec = inode->i_mtime.tv_sec;
>  	inode->i_mode = le16_to_cpu(sqsh_ino->mode);
> --
> 2.16.2.dirty
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] squashfs: fix mtime underflow on 64 bit system
  2019-01-17  8:21 [PATCH] squashfs: fix mtime underflow on 64 bit system zhengbin
  2019-01-21  2:18 ` zhengbin (A)
@ 2019-01-23  9:00 ` zhengbin (A)
  1 sibling, 0 replies; 3+ messages in thread
From: zhengbin (A) @ 2019-01-23  9:00 UTC (permalink / raw)
  To: phillip, linux-kernel; +Cc: houtao1, zhaohongjiang

Ping?

On 2019/1/17 16:21, zhengbin wrote:
> If we change the file mtime to 1969, mksquashfs and mount,
> the atime/mtime of this file will be underflow. The reason is
> treating timestamps with the high bit set as positive
> times(before 1970), which should be set as negative times
> just like on 32 bit system. After this, the poissble range
> of timestamps will be 1901-2038(prev is 1970-2106) on 64
> bit system.
> 
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/squashfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
> index e9793b1e49a5..03a6ef77a2d2 100644
> --- a/fs/squashfs/inode.c
> +++ b/fs/squashfs/inode.c
> @@ -72,7 +72,7 @@ static int squashfs_new_inode(struct super_block *sb, struct inode *inode,
>  	i_uid_write(inode, i_uid);
>  	i_gid_write(inode, i_gid);
>  	inode->i_ino = le32_to_cpu(sqsh_ino->inode_number);
> -	inode->i_mtime.tv_sec = le32_to_cpu(sqsh_ino->mtime);
> +	inode->i_mtime.tv_sec = (signed int)le32_to_cpu(sqsh_ino->mtime);
>  	inode->i_atime.tv_sec = inode->i_mtime.tv_sec;
>  	inode->i_ctime.tv_sec = inode->i_mtime.tv_sec;
>  	inode->i_mode = le16_to_cpu(sqsh_ino->mode);
> --
> 2.16.2.dirty
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-23  9:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17  8:21 [PATCH] squashfs: fix mtime underflow on 64 bit system zhengbin
2019-01-21  2:18 ` zhengbin (A)
2019-01-23  9:00 ` zhengbin (A)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.