* [PATCH AUTOSEL 4.19 02/14] drm/amdgpu: fix ucode out-of-bounds read warning
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 03/14] drm/amdgpu: fix mc_data " Sasha Levin
` (11 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Tim Huang, Alex Deucher, Sasha Levin, christian.koenig,
Xinhui.Pan, airlied, daniel, srinivasan.shanmugam, guchun.chen,
amd-gfx, dri-devel
From: Tim Huang <Tim.Huang@amd.com>
[ Upstream commit 8944acd0f9db33e17f387fdc75d33bb473d7936f ]
Clear warning that read ucode[] may out-of-bounds.
Signed-off-by: Tim Huang <Tim.Huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 387f1cf1dc207..9e768ff392fec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -212,6 +212,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
struct amdgpu_firmware_info *ucode;
id = fw_type_convert(cgs_device, type);
+ if (id >= AMDGPU_UCODE_ID_MAXIMUM)
+ return -EINVAL;
+
ucode = &adev->firmware.ucode[id];
if (ucode->fw == NULL)
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 03/14] drm/amdgpu: fix mc_data out-of-bounds read warning
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 02/14] drm/amdgpu: fix ucode out-of-bounds " Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 04/14] drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device Sasha Levin
` (10 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Tim Huang, Alex Deucher, Sasha Levin, christian.koenig,
Xinhui.Pan, airlied, daniel, lijo.lazar, Hawking.Zhang,
electrodeyt, amd-gfx, dri-devel
From: Tim Huang <Tim.Huang@amd.com>
[ Upstream commit 51dfc0a4d609fe700750a62f41447f01b8c9ea50 ]
Clear warning that read mc_data[i-1] may out-of-bounds.
Signed-off-by: Tim Huang <Tim.Huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
index 95f7bb22402f0..fe01df99445dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1625,6 +1625,8 @@ int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev,
(u32)le32_to_cpu(*((u32 *)reg_data + j));
j++;
} else if ((reg_table->mc_reg_address[i].pre_reg_data & LOW_NIBBLE_MASK) == DATA_EQU_PREV) {
+ if (i == 0)
+ continue;
reg_table->mc_reg_table_entry[num_ranges].mc_data[i] =
reg_table->mc_reg_table_entry[num_ranges].mc_data[i - 1];
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 04/14] drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 02/14] drm/amdgpu: fix ucode out-of-bounds " Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 03/14] drm/amdgpu: fix mc_data " Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 05/14] smack: tcp: ipv4, fix incorrect labeling Sasha Levin
` (9 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Michael Chen, Felix Kuehling, Alex Deucher, Sasha Levin,
Felix.Kuehling, christian.koenig, Xinhui.Pan, airlied, daniel,
amd-gfx, dri-devel
From: Michael Chen <michael.chen@amd.com>
[ Upstream commit 10f624ef239bd136cdcc5bbc626157a57b938a31 ]
Currently oem_id is defined as uint8_t[6] and casted to uint64_t*
in some use case. This would lead code scanner to complain about
access beyond. Re-define it in union to enforce 8-byte size and
alignment to avoid potential issue.
Signed-off-by: Michael Chen <michael.chen@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 --
drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +--
drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 5 ++++-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
index b5cd182b9edd2..037539c0b63fd 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
@@ -42,8 +42,6 @@
#define CRAT_OEMTABLEID_LENGTH 8
#define CRAT_RESERVED_LENGTH 6
-#define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1)
-
/* Compute Unit flags */
#define COMPUTE_UNIT_CPU (1 << 0) /* Create Virtual CRAT for CPU */
#define COMPUTE_UNIT_GPU (1 << 1) /* Create Virtual CRAT for GPU */
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 5cf499a07806a..4072013152925 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -863,8 +863,7 @@ static void kfd_update_system_properties(void)
dev = list_last_entry(&topology_device_list,
struct kfd_topology_device, list);
if (dev) {
- sys_props.platform_id =
- (*((uint64_t *)dev->oem_id)) & CRAT_OEMID_64BIT_MASK;
+ sys_props.platform_id = dev->oem_id64;
sys_props.platform_oem = *((uint64_t *)dev->oem_table_id);
sys_props.platform_rev = dev->oem_revision;
}
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h
index 7d9c3f948dff2..e47c0267f2060 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h
@@ -164,7 +164,10 @@ struct kfd_topology_device {
struct attribute attr_gpuid;
struct attribute attr_name;
struct attribute attr_props;
- uint8_t oem_id[CRAT_OEMID_LENGTH];
+ union {
+ uint8_t oem_id[CRAT_OEMID_LENGTH];
+ uint64_t oem_id64;
+ };
uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
uint32_t oem_revision;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 05/14] smack: tcp: ipv4, fix incorrect labeling
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (2 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 04/14] drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 06/14] ELF: fix kernel.randomize_va_space double read Sasha Levin
` (8 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Casey Schaufler, Konstantin Andreev, Sasha Levin, paul, jmorris,
serge, linux-security-module
From: Casey Schaufler <casey@schaufler-ca.com>
[ Upstream commit 2fe209d0ad2e2729f7e22b9b31a86cc3ff0db550 ]
Currently, Smack mirrors the label of incoming tcp/ipv4 connections:
when a label 'foo' connects to a label 'bar' with tcp/ipv4,
'foo' always gets 'foo' in returned ipv4 packets. So,
1) returned packets are incorrectly labeled ('foo' instead of 'bar')
2) 'bar' can write to 'foo' without being authorized to write.
Here is a scenario how to see this:
* Take two machines, let's call them C and S,
with active Smack in the default state
(no settings, no rules, no labeled hosts, only builtin labels)
* At S, add Smack rule 'foo bar w'
(labels 'foo' and 'bar' are instantiated at S at this moment)
* At S, at label 'bar', launch a program
that listens for incoming tcp/ipv4 connections
* From C, at label 'foo', connect to the listener at S.
(label 'foo' is instantiated at C at this moment)
Connection succeedes and works.
* Send some data in both directions.
* Collect network traffic of this connection.
All packets in both directions are labeled with the CIPSO
of the label 'foo'. Hence, label 'bar' writes to 'foo' without
being authorized, and even without ever being known at C.
If anybody cares: exactly the same happens with DCCP.
This behavior 1st manifested in release 2.6.29.4 (see Fixes below)
and it looks unintentional. At least, no explanation was provided.
I changed returned packes label into the 'bar',
to bring it into line with the Smack documentation claims.
Signed-off-by: Konstantin Andreev <andreev@swemel.ru>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
security/smack/smack_lsm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index d9bff4ba7f2e8..158f4df39be44 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -4291,7 +4291,7 @@ static int smack_inet_conn_request(struct sock *sk, struct sk_buff *skb,
rcu_read_unlock();
if (hskp == NULL)
- rc = netlbl_req_setattr(req, &skp->smk_netlabel);
+ rc = netlbl_req_setattr(req, &ssp->smk_out->smk_netlabel);
else
netlbl_req_delattr(req);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 06/14] ELF: fix kernel.randomize_va_space double read
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (3 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 05/14] smack: tcp: ipv4, fix incorrect labeling Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-27 12:18 ` Pavel Machek
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 07/14] udf: Avoid excessive partition lengths Sasha Levin
` (7 subsequent siblings)
12 siblings, 1 reply; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Alexey Dobriyan, Kees Cook, Sasha Levin, viro, brauner,
linux-fsdevel, linux-mm
From: Alexey Dobriyan <adobriyan@gmail.com>
[ Upstream commit 2a97388a807b6ab5538aa8f8537b2463c6988bd2 ]
ELF loader uses "randomize_va_space" twice. It is sysctl and can change
at any moment, so 2 loads could see 2 different values in theory with
unpredictable consequences.
Issue exactly one load for consistent value across one exec.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Link: https://lore.kernel.org/r/3329905c-7eb8-400a-8f0a-d87cff979b5b@p183
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/binfmt_elf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index c41c568ad1b8a..af8830878fa0b 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -876,7 +876,8 @@ static int load_elf_binary(struct linux_binprm *bprm)
if (elf_read_implies_exec(loc->elf_ex, executable_stack))
current->personality |= READ_IMPLIES_EXEC;
- if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
+ const int snapshot_randomize_va_space = READ_ONCE(randomize_va_space);
+ if (!(current->personality & ADDR_NO_RANDOMIZE) && snapshot_randomize_va_space)
current->flags |= PF_RANDOMIZE;
setup_new_exec(bprm);
@@ -1136,7 +1137,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
current->mm->end_data = end_data;
current->mm->start_stack = bprm->p;
- if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) {
+ if ((current->flags & PF_RANDOMIZE) && (snapshot_randomize_va_space > 1)) {
/*
* For architectures with ELF randomization, when executing
* a loader directly (i.e. no interpreter listed in ELF
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH AUTOSEL 4.19 06/14] ELF: fix kernel.randomize_va_space double read
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 06/14] ELF: fix kernel.randomize_va_space double read Sasha Levin
@ 2024-08-27 12:18 ` Pavel Machek
0 siblings, 0 replies; 15+ messages in thread
From: Pavel Machek @ 2024-08-27 12:18 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel, stable, Alexey Dobriyan, Kees Cook, viro, brauner,
linux-fsdevel, linux-mm
[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]
Hi!
> [ Upstream commit 2a97388a807b6ab5538aa8f8537b2463c6988bd2 ]
>
> ELF loader uses "randomize_va_space" twice. It is sysctl and can change
> at any moment, so 2 loads could see 2 different values in theory with
> unpredictable consequences.
>
> Issue exactly one load for consistent value across one exec.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> Link: https://lore.kernel.org/r/3329905c-7eb8-400a-8f0a-d87cff979b5b@p183
> Signed-off-by: Kees Cook <kees@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> fs/binfmt_elf.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> index c41c568ad1b8a..af8830878fa0b 100644
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -876,7 +876,8 @@ static int load_elf_binary(struct linux_binprm *bprm)
> if (elf_read_implies_exec(loc->elf_ex, executable_stack))
> current->personality |= READ_IMPLIES_EXEC;
>
> - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
> + const int snapshot_randomize_va_space = READ_ONCE(randomize_va_space);
> + if (!(current->personality & ADDR_NO_RANDOMIZE) && snapshot_randomize_va_space)
> current->flags |= PF_RANDOMIZE;
>
> setup_new_exec(bprm);
We normally put variable declaration at start of the function. I'd not
be surprised if this broke with older compilers.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH AUTOSEL 4.19 07/14] udf: Avoid excessive partition lengths
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (4 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 06/14] ELF: fix kernel.randomize_va_space double read Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 08/14] cgroup: Protect css->cgroup write under css_set_lock Sasha Levin
` (6 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Jan Kara, Sasha Levin, jack
From: Jan Kara <jack@suse.cz>
[ Upstream commit ebbe26fd54a9621994bc16b14f2ba8f84c089693 ]
Avoid mounting filesystems where the partition would overflow the
32-bits used for block number. Also refuse to mount filesystems where
the partition length is so large we cannot safely index bits in a
block bitmap.
Link: https://patch.msgid.link/20240620130403.14731-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/udf/super.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fs/udf/super.c b/fs/udf/super.c
index bce48a07790cb..077bc40df130e 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1047,12 +1047,19 @@ static int udf_fill_partdesc_info(struct super_block *sb,
struct udf_part_map *map;
struct udf_sb_info *sbi = UDF_SB(sb);
struct partitionHeaderDesc *phd;
+ u32 sum;
int err;
map = &sbi->s_partmaps[p_index];
map->s_partition_len = le32_to_cpu(p->partitionLength); /* blocks */
map->s_partition_root = le32_to_cpu(p->partitionStartingLocation);
+ if (check_add_overflow(map->s_partition_root, map->s_partition_len,
+ &sum)) {
+ udf_err(sb, "Partition %d has invalid location %u + %u\n",
+ p_index, map->s_partition_root, map->s_partition_len);
+ return -EFSCORRUPTED;
+ }
if (p->accessType == cpu_to_le32(PD_ACCESS_TYPE_READ_ONLY))
map->s_partition_flags |= UDF_PART_FLAG_READ_ONLY;
@@ -1108,6 +1115,14 @@ static int udf_fill_partdesc_info(struct super_block *sb,
bitmap->s_extPosition = le32_to_cpu(
phd->unallocSpaceBitmap.extPosition);
map->s_partition_flags |= UDF_PART_FLAG_UNALLOC_BITMAP;
+ /* Check whether math over bitmap won't overflow. */
+ if (check_add_overflow(map->s_partition_len,
+ sizeof(struct spaceBitmapDesc) << 3,
+ &sum)) {
+ udf_err(sb, "Partition %d is too long (%u)\n", p_index,
+ map->s_partition_len);
+ return -EFSCORRUPTED;
+ }
udf_debug("unallocSpaceBitmap (part %d) @ %u\n",
p_index, bitmap->s_extPosition);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 08/14] cgroup: Protect css->cgroup write under css_set_lock
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (5 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 07/14] udf: Avoid excessive partition lengths Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 09/14] um: line: always fill *error_out in setup_one_line() Sasha Levin
` (5 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Waiman Long, Tejun Heo, Sasha Levin, lizefan.x, hannes, mkoutny,
cgroups
From: Waiman Long <longman@redhat.com>
[ Upstream commit 57b56d16800e8961278ecff0dc755d46c4575092 ]
The writing of css->cgroup associated with the cgroup root in
rebind_subsystems() is currently protected only by cgroup_mutex.
However, the reading of css->cgroup in both proc_cpuset_show() and
proc_cgroup_show() is protected just by css_set_lock. That makes the
readers susceptible to racing problems like data tearing or caching.
It is also a problem that can be reported by KCSAN.
This can be fixed by using READ_ONCE() and WRITE_ONCE() to access
css->cgroup. Alternatively, the writing of css->cgroup can be moved
under css_set_lock as well which is done by this patch.
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/cgroup/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 6322b56529e91..30c0588067029 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1712,9 +1712,9 @@ int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask)
RCU_INIT_POINTER(scgrp->subsys[ssid], NULL);
rcu_assign_pointer(dcgrp->subsys[ssid], css);
ss->root = dst_root;
- css->cgroup = dcgrp;
spin_lock_irq(&css_set_lock);
+ css->cgroup = dcgrp;
WARN_ON(!list_empty(&dcgrp->e_csets[ss->id]));
list_for_each_entry_safe(cset, cset_pos, &scgrp->e_csets[ss->id],
e_cset_node[ss->id]) {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 09/14] um: line: always fill *error_out in setup_one_line()
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (6 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 08/14] cgroup: Protect css->cgroup write under css_set_lock Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 10/14] devres: Initialize an uninitialized struct member Sasha Levin
` (4 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Johannes Berg, Anton Ivanov, Sasha Levin, richard, johannes,
gregkh, jirislaby, roberto.sassu, benjamin, linux-um
From: Johannes Berg <johannes.berg@intel.com>
[ Upstream commit 824ac4a5edd3f7494ab1996826c4f47f8ef0f63d ]
The pointer isn't initialized by callers, but I have
encountered cases where it's still printed; initialize
it in all possible cases in setup_one_line().
Link: https://patch.msgid.link/20240703172235.ad863568b55f.Iaa1eba4db8265d7715ba71d5f6bb8c7ff63d27e9@changeid
Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/um/drivers/line.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 71e26488dfde2..b5c3bc0e6bce0 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -391,6 +391,7 @@ int setup_one_line(struct line *lines, int n, char *init,
parse_chan_pair(NULL, line, n, opts, error_out);
err = 0;
}
+ *error_out = "configured as 'none'";
} else {
char *new = kstrdup(init, GFP_KERNEL);
if (!new) {
@@ -414,6 +415,7 @@ int setup_one_line(struct line *lines, int n, char *init,
}
}
if (err) {
+ *error_out = "failed to parse channel pair";
line->init_str = NULL;
line->valid = 0;
kfree(new);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 10/14] devres: Initialize an uninitialized struct member
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (7 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 09/14] um: line: always fill *error_out in setup_one_line() Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 11/14] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv Sasha Levin
` (3 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Zijun Hu, Greg Kroah-Hartman, Sasha Levin
From: Zijun Hu <quic_zijuhu@quicinc.com>
[ Upstream commit 56a20ad349b5c51909cf8810f7c79b288864ad33 ]
Initialize an uninitialized struct member for driver API
devres_open_group().
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/1719931914-19035-4-git-send-email-quic_zijuhu@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/base/devres.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index d68b52cf92251..299d58a96a7b7 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -559,6 +559,7 @@ void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
grp->id = grp;
if (id)
grp->id = id;
+ grp->color = 0;
spin_lock_irqsave(&dev->devres_lock, flags);
add_dr(dev, &grp->node[0]);
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 11/14] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (8 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 10/14] devres: Initialize an uninitialized struct member Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 12/14] hwmon: (lm95234) Fix underflows seen when writing limit attributes Sasha Levin
` (2 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Krishna Kumar, Timothy Pearson, Bjorn Helgaas, Shawn Anastasio,
Michael Ellerman, Sasha Levin, linuxppc-dev, linux-pci
From: Krishna Kumar <krishnak@linux.ibm.com>
[ Upstream commit 335e35b748527f0c06ded9eebb65387f60647fda ]
The hotplug driver for powerpc (pci/hotplug/pnv_php.c) causes a kernel
crash when we try to hot-unplug/disable the PCIe switch/bridge from
the PHB.
The crash occurs because although the MSI data structure has been
released during disable/hot-unplug path and it has been assigned
with NULL, still during unregistration the code was again trying to
explicitly disable the MSI which causes the NULL pointer dereference and
kernel crash.
The patch fixes the check during unregistration path to prevent invoking
pci_disable_msi/msix() since its data structure is already freed.
Reported-by: Timothy Pearson <tpearson@raptorengineering.com>
Closes: https://lore.kernel.org/all/1981605666.2142272.1703742465927.JavaMail.zimbra@raptorengineeringinc.com/
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Shawn Anastasio <sanastasio@raptorengineering.com>
Signed-off-by: Krishna Kumar <krishnak@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240701074513.94873-2-krishnak@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/hotplug/pnv_php.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index 3276a5e4c430b..486fad4309584 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -35,7 +35,6 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot,
bool disable_device)
{
struct pci_dev *pdev = php_slot->pdev;
- int irq = php_slot->irq;
u16 ctrl;
if (php_slot->irq > 0) {
@@ -54,7 +53,7 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot,
php_slot->wq = NULL;
}
- if (disable_device || irq > 0) {
+ if (disable_device) {
if (pdev->msix_enabled)
pci_disable_msix(pdev);
else if (pdev->msi_enabled)
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 12/14] hwmon: (lm95234) Fix underflows seen when writing limit attributes
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (9 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 11/14] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 13/14] hwmon: (w83627ehf) " Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 14/14] wifi: mwifiex: Do not return unused priv in mwifiex_get_priv_by_id() Sasha Levin
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Guenter Roeck, Sasha Levin, jdelvare, linux-hwmon
From: Guenter Roeck <linux@roeck-us.net>
[ Upstream commit af64e3e1537896337405f880c1e9ac1f8c0c6198 ]
DIV_ROUND_CLOSEST() after kstrtol() results in an underflow if a large
negative number such as -9223372036854775808 is provided by the user.
Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hwmon/lm95234.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/lm95234.c b/drivers/hwmon/lm95234.c
index c7fcc9e7f57a2..13912ac7c69fc 100644
--- a/drivers/hwmon/lm95234.c
+++ b/drivers/hwmon/lm95234.c
@@ -310,7 +310,8 @@ static ssize_t set_tcrit2(struct device *dev, struct device_attribute *attr,
if (ret < 0)
return ret;
- val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, index ? 255 : 127);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, 0, (index ? 255 : 127) * 1000),
+ 1000);
mutex_lock(&data->update_lock);
data->tcrit2[index] = val;
@@ -359,7 +360,7 @@ static ssize_t set_tcrit1(struct device *dev, struct device_attribute *attr,
if (ret < 0)
return ret;
- val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 255);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 255000), 1000);
mutex_lock(&data->update_lock);
data->tcrit1[index] = val;
@@ -400,7 +401,7 @@ static ssize_t set_tcrit1_hyst(struct device *dev,
if (ret < 0)
return ret;
- val = DIV_ROUND_CLOSEST(val, 1000);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, -255000, 255000), 1000);
val = clamp_val((int)data->tcrit1[index] - val, 0, 31);
mutex_lock(&data->update_lock);
@@ -440,7 +441,7 @@ static ssize_t set_offset(struct device *dev, struct device_attribute *attr,
return ret;
/* Accuracy is 1/2 degrees C */
- val = clamp_val(DIV_ROUND_CLOSEST(val, 500), -128, 127);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, -64000, 63500), 500);
mutex_lock(&data->update_lock);
data->toffset[index] = val;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 13/14] hwmon: (w83627ehf) Fix underflows seen when writing limit attributes
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (10 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 12/14] hwmon: (lm95234) Fix underflows seen when writing limit attributes Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 14/14] wifi: mwifiex: Do not return unused priv in mwifiex_get_priv_by_id() Sasha Levin
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable; +Cc: Guenter Roeck, Sasha Levin, jdelvare, linux-hwmon
From: Guenter Roeck <linux@roeck-us.net>
[ Upstream commit 5c1de37969b7bc0abcb20b86e91e70caebbd4f89 ]
DIV_ROUND_CLOSEST() after kstrtol() results in an underflow if a large
negative number such as -9223372036854775808 is provided by the user.
Fix it by reordering clamp_val() and DIV_ROUND_CLOSEST() operations.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hwmon/w83627ehf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index ad68b6d9ff17e..8da5f77b8987c 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1519,7 +1519,7 @@ store_target_temp(struct device *dev, struct device_attribute *attr,
if (err < 0)
return err;
- val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 127);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 127000), 1000);
mutex_lock(&data->update_lock);
data->target_temp[nr] = val;
@@ -1545,7 +1545,7 @@ store_tolerance(struct device *dev, struct device_attribute *attr,
return err;
/* Limit the temp to 0C - 15C */
- val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 0, 15);
+ val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 15000), 1000);
mutex_lock(&data->update_lock);
if (sio_data->kind == nct6775 || sio_data->kind == nct6776) {
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH AUTOSEL 4.19 14/14] wifi: mwifiex: Do not return unused priv in mwifiex_get_priv_by_id()
2024-08-01 0:40 [PATCH AUTOSEL 4.19 01/14] drm/amdgpu: fix overflowed array index read warning Sasha Levin
` (11 preceding siblings ...)
2024-08-01 0:40 ` [PATCH AUTOSEL 4.19 13/14] hwmon: (w83627ehf) " Sasha Levin
@ 2024-08-01 0:40 ` Sasha Levin
12 siblings, 0 replies; 15+ messages in thread
From: Sasha Levin @ 2024-08-01 0:40 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sascha Hauer, Brian Norris, Francesco Dolcini, Kalle Valo,
Sasha Levin, dmantipov, johannes.berg, linus.walleij,
linux-wireless
From: Sascha Hauer <s.hauer@pengutronix.de>
[ Upstream commit c145eea2f75ff7949392aebecf7ef0a81c1f6c14 ]
mwifiex_get_priv_by_id() returns the priv pointer corresponding to
the bss_num and bss_type, but without checking if the priv is actually
currently in use.
Unused priv pointers do not have a wiphy attached to them which can
lead to NULL pointer dereferences further down the callstack. Fix
this by returning only used priv pointers which have priv->bss_mode
set to something else than NL80211_IFTYPE_UNSPECIFIED.
Said NULL pointer dereference happened when an Accesspoint was started
with wpa_supplicant -i mlan0 with this config:
network={
ssid="somessid"
mode=2
frequency=2412
key_mgmt=WPA-PSK WPA-PSK-SHA256
proto=RSN
group=CCMP
pairwise=CCMP
psk="12345678"
}
When waiting for the AP to be established, interrupting wpa_supplicant
with <ctrl-c> and starting it again this happens:
| Unable to handle kernel NULL pointer dereference at virtual address 0000000000000140
| Mem abort info:
| ESR = 0x0000000096000004
| EC = 0x25: DABT (current EL), IL = 32 bits
| SET = 0, FnV = 0
| EA = 0, S1PTW = 0
| FSC = 0x04: level 0 translation fault
| Data abort info:
| ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
| CM = 0, WnR = 0, TnD = 0, TagAccess = 0
| GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
| user pgtable: 4k pages, 48-bit VAs, pgdp=0000000046d96000
| [0000000000000140] pgd=0000000000000000, p4d=0000000000000000
| Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
| Modules linked in: caam_jr caamhash_desc spidev caamalg_desc crypto_engine authenc libdes mwifiex_sdio
+mwifiex crct10dif_ce cdc_acm onboard_usb_hub fsl_imx8_ddr_perf imx8m_ddrc rtc_ds1307 lm75 rtc_snvs
+imx_sdma caam imx8mm_thermal spi_imx error imx_cpufreq_dt fuse ip_tables x_tables ipv6
| CPU: 0 PID: 8 Comm: kworker/0:1 Not tainted 6.9.0-00007-g937242013fce-dirty #18
| Hardware name: somemachine (DT)
| Workqueue: events sdio_irq_work
| pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
| pc : mwifiex_get_cfp+0xd8/0x15c [mwifiex]
| lr : mwifiex_get_cfp+0x34/0x15c [mwifiex]
| sp : ffff8000818b3a70
| x29: ffff8000818b3a70 x28: ffff000006bfd8a5 x27: 0000000000000004
| x26: 000000000000002c x25: 0000000000001511 x24: 0000000002e86bc9
| x23: ffff000006bfd996 x22: 0000000000000004 x21: ffff000007bec000
| x20: 000000000000002c x19: 0000000000000000 x18: 0000000000000000
| x17: 000000040044ffff x16: 00500072b5503510 x15: ccc283740681e517
| x14: 0201000101006d15 x13: 0000000002e8ff43 x12: 002c01000000ffb1
| x11: 0100000000000000 x10: 02e8ff43002c0100 x9 : 0000ffb100100157
| x8 : ffff000003d20000 x7 : 00000000000002f1 x6 : 00000000ffffe124
| x5 : 0000000000000001 x4 : 0000000000000003 x3 : 0000000000000000
| x2 : 0000000000000000 x1 : 0001000000011001 x0 : 0000000000000000
| Call trace:
| mwifiex_get_cfp+0xd8/0x15c [mwifiex]
| mwifiex_parse_single_response_buf+0x1d0/0x504 [mwifiex]
| mwifiex_handle_event_ext_scan_report+0x19c/0x2f8 [mwifiex]
| mwifiex_process_sta_event+0x298/0xf0c [mwifiex]
| mwifiex_process_event+0x110/0x238 [mwifiex]
| mwifiex_main_process+0x428/0xa44 [mwifiex]
| mwifiex_sdio_interrupt+0x64/0x12c [mwifiex_sdio]
| process_sdio_pending_irqs+0x64/0x1b8
| sdio_irq_work+0x4c/0x7c
| process_one_work+0x148/0x2a0
| worker_thread+0x2fc/0x40c
| kthread+0x110/0x114
| ret_from_fork+0x10/0x20
| Code: a94153f3 a8c37bfd d50323bf d65f03c0 (f940a000)
| ---[ end trace 0000000000000000 ]---
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20240703072409.556618-1-s.hauer@pengutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wireless/marvell/mwifiex/main.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h
index 7e526014b6385..89774e0316bdc 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.h
+++ b/drivers/net/wireless/marvell/mwifiex/main.h
@@ -1306,6 +1306,9 @@ mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
for (i = 0; i < adapter->priv_num; i++) {
if (adapter->priv[i]) {
+ if (adapter->priv[i]->bss_mode == NL80211_IFTYPE_UNSPECIFIED)
+ continue;
+
if ((adapter->priv[i]->bss_num == bss_num) &&
(adapter->priv[i]->bss_type == bss_type))
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread