From patchwork Fri Sep 20 12:26:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Sun X-Patchwork-Id: 13808503 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7EB64D8BC; Fri, 20 Sep 2024 12:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726835189; cv=none; b=a0hmTNiqtSlwtECP3U6naHtZDo+UV5xQXw8pxoDhTJogvVc8fWCaMP1yQn8enve4CrlImNwyzq3E2L85m3qMt4XbCXfb5rA2KVSHRaAXdexssEhAs1FiPCgqGEf7fAtf1ouIcdfM6gDjJ/MrCMNQe4YaZdxHeqQ4Tf+QMEAlw60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726835189; c=relaxed/simple; bh=mSNpVrGkUzG7bbkjRfuqgS+HiG0Plamfz+z/RqBSPBI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hoLj6KCWmnXgJWwzqFfbs2T0Yr2L4WyR39L9n1svqYwWlC/JjiaM7pzX3YYB4jfxtvPpLFeGt3t0HVMl/4gmi3XpPSdt7Nv8Z3rJu9xzlhUPv7nvgaiCvAQHld45wbghNFpOVAywHN4S8vtarrqU287E/8+QxgfL4VW4bfPbNho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bj2OLf5R; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bj2OLf5R" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-208cf673b8dso19856885ad.3; Fri, 20 Sep 2024 05:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726835186; x=1727439986; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I2xeFOlTV6cuYMDLWWIw/VyeWKk2em0CeD8UdrtQixw=; b=bj2OLf5Rd4QY1sCo6ywMCy8tvxetRbvNLXT9bfI8KFgWJO0zh5vGAiEfmWaHAxAIXQ HFhvA+A/dByDwrhhO3WvDc15KU7LHA8fZDTUqJAoQmwk9YRL0UT31F80uzLJqUVGRZQT OeyDZjGlgCrmWMYmF8Cso4BjFcDAyOkZedje1hW1d2iPzo9L5uoC0CxNzcFn0qYZbUgs 1owKz3DafXgJ+gDXjYVdv1zcTxJUjxNtsC/sx9IK/E4Tc0zDiazizu6g4mjIyc/Xu2Ho AMCdE7kKuCkWNv2t8YzGjWsc3Hag8/s1BpUgWHpLO260NsxDK+LOIdnSqA4fHC4NSWKp Se/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726835186; x=1727439986; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I2xeFOlTV6cuYMDLWWIw/VyeWKk2em0CeD8UdrtQixw=; b=q8Mab+AICEM7sD5mR8iN8l4wHmUaTnjdCVNvc9uyaAaKjXXYuNFq1zaxIednUYSxbf BUquBhB2UYvKZcF8NJ+JQ3H1QsMWp2ng4mEhLdLpr0aN2teitksKYuwRVG0Qg5V6d6Gu tzxXEOitlS51EfacxNd6PoPROqFWK+dRFwzq/BQ/cyCCDddr0IKYl/LJGfB3Ifyexw0S MrxBZ5ESWyosURCx3aktt2nP83gWW7lekolbyKW+j0ejkrZAzfcUaT1xDpzNpWy5v6eo Iq6p5/q01ipWYqoGibAWPxyudQH3BK+3McFERJZGmtjYzw3B9D1pMWdCtpxb1PuXK4Qw NriQ== X-Forwarded-Encrypted: i=1; AJvYcCVwZvqXFs1eJQZlAAHLpHp8XGFlsa7nFkusvBCl0UlyPOW7Jb4550Z9S5G3zMyN616iHnMd8QAB@vger.kernel.org, AJvYcCXISOGtE7QEqF3uRYd51S8K7eOcGfVX+92zw4JEVZQlgV+zjPEMZoVJkVqIZF4mOiCCGEUrB5kBLag=@vger.kernel.org X-Gm-Message-State: AOJu0YwcR2YvRLGtpO6MnBunXa+Fofe14zwo4wJ8FCWfwk/l1/kFkJkN cXlL7A3TukKcx+krpbIPxnc48rzbTcvh2xBRjB7u64L/LKR5dfJ6X3Ja6Q6Y X-Google-Smtp-Source: AGHT+IEKdH8ny10oL9DmTVGDeKGZTje+hDEfdAp3cprhWsLt2tSOIhebk4gm/bNLhLZ0D/1stCPS4Q== X-Received: by 2002:a17:902:ea12:b0:206:b618:1da8 with SMTP id d9443c01a7336-208d97f0cb5mr35823685ad.17.1726835186385; Fri, 20 Sep 2024 05:26:26 -0700 (PDT) Received: from localhost ([38.207.141.200]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-207945da880sm94410925ad.9.2024.09.20.05.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 05:26:25 -0700 (PDT) From: Julian Sun To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Cc: chandan.babu@oracle.com, djwong@kernel.org, stable@vger.kernel.org, Julian Sun , syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com, Dave Chinner Subject: [PATCH 1/3] xfs: Do not unshare ranges beyond EOF Date: Fri, 20 Sep 2024 20:26:21 +0800 Message-Id: <20240920122621.215397-1-sunjunchao2870@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Attempting to unshare extents beyond EOF will trigger the need zeroing case, which in turn triggers a warning. Therefore, let's skip the unshare process if extents are beyond EOF. Reported-and-tested-by: syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=296b1c84b9cbf306e5a0 Fixes: 32a38a499104 ("iomap: use write_begin to read pages to unshare") Inspired-by: Dave Chinner Signed-off-by: Julian Sun --- fs/xfs/xfs_reflink.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 6fde6ec8092f..65509ff6aba0 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -3,6 +3,7 @@ * Copyright (C) 2016 Oracle. All Rights Reserved. * Author: Darrick J. Wong */ +#include "linux/fs.h" #include "xfs.h" #include "xfs_fs.h" #include "xfs_shared.h" @@ -1669,6 +1670,9 @@ xfs_reflink_unshare( if (!xfs_is_reflink_inode(ip)) return 0; + /* don't try to unshare any ranges beyond EOF. */ + if (offset + len > i_size_read(inode)) + len = i_size_read(inode) - offset; trace_xfs_reflink_unshare(ip, offset, len); From patchwork Fri Sep 20 12:28:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Sun X-Patchwork-Id: 13808504 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA1DD14D431; Fri, 20 Sep 2024 12:28:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726835339; cv=none; b=gPodiOqLG+ZSwmGFrfkCfeoHTJQPJlfWERn72HLXzg2KaL3GXtballJd4s9ooLGjsmhMz9fV0oSxRMB87o3I0skE28Sy3yUjZg+Z379d+1P32EF1llzP6H3e3022l5VJNYt7UBCFBHerdsPp5luSIhaPvfxi6iLQf/uhv/RE7Oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726835339; c=relaxed/simple; bh=0C0JZ+UA1yEmAscOepDgdd0S8z61bIz8VYuFtd0ruwA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=QjQaKGx1AQPKrAj+D7XQQqu0FPQ8sa5a9b0Yyikvmu3gMML0AB1TcBdse9gqGxcNuwnut21nCGAjAmno66jMeJL/v2sFJGJ9ZYDrsPRXze/nzQsQZXuRA2CGIakcmOKKZpxGFMo6DA0XIjucHRjF80YQWcFovOzbzmN7AidttsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BnX0Pxif; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BnX0Pxif" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20543fdb7acso17105255ad.1; Fri, 20 Sep 2024 05:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726835337; x=1727440137; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xCZKrYRGnZp8/QINcXPzi68Vv44RMSIFUQB1DI3ntCg=; b=BnX0Pxifj4nbaWLt1eawX2QKIFfhuShP8nJaYSp7CvxeM2dBxnAco2ZMApS37cnWME eCwZ8ktw9iSKaqFXya87fDfl0QTR6hZTiv77gy+EtCRRIl/zAlA/ABNdg4bTDP3/nDCP EbjVK6PDWP/fxKfM75T8c25H+jnwuocopyz7P1+wfsnaUsPPE/kqb28JbdqdEYWv5KOt 7g/x9LHyHtfhi2l9kolD+7cTo8n8ZzBFVHsEHSFgXmDoKFvYQifM/Kg0Vy/b36tU01V3 tT5kuucSvmjetKQ5HagXGn3I3oG122vgCxYdaXgXzQZ3qGlPc0f8BBd39LIVGm4ESWGD +d3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726835337; x=1727440137; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xCZKrYRGnZp8/QINcXPzi68Vv44RMSIFUQB1DI3ntCg=; b=s3EozwC+jMp8VyDq5votHzmMbpwm9BHcCLtdj3M4MvvBBQKYMjj+9HacHADnlb9aF7 +hz9eEljKkdRHlGSzgP/IgFIs3ZgZkQh7DkG4//4Lvhjd74BZqf/L5wEWa2DclKELZmO WdvejntPOhQIsco1Sro91xjcW8GvMx0cKDUqtcxFMGGCiplVtIDNEGfBzHWmvAGrvBUG nZ7t8exAuQzDctcapmvHztM4v3CTej0JOZ7tH0S5Vg57lw73iDCOcogqU0A9dU3wcKhH XyUSwtw6VGNhkSy2MHbjstda4zz99ufzKHpL4HVXxBF5RJBNun55KTkHkRWW8YApLhGz faxQ== X-Forwarded-Encrypted: i=1; AJvYcCXZ/dws4uGdpm4GdvqoCO2VvWDT7pd9a4Ox0Kv62qjVo458u61pyLgCXI8SXr104UugZ5O7JqoMWcM=@vger.kernel.org, AJvYcCXoUTez4chZmq6HPt4yfWULOQg7y5oPa7wpJkEXGiOkSBZuHBhq64kb3FbSBy0VeBB7gJ1ix6He@vger.kernel.org X-Gm-Message-State: AOJu0YyP8KgjIqc/Bt19Xnm+CPhzY9NkQkLxtk+Maf17phAT3ohhllXN p1R9P4BF4mquawCAuIvlcQ6D04V63HmG3GUQm0blqvFvsAq4H/TH5dQxJuJM X-Google-Smtp-Source: AGHT+IHqMFAI985wyoekDNDZQueMgwrmOzQZ85fJmKSimElHry5xjKW/lB/SBfH3if+HeiadiPo2Fw== X-Received: by 2002:a17:903:1112:b0:205:6a4c:9a20 with SMTP id d9443c01a7336-208d83d67a2mr36018675ad.34.1726835336592; Fri, 20 Sep 2024 05:28:56 -0700 (PDT) Received: from localhost ([38.207.141.200]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20794603792sm94758945ad.106.2024.09.20.05.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 05:28:56 -0700 (PDT) From: Julian Sun To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, stable@vger.kernel.org, Julian Sun , syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com, Dave Chinner Subject: [PATCH 2/3] vfs: Fix implicit conversion problem when testing overflow case Date: Fri, 20 Sep 2024 20:28:51 +0800 Message-Id: <20240920122851.215641-1-sunjunchao2870@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The overflow check in generic_copy_file_checks() and generic_remap_checks() is now broken because the result of the addition is implicitly converted to an unsigned type, which disrupts the comparison with signed numbers. This caused the kernel to not return EOVERFLOW in copy_file_range() call with len is set to 0xffffffffa003e45bul. Use the check_add_overflow() macro to fix this issue. Reported-and-tested-by: syzbot+296b1c84b9cbf306e5a0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=296b1c84b9cbf306e5a0 Fixes: 1383a7ed6749 ("vfs: check file ranges before cloning files") Fixes: 96e6e8f4a68d ("vfs: add missing checks to copy_file_range") Inspired-by: Dave Chinner Reviewed-by: Jan Kara Signed-off-by: Julian Sun Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/read_write.c | 5 +++-- fs/remap_range.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 070a7c33b9dd..5211246edc2e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1509,7 +1509,7 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in, struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); uint64_t count = *req_count; - loff_t size_in; + loff_t size_in, tmp; int ret; ret = generic_file_rw_checks(file_in, file_out); @@ -1544,7 +1544,8 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in, return -ETXTBSY; /* Ensure offsets don't wrap. */ - if (pos_in + count < pos_in || pos_out + count < pos_out) + if (check_add_overflow(pos_in, count, &tmp) || + check_add_overflow(pos_out, count, &tmp)) return -EOVERFLOW; /* Shorten the copy to EOF */ diff --git a/fs/remap_range.c b/fs/remap_range.c index 28246dfc8485..6fdeb3c8cb70 100644 --- a/fs/remap_range.c +++ b/fs/remap_range.c @@ -36,7 +36,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in, struct inode *inode_out = file_out->f_mapping->host; uint64_t count = *req_count; uint64_t bcount; - loff_t size_in, size_out; + loff_t size_in, size_out, tmp; loff_t bs = inode_out->i_sb->s_blocksize; int ret; @@ -45,7 +45,8 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in, return -EINVAL; /* Ensure offsets don't wrap. */ - if (pos_in + count < pos_in || pos_out + count < pos_out) + if (check_add_overflow(pos_in, count, &tmp) || + check_add_overflow(pos_out, count, &tmp)) return -EINVAL; size_in = i_size_read(inode_in); From patchwork Fri Sep 20 12:30:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Sun X-Patchwork-Id: 13808507 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2F4279FE; Fri, 20 Sep 2024 12:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726835431; cv=none; b=lYNztgpFIPDDQ/KbxJD34L9H9EFvEzgpJ37VE5tJjpa15KaVgT2k6msSx/vehWImoROo7EIabIWAM3mIFw0XccIPEtoa/fizGB+CC6jl+scCWbknSP4vTJ3atWDbwQ2Es44FdNh+Dqi7PB5G45nwaDrNYv/9vhXyz8KrXOzd/cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726835431; c=relaxed/simple; bh=vXL+U8ZESkDW3Fz7CembrXw7G0oLm5YisvxKnt8RenU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=J1M4wPZg2Xct/KW4Yg3qaIUK5fPqqf71Km1Cb9FIa1Zeum/09s8qRS73gaqkmGZ13H0rJBQyWAT8xQOf+HPqhOsWfMz1MB2wv9yWf7U07qS4ywCudeK1JM9BN3OIAoqpMccKrQ1rsOTFFuqon1zlS7wWVFq6ZqvXQBcLLIsGY5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j72DXoR/; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j72DXoR/" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2daaa9706a9so1753355a91.1; Fri, 20 Sep 2024 05:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726835428; x=1727440228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Q3rt44kILya/FqXwE7282lJPi+mCIQi4p14blEdUGEI=; b=j72DXoR/SprDxSji90oTpAOgRjmWtIVw0MPuIWxjs5uXe0mX4iH5nk8bZ4wxIinqcI vU9fwAy+ze0diHdPZYFPBPV0VZtR9I9GXZ+XjXbPSRTZmmZfEH2iicQu6DTUPXf2tX8v hdWfzgMN8yWV64itNDvNwk+aTwdkg3JF4SF8briTO8xUr9VPgp2JUJgKYaydEyIKp7gy ARhMK/zh+QFGyG9neR6aSt2QB4yX0DsMQlFB5IR9RC0/y+EWYlQIkHhpNeU4W9k58UCC SNbNcsCWlj3V7Vwu9AeBWx1OuKw6dPrG1+uqE6vqthqZHF8RfhuS3IAMa0m6Xwe2Nwbj gPgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726835428; x=1727440228; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Q3rt44kILya/FqXwE7282lJPi+mCIQi4p14blEdUGEI=; b=ctk+G8dS4cHpR7YiXQv2vN+mPwfh1pKL7zvbQXRKW8/IbwRg/zl/ucGaKj+ex3Clwd WPaeY2bJpNGG1lpT/kdV7Xd1SpgvR+2ZCJhLWmQSscjLkBO8DU063MCYqCIHJ8TcI8tw 06MsjRH3jh5cwr9egyIaQs4O+69IvMPxSXxJEObQspPFW7ZzltUJGs4LV3ZvKviXbC2C tdjV9NKPU1o/lLldQJRFgPHR55i+q/xJuTF6BtdjpRV5t5Rayr0/9aEJB99kTv431Mpf vocdppaO1F9JQLwrQap2UZqSI7ltlhyxUSPmU5g8VJ/LrG4SPC0tOW9y8chNXuzE5pLD ph7w== X-Forwarded-Encrypted: i=1; AJvYcCVSAxMMOJVquGJqORiIMxqVgYae42yrgL1IAcR5ZiTSj+3jECxm3nXcjhOaQ117Qvq3jQvDfm0VGeU=@vger.kernel.org, AJvYcCWdsOdJm85tj2bXfJ81uTiGs4LvH1z1mL1HY3A57HmbCWJdQO0vlc4ziERWK2qUmv2YrLgTPpPl@vger.kernel.org X-Gm-Message-State: AOJu0Yz7CxBSLz5E93dkQmOV6baV0M2W5gyw7+ys/Sn0+27N0siohgtJ OFOmHQrBv+cJcwwBQXU15GjI61ABthtkqHD7e3/AhAHl0xvDNW+659yWKK16 X-Google-Smtp-Source: AGHT+IF6OJMj3uXNKT4dsEF2MiKr4TPtyooRzradxtXH9Wn1TlHix4eQ+dNsZR+YJQ9ThxwgLRqRPA== X-Received: by 2002:a17:90b:1c8c:b0:2d8:9c97:3c33 with SMTP id 98e67ed59e1d1-2dd7f6b7597mr3778730a91.28.1726835428233; Fri, 20 Sep 2024 05:30:28 -0700 (PDT) Received: from localhost ([38.207.141.200]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd7f8302edsm1794926a91.16.2024.09.20.05.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 05:30:27 -0700 (PDT) From: Julian Sun To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, stable@vger.kernel.org, Julian Sun Subject: [PATCH 3/3] vfs: return -EOVERFLOW in generic_remap_checks() when overflow check fails Date: Fri, 20 Sep 2024 20:30:22 +0800 Message-Id: <20240920123022.215863-1-sunjunchao2870@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Keep it consistent with the handling of the same check within generic_copy_file_checks(). Also, returning -EOVERFLOW in this case is more appropriate. Signed-off-by: Julian Sun Reviewed-by: Christoph Hellwig --- fs/remap_range.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/remap_range.c b/fs/remap_range.c index 6fdeb3c8cb70..a26521ded5c8 100644 --- a/fs/remap_range.c +++ b/fs/remap_range.c @@ -42,7 +42,7 @@ static int generic_remap_checks(struct file *file_in, loff_t pos_in, /* The start of both ranges must be aligned to an fs block. */ if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_out, bs)) - return -EINVAL; + return -EOVERFLOW; /* Ensure offsets don't wrap. */ if (check_add_overflow(pos_in, count, &tmp) ||