Re: [PATCH v4] x86/traps: Enable UBSAN traps on x86

2024-07-11 Thread Peter Zijlstra
On Wed, Jul 10, 2024 at 08:32:38PM +, Gatlin Newhouse wrote: > Currently ARM architectures extract which specific sanitizer > has caused a trap via encoded data in the trap instruction. > Clang on x86 currently encodes the same data in ud1 instructions > but the x86 handle_bug() and is_valid_bu

Re: [PATCH v4] x86/traps: Enable UBSAN traps on x86

2024-07-11 Thread Marco Elver
On Thu, 11 Jul 2024 at 10:10, Peter Zijlstra wrote: > > On Wed, Jul 10, 2024 at 08:32:38PM +, Gatlin Newhouse wrote: > > Currently ARM architectures extract which specific sanitizer > > has caused a trap via encoded data in the trap instruction. > > Clang on x86 currently encodes the same data

[PATCH v4 00/11] Add per-core RAPL energy counter support for AMD CPUs

2024-07-11 Thread Dhananjay Ugwekar
Currently the energy-cores event in the power PMU aggregates energy consumption data at a package level. On the other hand the core energy RAPL counter in AMD CPUs has a core scope (which means the energy consumption is recorded separately for each core). Earlier efforts to add the core event in t

[PATCH v4 01/11] x86/topology: Introduce topology_logical_core_id()

2024-07-11 Thread Dhananjay Ugwekar
From: K Prateek Nayak On x86, topology_core_id() returns a unique core ID within the PKG domain. Looking at match_smt() suggests that a core ID just needs to be unique within a LLC domain. For use cases such as the per-core RAPL PMU, there exists a need for a unique core ID across the entire syst

[PATCH v4 02/11] perf/x86/rapl: Fix the energy-pkg event for AMD CPUs

2024-07-11 Thread Dhananjay Ugwekar
After commit ("x86/cpu/topology: Add support for the AMD 0x8026 leaf"), on AMD processors that support extended CPUID leaf 0x8026, the topology_die_cpumask() and topology_logical_die_id() macros, no longer return the package cpumask and package id, instead they return the CCD (Core Complex

[PATCH v4 03/11] perf/x86/rapl: Rename rapl_pmu variables

2024-07-11 Thread Dhananjay Ugwekar
Rename struct rapl_pmu variables from "pmu" to "rapl_pmu", to avoid any confusion between the variables of two different structs pmu and rapl_pmu. As rapl_pmu also contains a pointer to struct pmu, which leads to situations in code like pmu->pmu, which is needlessly confusing. Above scenario is rep

[PATCH v4 04/11] perf/x86/rapl: Make rapl_model struct global

2024-07-11 Thread Dhananjay Ugwekar
To support AMD's per_core RAPL counter, we will need to check per_core capability of the current rapl_model multiple times in rapl_cpu_online/offline, init_rapl_pmus functions, so cache the matched rapl model in a global variable, to avoid calling x86_match_cpu() multiple times. No functional chan

[PATCH v4 05/11] perf/x86/rapl: Move cpumask variable to rapl_pmus struct

2024-07-11 Thread Dhananjay Ugwekar
This patch is in preparation for addition of per-core energy counter support for AMD CPUs. Per-core energy counter PMU will need a separate cpumask. It seems like a better approach to add the cpumask inside the rapl_pmus struct, instead of creating another global cpumask variable for per-core PMU.

[PATCH v4 06/11] perf/x86/rapl: Add wrapper for online/offline functions

2024-07-11 Thread Dhananjay Ugwekar
This is in preparation for the addition of per-core RAPL counter support for AMD CPUs. The CPU online and offline functions will need to handle the setting up and migration of the new per-core PMU as well. The wrapper functions added below will make it easier to pass the corresponding args for bot

[PATCH v4 07/11] perf/x86/rapl: Add an argument to the cleanup and init functions

2024-07-11 Thread Dhananjay Ugwekar
Prep for per-core RAPL PMU addition. No functional change. Signed-off-by: Dhananjay Ugwekar --- arch/x86/events/rapl.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c index 1d36565d0cb9..362e82284ccb 100644 --- a

[PATCH v4 08/11] perf/x86/rapl: Modify the generic variable names to *_pkg*

2024-07-11 Thread Dhananjay Ugwekar
Prep for addition of power_per_core PMU to handle core scope energy consumption for AMD CPUs. Replace the generic names with *_pkg*, to differentiate between the scopes of the two different PMUs and their variables. No functional change. Signed-off-by: Dhananjay Ugwekar --- Changes in v4: * Mov

[PATCH v4 09/11] perf/x86/rapl: Remove the global variable rapl_msrs

2024-07-11 Thread Dhananjay Ugwekar
After making the rapl_model struct global, the rapl_msrs global variable isn't needed, so remove it. Also it will be cleaner when new per-core scope PMU is added. As we will need to maintain two rapl_msrs array(one for per-core scope and one for package scope PMU), inside the rapl_model struct. S

[PATCH v4 10/11] perf/x86/rapl: Add per-core energy counter support for AMD CPUs

2024-07-11 Thread Dhananjay Ugwekar
Add a new "power_per_core" PMU and "energy-per-core" event for monitoring energy consumption by each core. The existing energy-cores event aggregates the energy consumption at the package level. This new event aligns with the AMD's per_core energy counters. Tested the package level and core level

[PATCH v4 11/11] perf/x86/rapl: Remove the unused function cpu_to_rapl_pmu

2024-07-11 Thread Dhananjay Ugwekar
After the addition of per-core counters support, this function does not work as the same CPU can be mapped to multiple rapl_pmu structs (package or per-core). So, remove it. Signed-off-by: Dhananjay Ugwekar --- arch/x86/events/rapl.c | 12 1 file changed, 12 deletions(-) diff --git

Re: [PATCH 2/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Add __counted_by annotation

2024-07-11 Thread Bryan O'Donoghue
On 11/07/2024 00:09, Kees Cook wrote: The only direct user of struct hfi_session_release_buffer_pkt is pkt_session_unset_buffers() which sets "num_buffers" before using it as a loop counter for accessing "buffer_info". Add the __counted_by annotation to reflect the relationship. Signed-off-by: K

Re: [PATCH 1/2] media: venus: hfi_cmds: struct hfi_session_release_buffer_pkt: Replace 1-element array with flexible array

2024-07-11 Thread Bryan O'Donoghue
On 11/07/2024 00:09, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct hfi_session_release_buffer_pkt with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-11 Thread Alexander Lobakin
From: Eric Dumazet Date: Wed, 10 Jul 2024 10:04:39 -0700 > On Wed, Jul 10, 2024 at 4:19 AM Breno Leitao wrote: >> >> Hello Eric, >> >> On Tue, Jul 09, 2024 at 08:27:45AM -0700, Eric Dumazet wrote: >>> On Tue, Jul 9, 2024 at 5:54 AM Breno Leitao wrote: >> @@ -2596,7 +2599,7 @@ void dev_net_

Re: [PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array

2024-07-11 Thread David Sterba
On Wed, Jul 10, 2024 at 03:57:34PM -0700, Kees Cook wrote: > Replace the deprecated[1] use of a 1-element array in > struct slink_front with a modern flexible array. > > No binary differences are present after this conversion. > > Link: https://github.com/KSPP/linux/issues/79 [1] > Signed-off-by:

Re: [PATCH net-next v2] netdevice: define and allocate &net_device _properly_

2024-07-11 Thread Eric Dumazet
On Thu, Jul 11, 2024 at 5:54 AM Alexander Lobakin wrote: > > From: Eric Dumazet > Date: Wed, 10 Jul 2024 10:04:39 -0700 > > > This is because of the ‘const’ qualifier of the parameter. > > > > This could be solved with _Generic() later, if we want to keep the > > const qualifier. > > I tried _Gen

[PATCH 0/4] scsi: mpi3mr: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Kees Cook
Hi, Replace all the uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays. Thanks! -Kees Kees Cook (4): scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace 1-element array with flexible array scsi: mpi3mr: struct mpi3_event_data_pcie_topo

[PATCH 3/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page0: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct mpi3_sas_io_unit_page0 with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --- Cc: Sathya Prakash Veerichetty Cc: Kashyap De

[PATCH 2/4] scsi: mpi3mr: struct mpi3_event_data_pcie_topology_change_list: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct mpi3_event_data_pcie_topology_change_list with a modern flexible array. Additionally add __counted_by annotation since port_entry is only ever accessed in loops controlled by num_entries. For example: for (i = 0; i < event_data-

[PATCH 1/4] scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct mpi3_event_data_sas_topology_change_list with a modern flexible array. Additionally add __counted_by annotation since phy_entry is only ever accessed in loops controlled by num_entries. For example: for (i = 0; i < event_data->n

[PATCH 4/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page1: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct mpi3_sas_io_unit_page1 with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --- Cc: Sathya Prakash Veerichetty Cc: Kashyap De

[PATCH] scsi: megaraid_sas: struct MR_LD_VF_MAP: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct MR_LD_VF_MAP with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --- Cc: Kashyap Desai Cc: Sumit Saxena Cc: Shivasharan S

[PATCH] scsi: megaraid_sas: struct MR_HOST_DEVICE_LIST: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct MR_HOST_DEVICE_LIST with a modern flexible array. One binary difference appears in megasas_host_device_list_query(): struct MR_HOST_DEVICE_LIST *ci; ... ci = instance->host_device_list_buf; ... me

Re: [PATCH] fs/affs: struct slink_front: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
On Thu, Jul 11, 2024 at 04:29:28PM +0200, David Sterba wrote: > On Wed, Jul 10, 2024 at 03:57:34PM -0700, Kees Cook wrote: > > Replace the deprecated[1] use of a 1-element array in > > struct slink_front with a modern flexible array. > > > > No binary differences are present after this conversion.

Re: [PATCH 1/4] scsi: mpi3mr: struct mpi3_event_data_sas_topology_change_list: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 09:56, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct mpi3_event_data_sas_topology_change_list with a modern flexible array. Additionally add __counted_by annotation since phy_entry is only ever accessed in loops controlled by num_entries. For exampl

Re: [PATCH 2/4] scsi: mpi3mr: struct mpi3_event_data_pcie_topology_change_list: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 09:56, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct mpi3_event_data_pcie_topology_change_list with a modern flexible array. Additionally add __counted_by annotation since port_entry is only ever accessed in loops controlled by num_entries. For exam

Re: [PATCH 3/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page0: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 09:56, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct mpi3_sas_io_unit_page0 with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewe

Re: [PATCH 4/4] scsi: mpi3mr: struct mpi3_sas_io_unit_page1: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 09:56, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct mpi3_sas_io_unit_page1 with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewe

Re: [PATCH] scsi: megaraid_sas: struct MR_LD_VF_MAP: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 09:58, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct MR_LD_VF_MAP with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook Reviewed-by: Gust

Re: [PATCH v4] x86/traps: Enable UBSAN traps on x86

2024-07-11 Thread Kees Cook
On Thu, Jul 11, 2024 at 11:06:12AM +0200, Marco Elver wrote: > On Thu, 11 Jul 2024 at 10:10, Peter Zijlstra wrote: > > > > On Wed, Jul 10, 2024 at 08:32:38PM +, Gatlin Newhouse wrote: > > > Currently ARM architectures extract which specific sanitizer > > > has caused a trap via encoded data in

Re: [PATCH] scsi: megaraid_sas: struct MR_HOST_DEVICE_LIST: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 09:58, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct MR_HOST_DEVICE_LIST with a modern flexible array. One binary difference appears in megasas_host_device_list_query(): struct MR_HOST_DEVICE_LIST *ci; ... ci = instance->h

[PATCH] tsacct: Replace strncpy() with strscpy()

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of strncpy() in bacct_add_tsk(). Since this is UAPI, include trailing padding in the copy. Link: https://github.com/KSPP/linux/issues/90 [1] Signed-off-by: Kees Cook --- Cc: Andrew Morton Cc: "Eric W. Biederman" Cc: Peng Liu Cc: "Dr. Thomas Orgis" Cc: Ismael Luce

[PATCH] net/ipv4: Replace tcp_ca_get_name_by_key()'s strncpy() with strscpy()

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of strncpy() in tcp_ca_get_name_by_key(). The only caller passes the results to nla_put_string(), so trailing padding is not needed. Since passing "buffer" decays it to a pointer, the size can't be trivially determined by the compiler. ca->name is the same length, so

[PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct _RAID_VOL0_SETTINGS with a modern flexible array. Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks: lsi/mpi_cnfg.h:RAID_VOL0_PHYS_DISK PhysDisk[] __counted_by(Num

[PATCH 0/6] scsi: message: fusion: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Kees Cook
Hi, Replace all remaining uses of deprecated 1-element "fake" flexible arrays with modern C99 flexible arrays. Add __counted_by annotations at the same time. Thanks! -Kees Kees Cook (6): scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array scsi:

[PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_RAID_PHYS_DISK_1 with a modern flexible array. Additionally add __counted_by annotation since Path is only ever accessed via a loops bounded by NumPhysDiskPaths: lsi/mpi_cnfg.h:RAID_PHYS_DISK1_PATHPath[] __

[PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_SAS_IO_UNIT_0 with a modern flexible array. Additionally add __counted_by annotation since PhyData is only ever accessed via a loops bounded by NumPhys: lsi/mpi_cnfg.h:MPI_SAS_IO_UNIT0_PHY_DATA PhyData[] __counte

[PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_2 with a modern flexible array. Additionally add __counted_by annotation since RaidVolume is only ever accessed from loops controlled by NumActiveVolumes: lsi/mpi_cnfg.h:CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __c

[PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_3 with a modern flexible array. Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks: lsi/mpi_cnfg.h:IOC_3_PHYS_DISK PhysDisk[] __counted_by(

[PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_4 with a modern flexible array. Additionally add __counted_by annotation since SEP is only ever accessed after updating ACtiveSEP: lsi/mpi_cnfg.h:IOC_4_SEP SEP[] __counted_by(ActiveSEP); /* 08h *

Re: [PATCH] net/ipv4: Replace tcp_ca_get_name_by_key()'s strncpy() with strscpy()

2024-07-11 Thread Eric Dumazet
On Thu, Jul 11, 2024 at 10:16 AM Kees Cook wrote: > > Replace the deprecated[1] use of strncpy() in tcp_ca_get_name_by_key(). > The only caller passes the results to nla_put_string(), so trailing > padding is not needed. > > Since passing "buffer" decays it to a pointer, the size can't be > trivia

[PATCH] scsi: aacraid: union aac_init: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in union aac_init with a modern flexible array. Additionally add __counted_by annotation since rrq is only ever accessed after rr_queue_count has been set (with the same value used to control the loop): init->r8.rr_queue_count = c

[PATCH] scsi: aacraid: struct aac_ciss_phys_luns_resp: Replace 1-element array with flexible array

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element array in struct aac_ciss_phys_luns_resp with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --- Cc: Adaptec OEM Raid Solutions Cc: "James E.

Re: [PATCH] scsi: aacraid: struct aac_ciss_phys_luns_resp: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:50, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct aac_ciss_phys_luns_resp with a modern flexible array. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --- Cc:

Re: [PATCH] scsi: aacraid: union aac_init: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:48, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in union aac_init with a modern flexible array. Additionally add __counted_by annotation since rrq is only ever accessed after rr_queue_count has been set (with the same value used to control the loop):

[PATCH] scsi: ipr: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of a 1-element arrays in struct ipr_hostrcb_fabric_desc and struct ipr_hostrcb64_fabric_desc with modern flexible arrays. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [1] Signed-off-by: Kees Cook --- Cc: Bria

Re: [PATCH] mm/kmemleak: Replace strncpy() with strscpy()

2024-07-11 Thread Catalin Marinas
On Tue, Jul 09, 2024 at 05:13:08PM -0700, Kees Cook wrote: > Replace the depreciated[1] strncpy() calls with strscpy(). Uses of > object->comm do not depend on the padding side-effect. > > Link: https://github.com/KSPP/linux/issues/90 [1] > Signed-off-by: Kees Cook Acked-by: Catalin Marinas (u

Re: [PATCH] scsi: megaraid_sas: struct MR_HOST_DEVICE_LIST: Replace 1-element array with flexible array

2024-07-11 Thread James Bottomley
On Thu, 2024-07-11 at 08:58 -0700, Kees Cook wrote: > Replace the deprecated[1] use of a 1-element array in > struct MR_HOST_DEVICE_LIST with a modern flexible array. > > One binary difference appears in megasas_host_device_list_query(): > >     struct MR_HOST_DEVICE_LIST *ci; > ... >

Re: [PATCH 1/6] scsi: message: fusion: struct _RAID_VOL0_SETTINGS: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:28, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct _RAID_VOL0_SETTINGS with a modern flexible array. Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks: lsi/mpi_cnfg.h:RAID_VOL0_P

Re: [PATCH 2/6] scsi: message: fusion: struct _CONFIG_PAGE_SAS_IO_UNIT_0: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:28, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_SAS_IO_UNIT_0 with a modern flexible array. Additionally add __counted_by annotation since PhyData is only ever accessed via a loops bounded by NumPhys: lsi/mpi_cnfg.h:MPI_SAS_IO

Re: [PATCH 3/6] scsi: message: fusion: struct _CONFIG_PAGE_RAID_PHYS_DISK_1: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:28, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_RAID_PHYS_DISK_1 with a modern flexible array. Additionally add __counted_by annotation since Path is only ever accessed via a loops bounded by NumPhysDiskPaths: lsi/mpi_cnfg.h:R

Re: [PATCH 4/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_2: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:28, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_2 with a modern flexible array. Additionally add __counted_by annotation since RaidVolume is only ever accessed from loops controlled by NumActiveVolumes: lsi/mpi_cnfg.h:CONF

Re: [PATCH 5/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_3: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:28, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_3 with a modern flexible array. Additionally add __counted_by annotation since PhysDisk is only ever accessed via a loops bounded by NumPhysDisks: lsi/mpi_cnfg.h:IOC_3_PHYS_D

Re: [PATCH 6/6] scsi: message: fusion: struct _CONFIG_PAGE_IOC_4: Replace 1-element array with flexible array

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 11:28, Kees Cook wrote: Replace the deprecated[1] use of a 1-element array in struct _CONFIG_PAGE_IOC_4 with a modern flexible array. Additionally add __counted_by annotation since SEP is only ever accessed after updating ACtiveSEP: lsi/mpi_cnfg.h:IOC_4_SEP

Re: [PATCH] scsi: ipr: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Gustavo A. R. Silva
On 11/07/24 12:07, Kees Cook wrote: Replace the deprecated[1] use of a 1-element arrays in struct ipr_hostrcb_fabric_desc and struct ipr_hostrcb64_fabric_desc with modern flexible arrays. No binary differences are present after this conversion. Link: https://github.com/KSPP/linux/issues/79 [

Re: [PATCH v4] x86/traps: Enable UBSAN traps on x86

2024-07-11 Thread Peter Zijlstra
On Thu, Jul 11, 2024 at 09:35:24AM -0700, Kees Cook wrote: > On Thu, Jul 11, 2024 at 11:06:12AM +0200, Marco Elver wrote: > > On Thu, 11 Jul 2024 at 10:10, Peter Zijlstra wrote: > > > > > > On Wed, Jul 10, 2024 at 08:32:38PM +, Gatlin Newhouse wrote: > > > > Currently ARM architectures extract

Re: [PATCH] x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()

2024-07-11 Thread Dave Hansen
On 7/8/24 13:22, Kees Cook wrote: ... > diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h > index 2fc7bc3863ff..7c488ff0c764 100644 > --- a/arch/x86/include/asm/syscall.h > +++ b/arch/x86/include/asm/syscall.h > @@ -82,7 +82,12 @@ static inline void syscall_get_arguments(

Re: [PATCH] x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()

2024-07-11 Thread Peter Zijlstra
On Mon, Jul 08, 2024 at 01:22:06PM -0700, Kees Cook wrote: > Modern (fortified) memcpy() prefers to avoid writing (or reading) beyond > the end of the addressed destination (or source) struct member: > > In function ‘fortify_memcpy_chk’, > inlined from ‘syscall_get_arguments’ at > ./arch/x86/

[PATCH 1/2] scsi: aacraid: Rearrange order of struct aac_srb_unit

2024-07-11 Thread Kees Cook
struct aac_srb_unit contains struct aac_srb, which contains struct sgmap, which ends in a (currently) "fake" (1-element) flexible array. Converting this to a flexible array is needed so that runtime bounds checking won't think the array is fixed size (i.e. under CONFIG_FORTIFY_SOURCE=y and/or CONFI

[PATCH 0/2] scsi: aacraid: struct sgmap: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Kees Cook
Hi, This replaces some of the last remaining uses in the kernel of 1-element "fake" flexible arrays with modern C99 flexible arrays. Some refactoring is done to ease this, and binary differences are identified. For the on stack size changes in patch 2, the "yes, that is the source of the binary di

[PATCH 2/2] scsi: aacraid: struct {user,}sgmap{,64,raw}: Replace 1-element arrays with flexible arrays

2024-07-11 Thread Kees Cook
Replace the deprecated[1] use of 1-element arrays in struct sgmap, struct sgmap64, struct sgmapraw, struct user_sgmap, and struct user_sgmap64 with modern flexible arrays. Additionally remove struct user_sgmapraw as it is unused. The resulting binary output differences from this change are limited

Re: [PATCH v4 00/11] Add per-core RAPL energy counter support for AMD CPUs

2024-07-11 Thread Ian Rogers
On Thu, Jul 11, 2024 at 3:25 AM Dhananjay Ugwekar wrote: > > Currently the energy-cores event in the power PMU aggregates energy > consumption data at a package level. On the other hand the core energy > RAPL counter in AMD CPUs has a core scope (which means the energy > consumption is recorded se

Re: [PATCH] x86/syscall: Avoid memcpy() for ia32 syscall_get_arguments()

2024-07-11 Thread Kees Cook
On Thu, Jul 11, 2024 at 11:44:50PM +0200, Peter Zijlstra wrote: > Just for my education on things foritfy; would something like: > > void syscall_get_arguments(struct pt_regs *regs, unsigned long args[6]) > { > memcpy(args, (typeof(args))®s->bx, 6*sizeof(args[0])); > } Short answer: no.

Re: [PATCH net-next v3] netdevice: define and allocate &net_device _properly_

2024-07-11 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski : On Wed, 10 Jul 2024 04:30:28 -0700 you wrote: > From: Alexander Lobakin > > In fact, this structure contains a flexible array at the end, but > historically its size, alignment etc., is calculated manually. > There

Re: [PATCH v4 02/11] perf/x86/rapl: Fix the energy-pkg event for AMD CPUs

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > After commit ("x86/cpu/topology: Add support for the AMD 0x8026 > leaf"), > on AMD processors that support extended CPUID leaf 0x8026, the > topology_die_cpumask() and topology_logical_die_id() macros, no > longer > return the pa

Re: [PATCH v4 03/11] perf/x86/rapl: Rename rapl_pmu variables

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > Rename struct rapl_pmu variables from "pmu" to "rapl_pmu", to > avoid any confusion between the variables of two different > structs pmu and rapl_pmu. As rapl_pmu also contains a pointer to > struct pmu, which leads to situations in code

Re: [PATCH v4 04/11] perf/x86/rapl: Make rapl_model struct global

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > To support AMD's per_core RAPL counter, we will need to check > per_core capability of the current rapl_model multiple times in > rapl_cpu_online/offline, init_rapl_pmus functions, so cache the > matched rapl model in a global variable,

Re: [PATCH v4 05/11] perf/x86/rapl: Move cpumask variable to rapl_pmus struct

2024-07-11 Thread Zhang, Rui
> @@ -710,6 +710,9 @@ static int __init init_rapl_pmus(void) > rapl_pmus = kzalloc(struct_size(rapl_pmus, rapl_pmu, > nr_rapl_pmu), GFP_KERNEL); > if (!rapl_pmus) > return -ENOMEM; > + > +   if (!alloc_cpumask_var(&rapl_pmus->cpumask, GFP_KERNEL)) > +

Re: [PATCH v4 06/11] perf/x86/rapl: Add wrapper for online/offline functions

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > This is in preparation for the addition of per-core RAPL counter > support > for AMD CPUs. > > The CPU online and offline functions will need to handle the setting > up and > migration of the new per-core PMU as well. The wrapper functi

Re: [PATCH v4 07/11] perf/x86/rapl: Add an argument to the cleanup and init functions

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > Prep for per-core RAPL PMU addition. > > No functional change. > > Signed-off-by: Dhananjay Ugwekar Reviewed-by: Zhang Rui -rui > --- >  arch/x86/events/rapl.c | 14 +- >  1 file changed, 9 insertions(+), 5 deletions(-)

Re: [PATCH v4 08/11] perf/x86/rapl: Modify the generic variable names to *_pkg*

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > Prep for addition of power_per_core PMU to handle core scope energy > consumption for AMD CPUs. > > Replace the generic names with *_pkg*, to differentiate between the > scopes of the two different PMUs and their variables. > > No func

Re: [PATCH v4 02/11] perf/x86/rapl: Fix the energy-pkg event for AMD CPUs

2024-07-11 Thread Dhananjay Ugwekar
Hello Rui, On 7/12/2024 7:34 AM, Zhang, Rui wrote: > On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: >> After commit ("x86/cpu/topology: Add support for the AMD 0x8026 >> leaf"), >> on AMD processors that support extended CPUID leaf 0x8026, the >> topology_die_cpumask() and top

Re: [PATCH v4 09/11] perf/x86/rapl: Remove the global variable rapl_msrs

2024-07-11 Thread Zhang, Rui
On Thu, 2024-07-11 at 10:24 +, Dhananjay Ugwekar wrote: > After making the rapl_model struct global, the rapl_msrs global > variable isn't needed, so remove it. > > Also it will be cleaner when new per-core scope PMU is added. As we > will > need to maintain two rapl_msrs array(one for per-cor

Re: [PATCH v4 05/11] perf/x86/rapl: Move cpumask variable to rapl_pmus struct

2024-07-11 Thread Dhananjay Ugwekar
On 7/12/2024 8:37 AM, Zhang, Rui wrote: >> @@ -710,6 +710,9 @@ static int __init init_rapl_pmus(void) >> rapl_pmus = kzalloc(struct_size(rapl_pmus, rapl_pmu, >> nr_rapl_pmu), GFP_KERNEL); >> if (!rapl_pmus) >> return -ENOMEM; >> + >> +   if (!alloc_cpumask_var

Re: [PATCH v4 10/11] perf/x86/rapl: Add per-core energy counter support for AMD CPUs

2024-07-11 Thread Zhang, Rui
> > @@ -352,9 +384,13 @@ static int rapl_pmu_event_init(struct perf_event > *event) > u64 cfg = event->attr.config & RAPL_EVENT_MASK; > int bit, ret = 0; > struct rapl_pmu *rapl_pmu; > +   struct rapl_pmus *curr_rapl_pmus; >   > /* only look at RAPL events */ >