* [PATCH v2] zram: reject unrecognized type= values in recompress_store()
[not found] <MESSAGE-ID-OF-SERGEYS-REPLY>
@ 2026-04-07 15:30 ` Andrew Stellman
2026-04-08 1:40 ` Sergey Senozhatsky
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-04-07 15:30 UTC (permalink / raw)
To: senozhatsky, minchan; +Cc: linux-kernel, Andrew Stellman
recompress_store() parses the type= parameter with three if statements
checking for "idle", "huge", and "huge_idle". An unrecognized value
silently falls through with mode left at 0, causing the recompression
pass to run with no slot filter — processing all slots instead of the
intended subset.
Add a !mode check after the type parsing block to return -EINVAL for
unrecognized values, consistent with the function's other parameter
validation.
Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
Changes in v2:
- Use !mode check after the strcmp chain instead of restructuring
into if/else if/else, as suggested by Sergey Senozhatsky.
drivers/block/zram/zram_drv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 8ea2a12..67dea80 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2552,6 +2552,9 @@ static ssize_t recompress_store(struct device *dev,
if (!strcmp(val, "huge_idle"))
mode = RECOMPRESS_IDLE | RECOMPRESS_HUGE;
+ if (!mode)
+ return -EINVAL;
+
continue;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] zram: reject unrecognized type= values in recompress_store()
2026-04-07 15:30 ` [PATCH v2] zram: reject unrecognized type= values in recompress_store() Andrew Stellman
@ 2026-04-08 1:40 ` Sergey Senozhatsky
0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2026-04-08 1:40 UTC (permalink / raw)
To: Andrew Stellman, Andrew Morton; +Cc: senozhatsky, minchan, linux-kernel
Adding Andrew on this:
Message-ID: <20260407153027.42425-1-astellman@stellman-greene.com>
On (26/04/07 11:30), Andrew Stellman wrote:
[..]
> recompress_store() parses the type= parameter with three if statements
> checking for "idle", "huge", and "huge_idle". An unrecognized value
> silently falls through with mode left at 0, causing the recompression
> pass to run with no slot filter — processing all slots instead of the
> intended subset.
>
> Add a !mode check after the type parsing block to return -EINVAL for
> unrecognized values, consistent with the function's other parameter
> validation.
>
> Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
> ---
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-08 1:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <MESSAGE-ID-OF-SERGEYS-REPLY>
2026-04-07 15:30 ` [PATCH v2] zram: reject unrecognized type= values in recompress_store() Andrew Stellman
2026-04-08 1:40 ` Sergey Senozhatsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox