public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] pstore/ram: Check member of buffers during the initialization phase of the pstore
@ 2023-08-01  6:04 Yunlong Xing
  2023-08-02 15:46 ` Guilherme G. Piccoli
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yunlong Xing @ 2023-08-01  6:04 UTC (permalink / raw)
  To: keescook, tony.luck, gpiccoli, joel, enlin.mu
  Cc: linux-hardening, linux-kernel, enlinmu, yunlong.xing23

From: Enlin Mu <enlin.mu@unisoc.com>

The commit 30696378f68a("pstore/ram: Do not treat empty buffers as valid")
would introduce the following issue:

When finding the buffer_size is zero, it would return directly.However, at
the same time, if the buffer's start is a illegal value, the others would
panic if access the buffer.

To avoid these happenning, check if the members are legal during the
initialization phase of the pstore.

Fixes: 30696378f68a ("pstore/ram: Do not treat empty buffers as valid")
Cc: stable@vger.kernel.org
Signed-off-by: Enlin Mu <enlin.mu@unisoc.com>
---
 fs/pstore/ram_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 85aaf0fc6d7d..eb6df190d752 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -519,7 +519,7 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig,
 	sig ^= PERSISTENT_RAM_SIG;
 
 	if (prz->buffer->sig == sig) {
-		if (buffer_size(prz) == 0) {
+		if (buffer_size(prz) == 0 && buffer_start(prz) == 0) {
 			pr_debug("found existing empty buffer\n");
 			return 0;
 		}
-- 
2.25.1


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

end of thread, other threads:[~2023-08-07  1:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01  6:04 [PATCH 1/1] pstore/ram: Check member of buffers during the initialization phase of the pstore Yunlong Xing
2023-08-02 15:46 ` Guilherme G. Piccoli
2023-08-03 10:43   ` yunlong xing
2023-08-04  8:10 ` Kees Cook
2023-08-04  8:59   ` yunlong xing
2023-08-04 16:53     ` Kees Cook
2023-08-07  1:33       ` yunlong xing
2023-08-04 17:04 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox