summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-11-18 10:37:20 -0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-11-24 14:31:56 +0100
commit764cedc5638b0565de140575b90ce24983f2b664 (patch)
tree53490669a3383b5d29be6eb2507fe5c6b42dc9a0 /drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
parent136057256686de39cc3a07c2e39ef6bc43003ff6 (diff)
downloadlinux-764cedc5638b0565de140575b90ce24983f2b664.tar.bz2
thermal: int340x: Use struct_group() for memcpy() region
In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), avoid intentionally writing across neighboring fields. Use struct_group() in struct art around members weight, and ac[0-9]_max, so they can be referenced together. This will allow memcpy() and sizeof() to more easily reason about sizes, improve readability, and avoid future warnings about writing beyond the end of weight. "pahole" shows no size nor member offset changes to struct art. "objdump -d" shows no meaningful object code changes (i.e. only source line number induced differences). Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c')
-rw-r--r--drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c b/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
index a478cff8162a..e90690a234c4 100644
--- a/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
+++ b/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
@@ -250,8 +250,9 @@ static int fill_art(char __user *ubuf)
get_single_name(arts[i].source, art_user[i].source_device);
get_single_name(arts[i].target, art_user[i].target_device);
/* copy the rest int data in addition to source and target */
- memcpy(&art_user[i].weight, &arts[i].weight,
- sizeof(u64) * (ACPI_NR_ART_ELEMENTS - 2));
+ BUILD_BUG_ON(sizeof(art_user[i].data) !=
+ sizeof(u64) * (ACPI_NR_ART_ELEMENTS - 2));
+ memcpy(&art_user[i].data, &arts[i].data, sizeof(art_user[i].data));
}
if (copy_to_user(ubuf, art_user, art_len))