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.

dm verity: allow only one error handling mode

If more than one one handling mode is requested during DM verity table
load, the last requested mode will be used.

Change this to impose more strict checking so that the table load will
fail if more than one error handling mode is requested.

Signed-off-by: JeongHyeon Lee <jhs2.lee@samsung.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

JeongHyeon Lee and committed by
Mike Snitzer
219a9b5e 8615cb65

+29 -11
+29 -11
drivers/md/dm-verity-target.c
··· 893 893 return r; 894 894 } 895 895 896 + static inline bool verity_is_verity_mode(const char *arg_name) 897 + { 898 + return (!strcasecmp(arg_name, DM_VERITY_OPT_LOGGING) || 899 + !strcasecmp(arg_name, DM_VERITY_OPT_RESTART) || 900 + !strcasecmp(arg_name, DM_VERITY_OPT_PANIC)); 901 + } 902 + 903 + static int verity_parse_verity_mode(struct dm_verity *v, const char *arg_name) 904 + { 905 + if (v->mode) 906 + return -EINVAL; 907 + 908 + if (!strcasecmp(arg_name, DM_VERITY_OPT_LOGGING)) 909 + v->mode = DM_VERITY_MODE_LOGGING; 910 + else if (!strcasecmp(arg_name, DM_VERITY_OPT_RESTART)) 911 + v->mode = DM_VERITY_MODE_RESTART; 912 + else if (!strcasecmp(arg_name, DM_VERITY_OPT_PANIC)) 913 + v->mode = DM_VERITY_MODE_PANIC; 914 + 915 + return 0; 916 + } 917 + 896 918 static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v, 897 919 struct dm_verity_sig_opts *verify_args) 898 920 { ··· 938 916 arg_name = dm_shift_arg(as); 939 917 argc--; 940 918 941 - if (!strcasecmp(arg_name, DM_VERITY_OPT_LOGGING)) { 942 - v->mode = DM_VERITY_MODE_LOGGING; 943 - continue; 944 - 945 - } else if (!strcasecmp(arg_name, DM_VERITY_OPT_RESTART)) { 946 - v->mode = DM_VERITY_MODE_RESTART; 947 - continue; 948 - 949 - } else if (!strcasecmp(arg_name, DM_VERITY_OPT_PANIC)) { 950 - v->mode = DM_VERITY_MODE_PANIC; 919 + if (verity_is_verity_mode(arg_name)) { 920 + r = verity_parse_verity_mode(v, arg_name); 921 + if (r) { 922 + ti->error = "Conflicting error handling parameters"; 923 + return r; 924 + } 951 925 continue; 952 926 953 927 } else if (!strcasecmp(arg_name, DM_VERITY_OPT_IGN_ZEROES)) { ··· 1260 1242 1261 1243 static struct target_type verity_target = { 1262 1244 .name = "verity", 1263 - .version = {1, 7, 0}, 1245 + .version = {1, 8, 0}, 1264 1246 .module = THIS_MODULE, 1265 1247 .ctr = verity_ctr, 1266 1248 .dtr = verity_dtr,