Pull hardening updates from Kees Cook: "One of the more voluminous set of changes is for adding the new __counted_by annotation[1] to gain run-time bounds checking of dynamically sized arrays with UBSan. - Add LKDTM test for stuck CPUs (Mark Rutland) - Improve LKDTM selftest behavior under UBSan (Ricardo Cañuelo) - Refactor more 1-element arrays into flexible arrays (Gustavo A. R. Silva) - Analyze and replace strlcpy and strncpy uses (Justin Stitt, Azeem Shaikh) - Convert group_info.usage to refcount_t (Elena Reshetova) - Add __counted_by annotations (Kees Cook, Gustavo A. R. Silva) - Add Kconfig fragment for basic hardening options (Kees Cook, Lukas Bulwahn) - Fix randstruct GCC plugin performance mode to stay in groups (Kees Cook) - Fix strtomem() compile-time check for small sources (Kees Cook)" * tag 'hardening-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (56 commits) hwmon: (acpi_power_meter) replace open-coded kmemdup_nul reset: Annotate struct reset_control_array with __counted_by kexec: Annotate struct crash_mem with __counted_by virtio_console: Annotate struct port_buffer with __counted_by ima: Add __counted_by for struct modsig and use struct_size() MAINTAINERS: Include stackleak paths in hardening entry string: Adjust strtomem() logic to allow for smaller sources hardening: x86: drop reference to removed config AMD_IOMMU_V2 randstruct: Fix gcc-plugin performance mode to stay in group mailbox: zynqmp: Annotate struct zynqmp_ipi_pdata with __counted_by drivers: thermal: tsens: Annotate struct tsens_priv with __counted_by irqchip/imx-intmux: Annotate struct intmux_data with __counted_by KVM: Annotate struct kvm_irq_routing_table with __counted_by virt: acrn: Annotate struct vm_memory_region_batch with __counted_by hwmon: Annotate struct gsc_hwmon_platform_data with __counted_by sparc: Annotate struct cpuinfo_tree with __counted_by isdn: kcapi: replace deprecated strncpy with strscpy_pad isdn: replace deprecated strncpy with strscpy NFS/flexfiles: Annotate struct nfs4_ff_layout_segment with __counted_by nfs41: Annotate struct nfs4_file_layout_dsaddr with __counted_by ...
Showing the changes to scripts (1 of 60 files). Show all
Unified · Split
| @@ -191,12 +191,14 @@ static void partition_struct(tree *fields, unsigned long length, struct partitio · 190 unmodified lines | |||
| 191 | 191 | ||
| 192 | static void performance_shuffle(tree *newtree, unsigned long length, ranctx *prng_state) | 192 | static void performance_shuffle(tree *newtree, unsigned long length, ranctx *prng_state) |
| 193 | { | 193 | { |
| 194 | unsigned long i, x; | 194 | unsigned long i, x, index; |
| 195 | struct partition_group size_group[length]; | 195 | struct partition_group size_group[length]; |
| 196 | unsigned long num_groups = 0; | 196 | unsigned long num_groups = 0; |
| 197 | unsigned long randnum; | 197 | unsigned long randnum; |
| 198 | 198 | ||
| 199 | partition_struct(newtree, length, (struct partition_group *)&size_group, &num_groups); | 199 | partition_struct(newtree, length, (struct partition_group *)&size_group, &num_groups); |
| 200 | |||
| 201 | /* FIXME: this group shuffle is currently a no-op. */ | ||
| 200 | for (i = num_groups - 1; i > 0; i--) { | 202 | for (i = num_groups - 1; i > 0; i--) { |
| 201 | struct partition_group tmp; | 203 | struct partition_group tmp; |
| 202 | randnum = ranval(prng_state) % (i + 1); | 204 | randnum = ranval(prng_state) % (i + 1); |
| @@ -206,11 +208,14 @@ static void performance_shuffle(tree *newtree, unsigned long length, ranctx *prn · 3 unmodified lines | |||
| 206 | } | 208 | } |
| 207 | 209 | ||
| 208 | for (x = 0; x < num_groups; x++) { | 210 | for (x = 0; x < num_groups; x++) { |
| 209 | for (i = size_group[x].start + size_group[x].length - 1; i > size_group[x].start; i--) { | 211 | for (index = size_group[x].length - 1; index > 0; index--) { |
| 210 | tree tmp; | 212 | tree tmp; |
| 213 | |||
| 214 | i = size_group[x].start + index; | ||
| 211 | if (DECL_BIT_FIELD_TYPE(newtree[i])) | 215 | if (DECL_BIT_FIELD_TYPE(newtree[i])) |
| 212 | continue; | 216 | continue; |
| 213 | randnum = ranval(prng_state) % (i + 1); | 217 | randnum = ranval(prng_state) % (index + 1); |
| 218 | randnum += size_group[x].start; | ||
| 214 | // we could handle this case differently if desired | 219 | // we could handle this case differently if desired |
| 215 | if (DECL_BIT_FIELD_TYPE(newtree[randnum])) | 220 | if (DECL_BIT_FIELD_TYPE(newtree[randnum])) |
| 216 | continue; | 221 | continue; |