platform/x86/intel/ifs: Metadata validation for start_chunk
authorJithu Joseph <jithu.joseph@intel.com>
Thu, 5 Oct 2023 19:51:34 +0000 (12:51 -0700)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 6 Oct 2023 10:05:21 +0000 (13:05 +0300)
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 <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Tested-by: Pengfei Xu <pengfei.xu@intel.com>
Link: https://lore.kernel.org/r/20231005195137.3117166-7-jithu.joseph@intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/ifs/load.c

index 582f1801aaaa6f4c8f105cbf732a29a1492b9e79..959b1878cae62f8f5f05874cfaa7a2cf5794ec1c 100644 (file)
@@ -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;
 }