kobject_init_and_add() takes expects format string for a name, so we better provide it in order to avoid infoleaks if modules craft their mod->name in a special way.
Showing the changes to kernel/livepatch (1 of 1 file). Show all
Unified · Split
| @@ -731,7 +731,7 @@ static int klp_init_func(struct klp_object *obj, struct klp_func *func) · 730 unmodified lines | |||
| 731 | func->state = KLP_DISABLED; | 731 | func->state = KLP_DISABLED; |
| 732 | 732 | ||
| 733 | return kobject_init_and_add(&func->kobj, &klp_ktype_func, | 733 | return kobject_init_and_add(&func->kobj, &klp_ktype_func, |
| 734 | obj->kobj, func->old_name); | 734 | obj->kobj, "%s", func->old_name); |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | /* parts of the initialization that is done only when the object is loaded */ | 737 | /* parts of the initialization that is done only when the object is loaded */ |
| @@ -807,7 +807,7 @@ static int klp_init_patch(struct klp_patch *patch) · 69 unmodified lines | |||
| 807 | patch->state = KLP_DISABLED; | 807 | patch->state = KLP_DISABLED; |
| 808 | 808 | ||
| 809 | ret = kobject_init_and_add(&patch->kobj, &klp_ktype_patch, | 809 | ret = kobject_init_and_add(&patch->kobj, &klp_ktype_patch, |
| 810 | klp_root_kobj, patch->mod->name); | 810 | klp_root_kobj, "%s", patch->mod->name); |
| 811 | if (ret) | 811 | if (ret) |
| 812 | goto unlock; | 812 | goto unlock; |
| 813 | 813 | ||