From: zhengbin <zhengbin13@huawei.com>
To: <phillip@squashfs.org.uk>, <linux-kernel@vger.kernel.org>
Cc: <houtao1@huawei.com>, <zhaohongjiang@huawei.com>,
<zhengbin13@huawei.com>
Subject: [PATCH] squashfs: fix mtime underflow on 64 bit system
Date: Thu, 17 Jan 2019 16:21:48 +0800 [thread overview]
Message-ID: <20190117082148.129347-1-zhengbin13@huawei.com> (raw)
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
next reply other threads:[~2019-01-17 8:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 8:21 zhengbin [this message]
2019-01-21 2:18 ` zhengbin (A)
2019-01-23 9:00 ` zhengbin (A)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190117082148.129347-1-zhengbin13@huawei.com \
--to=zhengbin13@huawei.com \
--cc=houtao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@squashfs.org.uk \
--cc=zhaohongjiang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®