Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp448674imm; Thu, 12 Jul 2018 23:48:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeTdoMCQhWd2Lf9v+1s5xh0fsav16GX0NogX5WPm2RexEnI4cvt2kez7kJPzftBwWJI/caz X-Received: by 2002:a17:902:b18c:: with SMTP id s12-v6mr5131593plr.187.1531464481244; Thu, 12 Jul 2018 23:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531464481; cv=none; d=google.com; s=arc-20160816; b=lxbzwatysuER2uktNeQSox25JeIlf+iEjA0onZvOsgFPVJ69gW9DW4oyOFgiXUY1U9 bUFLR8gPXv+kuGPxVN7e7+sIQaw9jKSpXdAHHxCDQgpTnA6qjIqUzjrQLY2HooedBX94 Ml9nDuAhx4vzSTkEpUoQwwrNQDkKOul4Xg5wnHc/l+r/XoXwjR2uzE50fJ12SR0fQGfk 6viOflu0j9nUmZvEfmAHvfoUC+ikaJWDA25LqCG9kbwZ7ybmSgVdXTCg6kuMhTfO5Hnj N3LLkH5rpDInUseC16O6p//cMKYJpmEtP/YVikig+I80yuVhqy6srBem8YpJ3zuzGY18 Yxvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=pErKYYMrgQTAGbZXblSTDAyPnGEyBoAwxvgXXd+p+68=; b=sN4v2p7hstNmvUkyYKb2S7Zr9dkVmssdNMbDL77DeyaZEti1RcPslF8NbWvBxE63PP HK4MSu09ubktBCD4aocEgHsem0G2l9AcH1EqZIETYp3QldjQvwdWqm0r/RewICl9qdeY VMNNZNz9u6+m/c5F6vkYWirhFiLPEr3SK80HD1P8V6jvKdg7ZjNfjn6o9G+YHXRKM9lQ tIFEMssAMcyvzHx/UAGjxQJXQHw01dEwMRrvoDfU8cE161ySkdT8woGLmz8WLDax782v k/40NvqwEiawKL46OOGQkMGFlZpntqp6rvFerROxChSHPon7pDSV7N9Bz3C120h4Fu1D 4Www== 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 y2-v6si22762589plp.459.2018.07.12.23.47.45; Thu, 12 Jul 2018 23:48:01 -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; 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 S1729175AbeGMHAZ (ORCPT + 99 others); Fri, 13 Jul 2018 03:00:25 -0400 Received: from mail.parknet.co.jp ([210.171.160.6]:34352 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbeGMHAY (ORCPT ); Fri, 13 Jul 2018 03:00:24 -0400 Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id 05BDBADF6A; Fri, 13 Jul 2018 15:47:11 +0900 (JST) Received: from devron.myhome.or.jp (foobar@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.15.2/8.15.2/Debian-11) with ESMTPS id w6D6l9bP020758 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Jul 2018 15:47:10 +0900 Received: from devron.myhome.or.jp (foobar@localhost [127.0.0.1]) by devron.myhome.or.jp (8.15.2/8.15.2/Debian-11) with ESMTPS id w6D6l9hd025264 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 Jul 2018 15:47:09 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id w6D6l8BJ025263; Fri, 13 Jul 2018 15:47:08 +0900 From: OGAWA Hirofumi To: Andrew Morton Cc: linux-kernel@vger.kernel.org, "Wang\, Matt" , "dan.carpenter\@oracle.com" Subject: [PATCH] fat: Fix potential shift wrap with FITRIM ioctl on FAT References: Date: Fri, 13 Jul 2018 15:47:08 +0900 In-Reply-To: (Matt Wang's message of "Fri, 13 Jul 2018 03:37:23 +0000") Message-ID: <87h8l37hub.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is the fix of fat-add-fitrim-ioctl-for-fat-file-system.patch. Maybe better to merge with it (if it is easy). Anyway, please apply this with above patch. -------- From: Wentao Wang If we keep "trimmed" as an u32, there will be a potential shift wrap. It would be a problem on a larger than 4GB partition with FAT32. Though most tools who call this ioctl would ignore this value, it would be great to fix it. Signed-off-by: Wentao Wang Signed-off-by: OGAWA Hirofumi --- fs/fat/fatent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN fs/fat/fatent.c~fat-fitrim-fix fs/fat/fatent.c --- linux/fs/fat/fatent.c~fat-fitrim-fix 2018-07-13 15:39:14.417110998 +0900 +++ linux-hirofumi/fs/fat/fatent.c 2018-07-13 15:39:14.418110996 +0900 @@ -705,8 +705,8 @@ int fat_trim_fs(struct inode *inode, str struct msdos_sb_info *sbi = MSDOS_SB(sb); const struct fatent_operations *ops = sbi->fatent_ops; struct fat_entry fatent; - u64 ent_start, ent_end, minlen; - u32 free = 0, trimmed = 0; + u64 ent_start, ent_end, minlen, trimmed = 0; + u32 free = 0; unsigned long reada_blocks, reada_mask, cur_block = 0; int err = 0; _ -- OGAWA Hirofumi