Skip to content

Commit 8e81b9c

Browse files
superm1ij-intel
authored andcommitted
drivers/platform/x86/amd: pmf: Check for invalid Smart PC Policies
commit 376a8c2 ("platform/x86/amd/pmf: Update PMF Driver for Compatibility with new PMF-TA") added support for platforms that support an updated TA, however it also exposed a number of platforms that although they have support for the updated TA don't actually populate a policy binary. Add an explicit check that the policy binary isn't empty before initializing the TA. Reported-by: Christian Heusel <[email protected]> Closes: https://lore.kernel.org/platform-driver-x86/[email protected]/ Fixes: 376a8c2 ("platform/x86/amd/pmf: Update PMF Driver for Compatibility with new PMF-TA") Signed-off-by: Mario Limonciello <[email protected]> Tested-by: Christian Heusel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 690d722 commit 8e81b9c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/platform/x86/amd/pmf/tee-if.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
334334
return 0;
335335
}
336336

337+
static inline bool amd_pmf_pb_valid(struct amd_pmf_dev *dev)
338+
{
339+
return memchr_inv(dev->policy_buf, 0xff, dev->policy_sz);
340+
}
341+
337342
#ifdef CONFIG_AMD_PMF_DEBUG
338343
static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev)
339344
{
@@ -361,6 +366,11 @@ static ssize_t amd_pmf_get_pb_data(struct file *filp, const char __user *buf,
361366
dev->policy_buf = new_policy_buf;
362367
dev->policy_sz = length;
363368

369+
if (!amd_pmf_pb_valid(dev)) {
370+
ret = -EINVAL;
371+
goto cleanup;
372+
}
373+
364374
amd_pmf_hex_dump_pb(dev);
365375
ret = amd_pmf_start_policy_engine(dev);
366376
if (ret < 0)
@@ -533,6 +543,12 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
533543

534544
memcpy_fromio(dev->policy_buf, dev->policy_base, dev->policy_sz);
535545

546+
if (!amd_pmf_pb_valid(dev)) {
547+
dev_info(dev->dev, "No Smart PC policy present\n");
548+
ret = -EINVAL;
549+
goto err_free_policy;
550+
}
551+
536552
amd_pmf_hex_dump_pb(dev);
537553

538554
dev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL);

0 commit comments

Comments
 (0)