linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.19] fs: sysfs_emit_at: Remove PAGE_SIZE alignment check
@ 2023-03-17  6:27 Eric Biggers
  2023-03-17 13:02 ` Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.14-stable tree gregkh
  2023-03-17 13:02 ` Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.19-stable tree gregkh
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2023-03-17  6:27 UTC (permalink / raw)
  To: stable; +Cc: Joe Perches, Lucas Wei, linux-mm, kernel test robot

From: Eric Biggers <ebiggers@google.com>

[No upstream commit because this fixes a bug in a backport.]

Before upstream commit 59bb47985c1d ("mm, sl[aou]b: guarantee natural
alignment for kmalloc(power-of-two)") which went into v5.4, kmalloc did
*not* always guarantee that PAGE_SIZE allocations are PAGE_SIZE-aligned.

Upstream commit 2efc459d06f1 ("sysfs: Add sysfs_emit and sysfs_emit_at
to format sysfs output") added two WARN()s that trigger when PAGE_SIZE
allocations are not PAGE_SIZE-aligned.  This was backported to old
kernels that don't guarantee PAGE_SIZE alignment.

Commit 10ddfb495232 ("fs: sysfs_emit: Remove PAGE_SIZE alignment check")
in 4.19.y, and its equivalent in 4.14.y and 4.9.y, tried to fix this
bug.  However, only it handled sysfs_emit(), not sysfs_emit_at().

Fix it in sysfs_emit_at() too.

A reproducer is to build the kernel with the following options:

	CONFIG_SLUB=y
	CONFIG_SLUB_DEBUG=y
	CONFIG_SLUB_DEBUG_ON=y
	CONFIG_PM=y
	CONFIG_SUSPEND=y
	CONFIG_PM_WAKELOCKS=y

Then run:

	echo foo > /sys/power/wake_lock && cat /sys/power/wake_lock

Fixes: cb1f69d53ac8 ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output")
Reported-by: kernel test robot <yujie.liu@intel.com>
Link: https://lore.kernel.org/r/202303141634.1e64fd76-yujie.liu@intel.com
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/sysfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 011e391497f4e..cd70dbeeab226 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -599,7 +599,7 @@ int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
 	va_list args;
 	int len;
 
-	if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE,
+	if (WARN(!buf || at < 0 || at >= PAGE_SIZE,
 		 "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
 		return 0;
 
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.14-stable tree
  2023-03-17  6:27 [PATCH 4.19] fs: sysfs_emit_at: Remove PAGE_SIZE alignment check Eric Biggers
@ 2023-03-17 13:02 ` gregkh
  2023-03-17 13:02 ` Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.19-stable tree gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2023-03-17 13:02 UTC (permalink / raw)
  To: ebiggers, ebiggers, gregkh, joe, linux-mm, lucaswei, yujie.liu
  Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    fs: sysfs_emit_at: Remove PAGE_SIZE alignment check

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     fs-sysfs_emit_at-remove-page_size-alignment-check.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From ebiggers@kernel.org  Fri Mar 17 13:57:17 2023
From: Eric Biggers <ebiggers@kernel.org>
Date: Thu, 16 Mar 2023 23:27:43 -0700
Subject: fs: sysfs_emit_at: Remove PAGE_SIZE alignment check
To: stable@vger.kernel.org
Cc: Joe Perches <joe@perches.com>, Lucas Wei <lucaswei@google.com>, linux-mm@kvack.org, kernel test robot <yujie.liu@intel.com>
Message-ID: <20230317062743.313169-1-ebiggers@kernel.org>

From: Eric Biggers <ebiggers@kernel.org>

From: Eric Biggers <ebiggers@google.com>

[No upstream commit because this fixes a bug in a backport.]

Before upstream commit 59bb47985c1d ("mm, sl[aou]b: guarantee natural
alignment for kmalloc(power-of-two)") which went into v5.4, kmalloc did
*not* always guarantee that PAGE_SIZE allocations are PAGE_SIZE-aligned.

Upstream commit 2efc459d06f1 ("sysfs: Add sysfs_emit and sysfs_emit_at
to format sysfs output") added two WARN()s that trigger when PAGE_SIZE
allocations are not PAGE_SIZE-aligned.  This was backported to old
kernels that don't guarantee PAGE_SIZE alignment.

Commit 10ddfb495232 ("fs: sysfs_emit: Remove PAGE_SIZE alignment check")
in 4.19.y, and its equivalent in 4.14.y and 4.9.y, tried to fix this
bug.  However, only it handled sysfs_emit(), not sysfs_emit_at().

Fix it in sysfs_emit_at() too.

A reproducer is to build the kernel with the following options:

	CONFIG_SLUB=y
	CONFIG_SLUB_DEBUG=y
	CONFIG_SLUB_DEBUG_ON=y
	CONFIG_PM=y
	CONFIG_SUSPEND=y
	CONFIG_PM_WAKELOCKS=y

Then run:

	echo foo > /sys/power/wake_lock && cat /sys/power/wake_lock

Fixes: cb1f69d53ac8 ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output")
Reported-by: kernel test robot <yujie.liu@intel.com>
Link: https://lore.kernel.org/r/202303141634.1e64fd76-yujie.liu@intel.com
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/sysfs/file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -592,7 +592,7 @@ int sysfs_emit_at(char *buf, int at, con
 	va_list args;
 	int len;
 
-	if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE,
+	if (WARN(!buf || at < 0 || at >= PAGE_SIZE,
 		 "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
 		return 0;
 


Patches currently in stable-queue which might be from ebiggers@kernel.org are

queue-4.14/fs-sysfs_emit_at-remove-page_size-alignment-check.patch
queue-4.14/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.19-stable tree
  2023-03-17  6:27 [PATCH 4.19] fs: sysfs_emit_at: Remove PAGE_SIZE alignment check Eric Biggers
  2023-03-17 13:02 ` Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.14-stable tree gregkh
@ 2023-03-17 13:02 ` gregkh
  1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2023-03-17 13:02 UTC (permalink / raw)
  To: ebiggers, ebiggers, gregkh, joe, linux-mm, lucaswei, yujie.liu
  Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    fs: sysfs_emit_at: Remove PAGE_SIZE alignment check

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     fs-sysfs_emit_at-remove-page_size-alignment-check.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


From ebiggers@kernel.org  Fri Mar 17 13:57:17 2023
From: Eric Biggers <ebiggers@kernel.org>
Date: Thu, 16 Mar 2023 23:27:43 -0700
Subject: fs: sysfs_emit_at: Remove PAGE_SIZE alignment check
To: stable@vger.kernel.org
Cc: Joe Perches <joe@perches.com>, Lucas Wei <lucaswei@google.com>, linux-mm@kvack.org, kernel test robot <yujie.liu@intel.com>
Message-ID: <20230317062743.313169-1-ebiggers@kernel.org>

From: Eric Biggers <ebiggers@kernel.org>

From: Eric Biggers <ebiggers@google.com>

[No upstream commit because this fixes a bug in a backport.]

Before upstream commit 59bb47985c1d ("mm, sl[aou]b: guarantee natural
alignment for kmalloc(power-of-two)") which went into v5.4, kmalloc did
*not* always guarantee that PAGE_SIZE allocations are PAGE_SIZE-aligned.

Upstream commit 2efc459d06f1 ("sysfs: Add sysfs_emit and sysfs_emit_at
to format sysfs output") added two WARN()s that trigger when PAGE_SIZE
allocations are not PAGE_SIZE-aligned.  This was backported to old
kernels that don't guarantee PAGE_SIZE alignment.

Commit 10ddfb495232 ("fs: sysfs_emit: Remove PAGE_SIZE alignment check")
in 4.19.y, and its equivalent in 4.14.y and 4.9.y, tried to fix this
bug.  However, only it handled sysfs_emit(), not sysfs_emit_at().

Fix it in sysfs_emit_at() too.

A reproducer is to build the kernel with the following options:

	CONFIG_SLUB=y
	CONFIG_SLUB_DEBUG=y
	CONFIG_SLUB_DEBUG_ON=y
	CONFIG_PM=y
	CONFIG_SUSPEND=y
	CONFIG_PM_WAKELOCKS=y

Then run:

	echo foo > /sys/power/wake_lock && cat /sys/power/wake_lock

Fixes: cb1f69d53ac8 ("sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output")
Reported-by: kernel test robot <yujie.liu@intel.com>
Link: https://lore.kernel.org/r/202303141634.1e64fd76-yujie.liu@intel.com
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/sysfs/file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -599,7 +599,7 @@ int sysfs_emit_at(char *buf, int at, con
 	va_list args;
 	int len;
 
-	if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE,
+	if (WARN(!buf || at < 0 || at >= PAGE_SIZE,
 		 "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
 		return 0;
 


Patches currently in stable-queue which might be from ebiggers@kernel.org are

queue-4.19/fs-sysfs_emit_at-remove-page_size-alignment-check.patch
queue-4.19/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-17 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17  6:27 [PATCH 4.19] fs: sysfs_emit_at: Remove PAGE_SIZE alignment check Eric Biggers
2023-03-17 13:02 ` Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.14-stable tree gregkh
2023-03-17 13:02 ` Patch "fs: sysfs_emit_at: Remove PAGE_SIZE alignment check" has been added to the 4.19-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).