Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1769257ybl; Sun, 18 Aug 2019 10:03:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz66MJDtSfDM1JNmIJl/IZM1Wag49D3ZxYtd+I2y42E9iTemor9Ftn3TwKFVlEpn1YbHuFQ X-Received: by 2002:a63:8ac3:: with SMTP id y186mr16431079pgd.13.1566147783494; Sun, 18 Aug 2019 10:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566147783; cv=none; d=google.com; s=arc-20160816; b=D3e5/NR60Os+0AGys1xZ/emr8rXAzvJ2mtnToJAxHm1wfW7wC7Tt1BioLvyuh6r6c2 2DGal7dMvuqLvUBVgIHxrejq0F1Ass+GSb3niv5nlu4c+0iRefNFMsgTJ4Mw26Eoi9DZ wg1o+TgdIdPw3M4DKdkGHmttlmRql5oHBMV9AjZ07sSXqG1zM0o+dKI2l8QMLZdw9xaI nGpLanw2vLMFLl3q1Tzv2z3xBDmqea5B9/JXc3uK2nZrrmoD0y0pCKephx81ZTZ6mC/G 5UKMq5rIE2SZIriutqhGfe/6ULUhabmTl361QKNzCFMLHtoEYftfRkyOXyJ6dS3mD8p3 8dXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=A08CQyPF693tmDGwyR4szt4dpA6CyB4J0ZetXSJxCsI=; b=doD58wsPi3FEJ+vlot7W35lIoC485upZHSuc92lx9AXgzeC7xM61tCo7ileLtZfZuv x6FnCAwyGAUv+2QACVWLzZXWQczahnPwopJAnw2wb8H+99mAVlD0VmSoF0qwUcX40xdV dBemsKnA4Jkjbjq4ly0sx75QV5VQuQr10fJ+wJ/4y+G7JSrAWEfUUeUJVcqIRCtqxXEV llIvBYvEwKqmkeXqsfy48nbkTtiOJa09XYfQNtpDPxUhRhfNdKQq61Tub4STtkSytE9s QyCoGZx53ldzktWRwfZGukuxwZjEZcP2ot47n/4BHrfBBGREYl5qW1tay3Av+7m5Yc8g mHEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D3UzYMN0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si8369580ply.113.2019.08.18.10.02.49; Sun, 18 Aug 2019 10:03:03 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D3UzYMN0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbfHRRAC (ORCPT + 99 others); Sun, 18 Aug 2019 13:00:02 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46171 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbfHRQ76 (ORCPT ); Sun, 18 Aug 2019 12:59:58 -0400 Received: by mail-pf1-f193.google.com with SMTP id q139so5701037pfc.13; Sun, 18 Aug 2019 09:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A08CQyPF693tmDGwyR4szt4dpA6CyB4J0ZetXSJxCsI=; b=D3UzYMN0ubh5OjWIPnDT31k0PC+Ich0Iti3pY8agIwmBEfh4giotU36w7CPi4aJUDi A8TNhlzmGX8N3gYYHeBmUl5gYG1Aps4+iKvb4f35zC5C7YcEEC0OByyfZWa1rn/O49Lt 68+eVWloTEJkFhTCp2xX+kNHj9dt3X6uBFi3jpq9OyZizQHEbx5k2zmja0JwdM+28t0l TTWijpf7HfhmcQwyCcJFnxlwAI2YEXMtQPIkITSGzA8Im21zk2spABQgrB8RRZWFQ5AU eehoFZArqJHemcbdJURNxrYnz49EKHnREgfoC+d2IpP+KePg604bCIye/3bBbLZYyXF8 t7Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A08CQyPF693tmDGwyR4szt4dpA6CyB4J0ZetXSJxCsI=; b=Ynx1pVjBnrU7GxTbal9W/qxIhZKTgV0CpJjFSe2z9ZwTX1Yp4f6hKN7mNfPIUD3aPM ow0PnU9t+UQotLQcE/VlZIExAWnjge2M1LYN+i1NOrPl5evmIOr8cg0qF8hXBfNsnX+L wZ9d5ML51sqyUEjNcaielekw7I02fXZy7WYDm/IuzPIxQtRK8e4Dj8wmRpbJ2f1Voas6 MXr9j9Qccze7lr4F0+Ix1M9ydfeMrApKu9ZVdGgui8fRgDdBA+gI0RrEBMH+wJ8H6dz6 KrrHBTGN/V2uu6j5wzfbihVckquHjxkMZIJ5wSIM7Aq02cS3CtYLnIJXcrLmnA+K3VyN bppg== X-Gm-Message-State: APjAAAUv16emr1UkKFDghmcIC6JQPs8yaYjlftwix38URLJ5RTMkoIko oquhYMSPAKoGq/Gxf/ZOMmg= X-Received: by 2002:a63:b10f:: with SMTP id r15mr16218681pgf.230.1566147597851; Sun, 18 Aug 2019 09:59:57 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:57 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, hirofumi@mail.parknet.co.jp Subject: [PATCH v8 12/20] fs: fat: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:09 -0700 Message-Id: <20190818165817.32634-13-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Some FAT variants indicate that the years after 2099 are not supported. Since commit 7decd1cb0305 ("fat: Fix and cleanup timestamp conversion") we support the full range of years that can be represented, up to 2107. Signed-off-by: Deepa Dinamani Cc: hirofumi@mail.parknet.co.jp --- fs/fat/inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 0bc2abc5d453..f27f84e2103f 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -31,6 +31,11 @@ #define KB_IN_SECTORS 2 +/* DOS dates from 1980/1/1 through 2107/12/31 */ +#define FAT_DATE_MIN (0<<9 | 1<<5 | 1) +#define FAT_DATE_MAX (127<<9 | 12<<5 | 31) +#define FAT_TIME_MAX (23<<11 | 59<<5 | 29) + /* * A deserialized copy of the on-disk structure laid out in struct * fat_boot_sector. @@ -1617,6 +1622,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, int debug; long error; char buf[50]; + struct timespec64 ts; /* * GFP_KERNEL is ok here, because while we do hold the @@ -1710,6 +1716,12 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, sbi->free_clus_valid = 0; sbi->prev_free = FAT_START_ENT; sb->s_maxbytes = 0xffffffff; + fat_time_fat2unix(sbi, &ts, 0, cpu_to_le16(FAT_DATE_MIN), 0); + sb->s_time_min = ts.tv_sec; + + fat_time_fat2unix(sbi, &ts, cpu_to_le16(FAT_TIME_MAX), + cpu_to_le16(FAT_DATE_MAX), 0); + sb->s_time_max = ts.tv_sec; if (!sbi->fat_length && bpb.fat32_length) { struct fat_boot_fsinfo *fsinfo; -- 2.17.1