2023-09-30 04:00:55

by Joseph, Jithu

[permalink] [raw]
Subject: [PATCH v3 6/9] platform/x86/intel/ifs: Metadata validation for start_chunk

Add an additional check to validate IFS image metadata field prior to
loading the test image.

If start_chunk is not a multiple of chunks_per_stride error out.

Signed-off-by: Jithu Joseph <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Tested-by: Pengfei Xu <[email protected]>
---
drivers/platform/x86/intel/ifs/load.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
index da54fd060878..6f8abb4729e9 100644
--- a/drivers/platform/x86/intel/ifs/load.c
+++ b/drivers/platform/x86/intel/ifs/load.c
@@ -291,6 +291,13 @@ static int validate_ifs_metadata(struct device *dev)
return ret;
}

+ if (ifs_meta->chunks_per_stride &&
+ (ifs_meta->starting_chunk % ifs_meta->chunks_per_stride != 0)) {
+ dev_warn(dev, "Starting chunk num %d not a multiple of chunks_per_stride %d\n",
+ ifs_meta->starting_chunk, ifs_meta->chunks_per_stride);
+ return ret;
+ }
+
return 0;
}

--
2.25.1


2023-10-02 20:43:46

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v3 6/9] platform/x86/intel/ifs: Metadata validation for start_chunk

On Fri, 29 Sep 2023, Jithu Joseph wrote:

> Add an additional check to validate IFS image metadata field prior to
> loading the test image.
>
> If start_chunk is not a multiple of chunks_per_stride error out.
>
> Signed-off-by: Jithu Joseph <[email protected]>
> Reviewed-by: Tony Luck <[email protected]>
> Tested-by: Pengfei Xu <[email protected]>
> ---
> drivers/platform/x86/intel/ifs/load.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
> index da54fd060878..6f8abb4729e9 100644
> --- a/drivers/platform/x86/intel/ifs/load.c
> +++ b/drivers/platform/x86/intel/ifs/load.c
> @@ -291,6 +291,13 @@ static int validate_ifs_metadata(struct device *dev)
> return ret;
> }
>
> + if (ifs_meta->chunks_per_stride &&
> + (ifs_meta->starting_chunk % ifs_meta->chunks_per_stride != 0)) {
> + dev_warn(dev, "Starting chunk num %d not a multiple of chunks_per_stride %d\n",
> + ifs_meta->starting_chunk, ifs_meta->chunks_per_stride);

Please use %u as both are u32s.

--
i.

> + return ret;
> + }
> +
> return 0;
> }
>
>

2023-10-02 22:58:45

by Joseph, Jithu

[permalink] [raw]
Subject: Re: [PATCH v3 6/9] platform/x86/intel/ifs: Metadata validation for start_chunk



On 10/2/2023 4:47 AM, Ilpo Järvinen wrote:
> On Fri, 29 Sep 2023, Jithu Joseph wrote:
>
>> Add an additional check to validate IFS image metadata field prior to
>> loading the test image.
>>
>> If start_chunk is not a multiple of chunks_per_stride error out.
>>
>> Signed-off-by: Jithu Joseph <[email protected]>
>> Reviewed-by: Tony Luck <[email protected]>
>> Tested-by: Pengfei Xu <[email protected]>
>> ---
>> drivers/platform/x86/intel/ifs/load.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
>> index da54fd060878..6f8abb4729e9 100644
>> --- a/drivers/platform/x86/intel/ifs/load.c
>> +++ b/drivers/platform/x86/intel/ifs/load.c
>> @@ -291,6 +291,13 @@ static int validate_ifs_metadata(struct device *dev)
>> return ret;
>> }
>>
>> + if (ifs_meta->chunks_per_stride &&
>> + (ifs_meta->starting_chunk % ifs_meta->chunks_per_stride != 0)) {
>> + dev_warn(dev, "Starting chunk num %d not a multiple of chunks_per_stride %d\n",
>> + ifs_meta->starting_chunk, ifs_meta->chunks_per_stride);
>
> Please use %u as both are u32s.
>

Thanks for the review... I will make this change


Jithu

2023-10-04 19:23:48

by Joseph, Jithu

[permalink] [raw]
Subject: [PATCH v3 6/9] platform/x86/intel/ifs: Metadata validation for start_chunk

Add an additional check to validate IFS image metadata field prior to
loading the test image.

If start_chunk is not a multiple of chunks_per_stride error out.

Signed-off-by: Jithu Joseph <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Tested-by: Pengfei Xu <[email protected]>
---
- changed the dev_warn printk format specifiers (Ilpo Järvinen)

drivers/platform/x86/intel/ifs/load.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
index 582f1801aaaa..959b1878cae6 100644
--- a/drivers/platform/x86/intel/ifs/load.c
+++ b/drivers/platform/x86/intel/ifs/load.c
@@ -291,6 +291,13 @@ static int validate_ifs_metadata(struct device *dev)
return ret;
}

+ if (ifs_meta->chunks_per_stride &&
+ (ifs_meta->starting_chunk % ifs_meta->chunks_per_stride != 0)) {
+ dev_warn(dev, "Starting chunk num %u not a multiple of chunks_per_stride %u\n",
+ ifs_meta->starting_chunk, ifs_meta->chunks_per_stride);
+ return ret;
+ }
+
return 0;
}

--
2.25.1