Skip to content
Commit f9f0a539 authored by Piotr Zalewski's avatar Piotr Zalewski Committed by Kent Overstreet
Browse files

bcachefs: Change OPT_STR max to be 1 less than the size of choices array



Change OPT_STR max value to be 1 less than the "ARRAY_SIZE" of "_choices"
array. As a result, remove -1 from (opt->max-1) in bch2_opt_to_text.

The "_choices" array is a null-terminated array, so computing the maximum
using "ARRAY_SIZE" without subtracting 1 yields an incorrect result. Since
bch2_opt_validate don't subtract 1, as bch2_opt_to_text does, values
bigger than the actual maximum would pass through option validation.

Reported-by: default avatar <syzbot+bee87a0c3291c06aa8c6@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=bee87a0c3291c06aa8c6


Fixes: 63c4b254 ("bcachefs: Better superblock opt validation")
Suggested-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: default avatarPiotr Zalewski <pZ010001011111@proton.me>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent baefd3f8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment