devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/dtc: Update to upstream version v1.6.1-66-gabbd523bae6e
@ 2023-02-03 17:24 Rob Herring
  2023-02-03 17:34 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2023-02-03 17:24 UTC (permalink / raw)
  To: Frank Rowand; +Cc: Kees Cook, devicetree, linux-kernel

This adds the following commits from upstream:

abbd523bae6e pylibfdt: Work-around SWIG limitations with flexible arrays
a41509bea3e7 libfdt: Replace deprecated 0-length arrays with proper flexible arrays
2cd89f862cdb dtc: Warning rather than error on possible truncation of cell values

Signed-off-by: Rob Herring <robh@kernel.org>
---
 scripts/dtc/dtc-parser.y  | 11 ++++++++---
 scripts/dtc/libfdt/fdt.h  |  4 ++--
 scripts/dtc/version_gen.h |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
index 46457d4bc0aa..bff1337ec266 100644
--- a/scripts/dtc/dtc-parser.y
+++ b/scripts/dtc/dtc-parser.y
@@ -404,9 +404,14 @@ arrayprefix:
 				 * within the mask to one (i.e. | in the
 				 * mask), all bits are one.
 				 */
-				if (($2 > mask) && (($2 | mask) != -1ULL))
-					ERROR(&@2, "Value out of range for"
-					      " %d-bit array element", $1.bits);
+				if (($2 > mask) && (($2 | mask) != -1ULL)) {
+					char *loc = srcpos_string(&@2);
+					fprintf(stderr,
+						"WARNING: %s: Value 0x%016" PRIx64
+						" truncated to 0x%0*" PRIx64 "\n",
+						loc, $2, $1.bits / 4, ($2 & mask));
+					free(loc);
+				}
 			}
 
 			$$.data = data_append_integer($1.data, $2, $1.bits);
diff --git a/scripts/dtc/libfdt/fdt.h b/scripts/dtc/libfdt/fdt.h
index f2e68807f277..0c91aa7f67b5 100644
--- a/scripts/dtc/libfdt/fdt.h
+++ b/scripts/dtc/libfdt/fdt.h
@@ -35,14 +35,14 @@ struct fdt_reserve_entry {
 
 struct fdt_node_header {
 	fdt32_t tag;
-	char name[0];
+	char name[];
 };
 
 struct fdt_property {
 	fdt32_t tag;
 	fdt32_t len;
 	fdt32_t nameoff;
-	char data[0];
+	char data[];
 };
 
 #endif /* !__ASSEMBLY */
diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
index 0f303087b043..99614ec1a289 100644
--- a/scripts/dtc/version_gen.h
+++ b/scripts/dtc/version_gen.h
@@ -1 +1 @@
-#define DTC_VERSION "DTC 1.6.1-g55778a03"
+#define DTC_VERSION "DTC 1.6.1-gabbd523b"
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/dtc: Update to upstream version v1.6.1-66-gabbd523bae6e
  2023-02-03 17:24 [PATCH] scripts/dtc: Update to upstream version v1.6.1-66-gabbd523bae6e Rob Herring
@ 2023-02-03 17:34 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2023-02-03 17:34 UTC (permalink / raw)
  To: Rob Herring; +Cc: Frank Rowand, devicetree, linux-kernel

On Fri, Feb 03, 2023 at 11:24:29AM -0600, Rob Herring wrote:
> This adds the following commits from upstream:
> 
> abbd523bae6e pylibfdt: Work-around SWIG limitations with flexible arrays
> a41509bea3e7 libfdt: Replace deprecated 0-length arrays with proper flexible arrays
> 2cd89f862cdb dtc: Warning rather than error on possible truncation of cell values
> 
> Signed-off-by: Rob Herring <robh@kernel.org>

Thanks for your help with this!

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  scripts/dtc/dtc-parser.y  | 11 ++++++++---
>  scripts/dtc/libfdt/fdt.h  |  4 ++--
>  scripts/dtc/version_gen.h |  2 +-
>  3 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y
> index 46457d4bc0aa..bff1337ec266 100644
> --- a/scripts/dtc/dtc-parser.y
> +++ b/scripts/dtc/dtc-parser.y
> @@ -404,9 +404,14 @@ arrayprefix:
>  				 * within the mask to one (i.e. | in the
>  				 * mask), all bits are one.
>  				 */
> -				if (($2 > mask) && (($2 | mask) != -1ULL))
> -					ERROR(&@2, "Value out of range for"
> -					      " %d-bit array element", $1.bits);
> +				if (($2 > mask) && (($2 | mask) != -1ULL)) {
> +					char *loc = srcpos_string(&@2);
> +					fprintf(stderr,
> +						"WARNING: %s: Value 0x%016" PRIx64
> +						" truncated to 0x%0*" PRIx64 "\n",
> +						loc, $2, $1.bits / 4, ($2 & mask));
> +					free(loc);
> +				}
>  			}
>  
>  			$$.data = data_append_integer($1.data, $2, $1.bits);
> diff --git a/scripts/dtc/libfdt/fdt.h b/scripts/dtc/libfdt/fdt.h
> index f2e68807f277..0c91aa7f67b5 100644
> --- a/scripts/dtc/libfdt/fdt.h
> +++ b/scripts/dtc/libfdt/fdt.h
> @@ -35,14 +35,14 @@ struct fdt_reserve_entry {
>  
>  struct fdt_node_header {
>  	fdt32_t tag;
> -	char name[0];
> +	char name[];
>  };
>  
>  struct fdt_property {
>  	fdt32_t tag;
>  	fdt32_t len;
>  	fdt32_t nameoff;
> -	char data[0];
> +	char data[];
>  };
>  
>  #endif /* !__ASSEMBLY */
> diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h
> index 0f303087b043..99614ec1a289 100644
> --- a/scripts/dtc/version_gen.h
> +++ b/scripts/dtc/version_gen.h
> @@ -1 +1 @@
> -#define DTC_VERSION "DTC 1.6.1-g55778a03"
> +#define DTC_VERSION "DTC 1.6.1-gabbd523b"
> -- 
> 2.39.0
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-03 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 17:24 [PATCH] scripts/dtc: Update to upstream version v1.6.1-66-gabbd523bae6e Rob Herring
2023-02-03 17:34 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).