Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

zram: do not autocorrect bad recompression parameters

Do not silently autocorrect bad recompression priority parameter value and
just error out.

Link: https://lkml.kernel.org/r/20260311084312.1766036-3-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Suggested-by: Minchan Kim <minchan@kernel.org>
Cc: Brian Geffon <bgeffon@google.com>
Cc: gao xu <gaoxu2@honor.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sergey Senozhatsky and committed by
Andrew Morton
ed19b9d5 241f9005

+8 -9
+8 -9
drivers/block/zram/zram_drv.c
··· 2517 2517 struct device_attribute *attr, 2518 2518 const char *buf, size_t len) 2519 2519 { 2520 + u32 prio = ZRAM_SECONDARY_COMP, prio_max = ZRAM_MAX_COMPS; 2520 2521 struct zram *zram = dev_to_zram(dev); 2521 2522 char *args, *param, *val, *algo = NULL; 2522 2523 u64 num_recomp_pages = ULLONG_MAX; 2523 2524 struct zram_pp_ctl *ctl = NULL; 2524 2525 struct zram_pp_slot *pps; 2525 2526 u32 mode = 0, threshold = 0; 2526 - u32 prio, prio_max; 2527 2527 struct page *page = NULL; 2528 2528 ssize_t ret; 2529 - 2530 - prio = ZRAM_SECONDARY_COMP; 2531 - prio_max = zram->num_active_comps; 2532 2529 2533 2530 args = skip_spaces(buf); 2534 2531 while (*args) { ··· 2576 2579 if (ret) 2577 2580 return ret; 2578 2581 2579 - if (prio == ZRAM_PRIMARY_COMP) 2580 - prio = ZRAM_SECONDARY_COMP; 2581 - 2582 - prio_max = prio + 1; 2582 + prio_max = min(prio + 1, ZRAM_MAX_COMPS); 2583 2583 continue; 2584 2584 } 2585 2585 } ··· 2596 2602 continue; 2597 2603 2598 2604 if (!strcmp(zram->comp_algs[prio], algo)) { 2599 - prio_max = prio + 1; 2605 + prio_max = min(prio + 1, ZRAM_MAX_COMPS); 2600 2606 found = true; 2601 2607 break; 2602 2608 } ··· 2610 2616 2611 2617 prio_max = min(prio_max, (u32)zram->num_active_comps); 2612 2618 if (prio >= prio_max) { 2619 + ret = -EINVAL; 2620 + goto out; 2621 + } 2622 + 2623 + if (prio < ZRAM_SECONDARY_COMP || prio >= ZRAM_MAX_COMPS) { 2613 2624 ret = -EINVAL; 2614 2625 goto out; 2615 2626 }