Skip to contentSkip to conversation

mm-fadvise-validate-offset-in-generic_fadvise.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Mar 24

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/fadvise: validate offset in generic_fadvise
has been removed from the -mm tree. Its filename was
mm-fadvise-validate-offset-in-generic_fadvise.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Kevin Lourenco <[email protected]>
Subject: mm/fadvise: validate offset in generic_fadvise
Date: Mon, 22 Dec 2025 15:18:17 +0100

When converted to (u64) for page calculations, a negative offset can produce extremely large page indices. This may lead to issues in certain advice modes (excessive readahead or cache invalidation).

Reject negative offsets with -EINVAL for consistent argument validation and to avoid silent misbehavior.

POSIX and the man page do not clearly define behavior for negative offset/len. FreeBSD rejects negative offsets as well, so failing with -EINVAL is consistent with existing practice. The man page can be updated separately to document the Linux behavior.

---

 mm/fadvise.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/fadvise.c renamed from mm/fadvise.c~mm-fadvise-validate-offset-in-generic_fadvise +1 -1
@@ -43,7 +43,7 @@ int generic_fadvise(struct file *file, l
 		return -ESPIPE;
 
 	mapping = file->f_mapping;
-	if (!mapping || len < 0)
+	if (!mapping || len < 0 || offset < 0)
 		return -EINVAL;
 
 	bdi = inode_to_bdi(mapping->host);

_

Patches currently in -mm which might be from [email protected] are