Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1034013ybt; Wed, 8 Jul 2020 19:01:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4dpVtHXMTaCZEpV/y55Mib0HSI+zNZHPd+h9Wp7grZTgnmYcnGqILnqptTZzfeJWBGdO/ X-Received: by 2002:a05:6402:3113:: with SMTP id dc19mr68642558edb.20.1594260087470; Wed, 08 Jul 2020 19:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594260087; cv=none; d=google.com; s=arc-20160816; b=lkZio/LutueGriB1YKzanWJ15TB2uL+k7GI2UONcapAlt8sAsxLCIXHGaz/Y1phX4s xahj5CjbEcWY6uZNpOZPpSoKTuKg1RoVvWJqBfohGz6aX+UJRkeBwCunXjtKkLaMIiPm ZztAUaC4LLwBleAqKGTpZnV5ZpJJKhVcVb8sF2zCogdI6PuWZaZ8HJACcCnnsKm4gDzn kiISejBoGUZ+l8gJ8Uk4+2n2vCbBrF+2PLf3jtmO1Rwz2U3AmuUfQlMG7g8rb4P34pLG EswccB1qM5j+CK/DRK+mHAqwqPzD9woHoin70Uvg+JqF/RTSWLQ/LdajF44OXAZx3zjx Vcxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3EOJ8u6cUBdJpk7YFY5mzmvMLrW3UokFC1yt6TbWqsM=; b=R3jimSeKNQ5ocdeLwm6zwFKU1itGLPuJp+F9IA2SmgnWsF6/q4Ov4JIXjP48ClV3Kf +JETigkGpRBTd1I5Ue2HiHDolGULX9IqlWXEnUNLeRpU20rkD8ncUJ8BxYc+Bzee+Sg3 oQ9i38wKF26hp7P75x7UN9FXkwfv4KQy0XDc35TMlUP+TgG+cbR2ynm8quEVuGSgQ65w fkdq6uOc0qagcV7XEOE0wkA3p4p+5R90jvDm7PtaGhI8tsuHThdXienKTGZTYAliMIJe KNxT8FshTzlJYsAzvEZAGRRNv8mVEJYS3+zc7oPEEW4/853kIT3sAzytEQn6RV+53XTc fR1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rpT763Zt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ok24si973257ejb.491.2020.07.08.19.01.04; Wed, 08 Jul 2020 19:01:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rpT763Zt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726194AbgGIB5r (ORCPT + 99 others); Wed, 8 Jul 2020 21:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgGIB5q (ORCPT ); Wed, 8 Jul 2020 21:57:46 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC23C061A0B for ; Wed, 8 Jul 2020 18:57:46 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id u18so299033pfk.10 for ; Wed, 08 Jul 2020 18:57:46 -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:mime-version :content-transfer-encoding; bh=3EOJ8u6cUBdJpk7YFY5mzmvMLrW3UokFC1yt6TbWqsM=; b=rpT763ZtXVtRFJZzC+mYrDD5V0TzXR8UbA3D8mmCaw7nudYZxGAy3M7MZ35tvaf0U4 QSQKbBP4QqPbDs9WKeGDkwoaTWygs6EPVNIOS1JoHnlyhwEv1YzsknMBahVKtsuZ9eZE sEIsGewAi3aLHSDEO20X27Aq7AKOBGTRo81IiQppu7LojOnsJL+N3klBSjZ7NHs3ur7Q XQ1CFoRzJOcpOfxcNWEgMTzVtr/yhL00CCVXeYGJJqAfKKXeVTcYF5oGzdEiKw/2PwWE ZSK+Ue8OQZ4YbL3AJI0DpasraKyocSXJVT0VYFwitIxbVstapK5yQ5RLHUvgImJ/1Od5 rOeA== 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:mime-version :content-transfer-encoding; bh=3EOJ8u6cUBdJpk7YFY5mzmvMLrW3UokFC1yt6TbWqsM=; b=G30aXOPCb5Uk7Jm4rcpfapUAFnomuVCj+zHLyKiV4od0C9Su44tUqRYTMdsK0ghjLL Vc4fQYx7ltVJYLJow7AAyBL68waEc56MvezKb+dXY1dOrg8PwdhcRepg083dVs8byjcO Dhxz4JTjD3J/HmcAy/6qRPzH/PXaRVaeOjydhRqF02QzSCbfnsF2okF7jMky7iepi3u6 5x9BY6Cqh0fwnQiApJxvF1pRpFl3fH8+WXM/rJaxHKjFoHxOal++M15Pf/P8B8Kus3ow 2WvQ8DZQMh1FKGCkVsuLL0Tw+aZI5URvlCbtNPUQh4SbnCWCH6/J8JEtfbjj16L0tiDN O9vg== X-Gm-Message-State: AOAM533eVLTm9UPKab9jMD11OxhG4ox5VIZr/S8t1jnkmVcOFNG4d16M 7/ocO/5a2sLKbjGcBrSNK7MAIk0NytsoPA== X-Received: by 2002:a63:6c1:: with SMTP id 184mr53624374pgg.262.1594259865770; Wed, 08 Jul 2020 18:57:45 -0700 (PDT) Received: from daehojeong1.seo.corp.google.com ([2401:fa00:d:1:a6ae:11ff:fe18:6ce2]) by smtp.gmail.com with ESMTPSA id i21sm911219pfa.18.2020.07.08.18.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 18:57:45 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong Subject: [PATCH] f2fs: ignore when len of range in f2fs_sec_trim_file is zero Date: Thu, 9 Jul 2020 10:57:39 +0900 Message-Id: <20200709015739.1653668-1-daeho43@gmail.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daeho Jeong When end_addr comes to zero, it'll trigger different behaviour. To prevent this, we need to ignore the case of that range.len is zero in the function. Signed-off-by: Daeho Jeong --- fs/f2fs/file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 368c80f8e2a1..98b0a8dbf669 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3813,15 +3813,14 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) file_start_write(filp); inode_lock(inode); - if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) { + if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode) || + range.start >= inode->i_size) { ret = -EINVAL; goto err; } - if (range.start >= inode->i_size) { - ret = -EINVAL; + if (range.len == 0) goto err; - } if (inode->i_size - range.start < range.len) { ret = -E2BIG; -- 2.27.0.383.g050319c2ae-goog