Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24da2c84 authored by Kees Cook's avatar Kees Cook Committed by Sami Tolvanen
Browse files

BACKPORT: treewide: Fix function prototypes for module_param_call()



Several function prototypes for the set/get functions defined by
module_param_call() have a slightly wrong argument types. This fixes
those in an effort to clean up the calls when running under type-enforced
compiler instrumentation for CFI. This is the result of running the
following semantic patch:

@match_module_param_call_function@
declarer name module_param_call;
identifier _name, _set_func, _get_func;
expression _arg, _mode;
@@

 module_param_call(_name, _set_func, _get_func, _arg, _mode);

@fix_set_prototype
 depends on match_module_param_call_function@
identifier match_module_param_call_function._set_func;
identifier _val, _param;
type _val_type, _param_type;
@@

 int _set_func(
-_val_type _val
+const char * _val
 ,
-_param_type _param
+const struct kernel_param * _param
 ) { ... }

@fix_get_prototype
 depends on match_module_param_call_function@
identifier match_module_param_call_function._get_func;
identifier _val, _param;
type _val_type, _param_type;
@@

 int _get_func(
-_val_type _val
+char * _val
 ,
-_param_type _param
+const struct kernel_param * _param
 ) { ... }

Two additional by-hand changes are included for places where the above
Coccinelle script didn't notice them:

	drivers/platform/x86/thinkpad_acpi.c
	fs/lockd/svc.c

Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>

Bug: 67506682
Change-Id: I2c9c0ee8ed28065e63270a52c155e5e7d2791295
(cherry picked from commit e4dca7b7aa08b22893c45485d222b5807c1375ae)
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 38cbecf2
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -708,7 +708,7 @@ static void cmm_exit(void)
 * Return value:
 * Return value:
 * 	0 on success / other on failure
 * 	0 on success / other on failure
 **/
 **/
static int cmm_set_disable(const char *val, struct kernel_param *kp)
static int cmm_set_disable(const char *val, const struct kernel_param *kp)
{
{
	int disable = simple_strtoul(val, NULL, 10);
	int disable = simple_strtoul(val, NULL, 10);


+1 −1
Original line number Original line Diff line number Diff line
@@ -615,7 +615,7 @@ enum __force_cpu_type {


static int force_cpu_type;
static int force_cpu_type;


static int set_cpu_type(const char *str, struct kernel_param *kp)
static int set_cpu_type(const char *str, const struct kernel_param *kp)
{
{
	if (!strcmp(str, "timer")) {
	if (!strcmp(str, "timer")) {
		force_cpu_type = timer;
		force_cpu_type = timer;
+4 −2
Original line number Original line Diff line number Diff line
@@ -556,7 +556,8 @@ static int acpi_button_remove(struct acpi_device *device)
	return 0;
	return 0;
}
}


static int param_set_lid_init_state(const char *val, struct kernel_param *kp)
static int param_set_lid_init_state(const char *val,
				    const struct kernel_param *kp)
{
{
	int result = 0;
	int result = 0;


@@ -574,7 +575,8 @@ static int param_set_lid_init_state(const char *val, struct kernel_param *kp)
	return result;
	return result;
}
}


static int param_get_lid_init_state(char *buffer, struct kernel_param *kp)
static int param_get_lid_init_state(char *buffer,
				    const struct kernel_param *kp)
{
{
	switch (lid_init_state) {
	switch (lid_init_state) {
	case ACPI_BUTTON_LID_INIT_OPEN:
	case ACPI_BUTTON_LID_INIT_OPEN:
+4 −2
Original line number Original line Diff line number Diff line
@@ -1891,7 +1891,8 @@ static const struct dev_pm_ops acpi_ec_pm = {
	SET_SYSTEM_SLEEP_PM_OPS(acpi_ec_suspend, acpi_ec_resume)
	SET_SYSTEM_SLEEP_PM_OPS(acpi_ec_suspend, acpi_ec_resume)
};
};


static int param_set_event_clearing(const char *val, struct kernel_param *kp)
static int param_set_event_clearing(const char *val,
				    const struct kernel_param *kp)
{
{
	int result = 0;
	int result = 0;


@@ -1909,7 +1910,8 @@ static int param_set_event_clearing(const char *val, struct kernel_param *kp)
	return result;
	return result;
}
}


static int param_get_event_clearing(char *buffer, struct kernel_param *kp)
static int param_get_event_clearing(char *buffer,
				    const struct kernel_param *kp)
{
{
	switch (ec_event_clearing) {
	switch (ec_event_clearing) {
	case ACPI_EC_EVT_TIMING_STATUS:
	case ACPI_EC_EVT_TIMING_STATUS:
+5 −3
Original line number Original line Diff line number Diff line
@@ -227,7 +227,8 @@ module_param_cb(trace_method_name, &param_ops_trace_method, &trace_method_name,
module_param_cb(trace_debug_layer, &param_ops_trace_attrib, &acpi_gbl_trace_dbg_layer, 0644);
module_param_cb(trace_debug_layer, &param_ops_trace_attrib, &acpi_gbl_trace_dbg_layer, 0644);
module_param_cb(trace_debug_level, &param_ops_trace_attrib, &acpi_gbl_trace_dbg_level, 0644);
module_param_cb(trace_debug_level, &param_ops_trace_attrib, &acpi_gbl_trace_dbg_level, 0644);


static int param_set_trace_state(const char *val, struct kernel_param *kp)
static int param_set_trace_state(const char *val,
				 const struct kernel_param *kp)
{
{
	acpi_status status;
	acpi_status status;
	const char *method = trace_method_name;
	const char *method = trace_method_name;
@@ -263,7 +264,7 @@ static int param_set_trace_state(const char *val, struct kernel_param *kp)
	return 0;
	return 0;
}
}


static int param_get_trace_state(char *buffer, struct kernel_param *kp)
static int param_get_trace_state(char *buffer, const struct kernel_param *kp)
{
{
	if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED))
	if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED))
		return sprintf(buffer, "disable");
		return sprintf(buffer, "disable");
@@ -292,7 +293,8 @@ MODULE_PARM_DESC(aml_debug_output,
		 "To enable/disable the ACPI Debug Object output.");
		 "To enable/disable the ACPI Debug Object output.");


/* /sys/module/acpi/parameters/acpica_version */
/* /sys/module/acpi/parameters/acpica_version */
static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
static int param_get_acpica_version(char *buffer,
				    const struct kernel_param *kp)
{
{
	int result;
	int result;


Loading