From: Greg Kroah-Hartman Date: Thu, 7 Mar 2019 12:25:19 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v5.0.1~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99e0bebd355c8d74b85e6958ae784bbc684238e9;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch --- diff --git a/queue-4.14/cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch b/queue-4.14/cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch new file mode 100644 index 00000000000..4cba94586aa --- /dev/null +++ b/queue-4.14/cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch @@ -0,0 +1,168 @@ +From 625c85a62cb7d3c79f6e16de3cfa972033658250 Mon Sep 17 00:00:00 2001 +From: Viresh Kumar +Date: Fri, 25 Jan 2019 12:53:07 +0530 +Subject: cpufreq: Use struct kobj_attribute instead of struct global_attr + +From: Viresh Kumar + +commit 625c85a62cb7d3c79f6e16de3cfa972033658250 upstream. + +The cpufreq_global_kobject is created using kobject_create_and_add() +helper, which assigns the kobj_type as dynamic_kobj_ktype and show/store +routines are set to kobj_attr_show() and kobj_attr_store(). + +These routines pass struct kobj_attribute as an argument to the +show/store callbacks. But all the cpufreq files created using the +cpufreq_global_kobject expect the argument to be of type struct +attribute. Things work fine currently as no one accesses the "attr" +argument. We may not see issues even if the argument is used, as struct +kobj_attribute has struct attribute as its first element and so they +will both get same address. + +But this is logically incorrect and we should rather use struct +kobj_attribute instead of struct global_attr in the cpufreq core and +drivers and the show/store callbacks should take struct kobj_attribute +as argument instead. + +This bug is caught using CFI CLANG builds in android kernel which +catches mismatch in function prototypes for such callbacks. + +Reported-by: Donghee Han +Reported-by: Sangkyu Kim +Signed-off-by: Viresh Kumar +Signed-off-by: Rafael J. Wysocki +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/cpufreq/cpufreq.c | 6 +++--- + drivers/cpufreq/intel_pstate.c | 18 +++++++++--------- + include/linux/cpufreq.h | 12 ++---------- + 3 files changed, 14 insertions(+), 22 deletions(-) + +--- a/drivers/cpufreq/cpufreq.c ++++ b/drivers/cpufreq/cpufreq.c +@@ -554,13 +554,13 @@ EXPORT_SYMBOL_GPL(cpufreq_policy_transit + * SYSFS INTERFACE * + *********************************************************************/ + static ssize_t show_boost(struct kobject *kobj, +- struct attribute *attr, char *buf) ++ struct kobj_attribute *attr, char *buf) + { + return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled); + } + +-static ssize_t store_boost(struct kobject *kobj, struct attribute *attr, +- const char *buf, size_t count) ++static ssize_t store_boost(struct kobject *kobj, struct kobj_attribute *attr, ++ const char *buf, size_t count) + { + int ret, enable; + +--- a/drivers/cpufreq/intel_pstate.c ++++ b/drivers/cpufreq/intel_pstate.c +@@ -811,7 +811,7 @@ static void intel_pstate_update_policies + /************************** sysfs begin ************************/ + #define show_one(file_name, object) \ + static ssize_t show_##file_name \ +- (struct kobject *kobj, struct attribute *attr, char *buf) \ ++ (struct kobject *kobj, struct kobj_attribute *attr, char *buf) \ + { \ + return sprintf(buf, "%u\n", global.object); \ + } +@@ -820,7 +820,7 @@ static ssize_t intel_pstate_show_status( + static int intel_pstate_update_status(const char *buf, size_t size); + + static ssize_t show_status(struct kobject *kobj, +- struct attribute *attr, char *buf) ++ struct kobj_attribute *attr, char *buf) + { + ssize_t ret; + +@@ -831,7 +831,7 @@ static ssize_t show_status(struct kobjec + return ret; + } + +-static ssize_t store_status(struct kobject *a, struct attribute *b, ++static ssize_t store_status(struct kobject *a, struct kobj_attribute *b, + const char *buf, size_t count) + { + char *p = memchr(buf, '\n', count); +@@ -845,7 +845,7 @@ static ssize_t store_status(struct kobje + } + + static ssize_t show_turbo_pct(struct kobject *kobj, +- struct attribute *attr, char *buf) ++ struct kobj_attribute *attr, char *buf) + { + struct cpudata *cpu; + int total, no_turbo, turbo_pct; +@@ -871,7 +871,7 @@ static ssize_t show_turbo_pct(struct kob + } + + static ssize_t show_num_pstates(struct kobject *kobj, +- struct attribute *attr, char *buf) ++ struct kobj_attribute *attr, char *buf) + { + struct cpudata *cpu; + int total; +@@ -892,7 +892,7 @@ static ssize_t show_num_pstates(struct k + } + + static ssize_t show_no_turbo(struct kobject *kobj, +- struct attribute *attr, char *buf) ++ struct kobj_attribute *attr, char *buf) + { + ssize_t ret; + +@@ -914,7 +914,7 @@ static ssize_t show_no_turbo(struct kobj + return ret; + } + +-static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, ++static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b, + const char *buf, size_t count) + { + unsigned int input; +@@ -961,7 +961,7 @@ static ssize_t store_no_turbo(struct kob + return count; + } + +-static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, ++static ssize_t store_max_perf_pct(struct kobject *a, struct kobj_attribute *b, + const char *buf, size_t count) + { + unsigned int input; +@@ -991,7 +991,7 @@ static ssize_t store_max_perf_pct(struct + return count; + } + +-static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, ++static ssize_t store_min_perf_pct(struct kobject *a, struct kobj_attribute *b, + const char *buf, size_t count) + { + unsigned int input; +--- a/include/linux/cpufreq.h ++++ b/include/linux/cpufreq.h +@@ -254,20 +254,12 @@ __ATTR(_name, 0644, show_##_name, store_ + static struct freq_attr _name = \ + __ATTR(_name, 0200, NULL, store_##_name) + +-struct global_attr { +- struct attribute attr; +- ssize_t (*show)(struct kobject *kobj, +- struct attribute *attr, char *buf); +- ssize_t (*store)(struct kobject *a, struct attribute *b, +- const char *c, size_t count); +-}; +- + #define define_one_global_ro(_name) \ +-static struct global_attr _name = \ ++static struct kobj_attribute _name = \ + __ATTR(_name, 0444, show_##_name, NULL) + + #define define_one_global_rw(_name) \ +-static struct global_attr _name = \ ++static struct kobj_attribute _name = \ + __ATTR(_name, 0644, show_##_name, store_##_name) + + diff --git a/queue-4.14/series b/queue-4.14/series new file mode 100644 index 00000000000..fa8434ccf71 --- /dev/null +++ b/queue-4.14/series @@ -0,0 +1 @@ +cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch diff --git a/queue-4.19/series b/queue-4.19/series new file mode 100644 index 00000000000..7ab46c5b0b0 --- /dev/null +++ b/queue-4.19/series @@ -0,0 +1,2 @@ +cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch +staging-erofs-fix-mis-acted-tail-merging-behavior.patch diff --git a/queue-4.20/series b/queue-4.20/series new file mode 100644 index 00000000000..7ab46c5b0b0 --- /dev/null +++ b/queue-4.20/series @@ -0,0 +1,2 @@ +cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch +staging-erofs-fix-mis-acted-tail-merging-behavior.patch diff --git a/queue-4.9/series b/queue-4.9/series new file mode 100644 index 00000000000..e69de29bb2d diff --git a/queue-5.0/series b/queue-5.0/series new file mode 100644 index 00000000000..7ab46c5b0b0 --- /dev/null +++ b/queue-5.0/series @@ -0,0 +1,2 @@ +cpufreq-use-struct-kobj_attribute-instead-of-struct-global_attr.patch +staging-erofs-fix-mis-acted-tail-merging-behavior.patch