Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1696672imu; Thu, 17 Jan 2019 01:36:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN5qlqbV27xZE9g8/PGqp4TO+TZVh9cSlQtJ9ruucwE6zORPpZxKZa1XrD8+jnV//F5gS7V1 X-Received: by 2002:a17:902:9a46:: with SMTP id x6mr1999700plv.94.1547717794779; Thu, 17 Jan 2019 01:36:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547717794; cv=none; d=google.com; s=arc-20160816; b=vQ45B3do9q7dHoVvnC194Z+nNQYQjpzE/gMpz84EKymlVrsmYaBvM+d9WcMsqX682m +kiVqboDmdaY8RrX+TnkhcK+mqmsLXO/qpFR7MJVeJDK4kVOiwiykjdJS79fPoQh1mo6 ZTe3ghREzq6/N5E+KngwFAAFL8HMA4knjGFAdFk7j2LlxFU9ljeBUtkHYPKg87MJXN3j h/vyV1lHFeN7AQ1HD4bT/oAZngixlMvl3OAzajFLHAxJ/QZHhsHrxj93lI04+N1gBc1h g3SMCtQyDB9oqYIcNrUQa7xcYjMEPytAxCXriZ8faBbVy+sh7ci730cYdlAveDNSBpAr qvPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Dy7l1ZIbzoibOViDXD6jGkp5sep3JBrVsjs050F+02s=; b=RKch3lnE6HQevC8/s3vF2t7utTMZqdOKXWmgH5lzOJ7kIzG3NmacSfUbUh3PrXuh2p djrFzwmUEK9/PQNHrc7jl4ys000XrJvZ5UVDv4ldg+npr+EQhJ0HlBYoYQ9UbAGCzbLU zKPkfYzBkBgemUQMJ+odURQiZVhxmg9z4UJho6v9rEtDlYIOMouautR63Ake81UNlwZ8 4CP2BGgI5DeYnOyrYxHWIyBJNQqjsvblhBFqXgxFn4F1jxFu+byoVpvBHB1AipCXNiLe ufom6WaDW/QELT78lbEWDATUs7j8IDi/JgiLdrLb9UHbPGB8FwPMr5wGRZEW+xLKi1/0 77gg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si1166855pgg.290.2019.01.17.01.36.19; Thu, 17 Jan 2019 01:36:34 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730068AbfAQISS (ORCPT + 99 others); Thu, 17 Jan 2019 03:18:18 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:47602 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727343AbfAQISS (ORCPT ); Thu, 17 Jan 2019 03:18:18 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E521F326D8204A3BC4F3; Thu, 17 Jan 2019 16:18:14 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 17 Jan 2019 16:18:05 +0800 From: zhengbin To: , CC: , , Subject: [PATCH] squashfs: fix mtime underflow on 64 bit system Date: Thu, 17 Jan 2019 16:21:48 +0800 Message-ID: <20190117082148.129347-1-zhengbin13@huawei.com> X-Mailer: git-send-email 2.16.2.dirty MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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