ioctl: check if permd op is valid

A bad permd op should fail ioctl() with EINVAL instead of
invoking undefined behavior.
This commit is contained in:
CismonX 2025-01-02 18:53:12 +08:00
parent 486bd6b36e
commit 3e325a3934
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
2 changed files with 5 additions and 1 deletions

View file

@ -2444,7 +2444,7 @@ bookmark_permute (
break; break;
default: default:
unreachable(); return -EINVAL;
} }
ctx->dirty = DIRTY_LEVEL_DATA; ctx->dirty = DIRTY_LEVEL_DATA;

View file

@ -926,6 +926,8 @@ mozbm_pos_shift (
return 0; return 0;
} }
*pos_end_ptr = pos_end; *pos_end_ptr = pos_end;
} else if (op != BOOKMARKFS_PERMD_OP_MOVE_AFTER) {
return -EINVAL;
} }
++pos_start; ++pos_start;
} else { } else {
@ -934,6 +936,8 @@ mozbm_pos_shift (
return 0; return 0;
} }
*pos_end_ptr = pos_end; *pos_end_ptr = pos_end;
} else if (op != BOOKMARKFS_PERMD_OP_MOVE_BEFORE) {
return -EINVAL;
} }
--pos_start; --pos_start;