* [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT @ 2020-08-13 7:55 Frank Mehnert 2020-08-13 9:51 ` David Gibson 0 siblings, 1 reply; 5+ messages in thread From: Frank Mehnert @ 2020-08-13 7:55 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: David Gibson fdt_check_node_offset_() checks for a valid offset but also changes the offset by calling fdt_next_tag(). Hence, do not skip this function if ASSUME_VALID_INPUT is set. Actually this works similar to fdt_check_prop_offset_(). --- libfdt/fdt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libfdt/fdt.c b/libfdt/fdt.c index c28fcc1..39ed8ed 100644 --- a/libfdt/fdt.c +++ b/libfdt/fdt.c @@ -206,8 +206,6 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) int fdt_check_node_offset_(const void *fdt, int offset) { - if (can_assume(VALID_INPUT)) - return offset; if ((offset < 0) || (offset % FDT_TAGSIZE) || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) return -FDT_ERR_BADOFFSET; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT 2020-08-13 7:55 [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT Frank Mehnert @ 2020-08-13 9:51 ` David Gibson [not found] ` <20200813095108.GA181791-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: David Gibson @ 2020-08-13 9:51 UTC (permalink / raw) To: Frank Mehnert; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1240 bytes --] On Thu, Aug 13, 2020 at 09:55:09AM +0200, Frank Mehnert wrote: > fdt_check_node_offset_() checks for a valid offset but also changes the > offset by calling fdt_next_tag(). Hence, do not skip this function if > ASSUME_VALID_INPUT is set. > > Actually this works similar to fdt_check_prop_offset_(). Correct, but we can do better. We can still elide the checks for offset < 0 and offset % FDT_TAGSIZE when VALID_INPUT is set. > --- > libfdt/fdt.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/libfdt/fdt.c b/libfdt/fdt.c > index c28fcc1..39ed8ed 100644 > --- a/libfdt/fdt.c > +++ b/libfdt/fdt.c > @@ -206,8 +206,6 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) > > int fdt_check_node_offset_(const void *fdt, int offset) > { > - if (can_assume(VALID_INPUT)) > - return offset; > if ((offset < 0) || (offset % FDT_TAGSIZE) > || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) > return -FDT_ERR_BADOFFSET; -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20200813095108.GA181791-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>]
* Re: [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT [not found] ` <20200813095108.GA181791-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> @ 2020-08-13 15:26 ` Frank Mehnert 2020-08-14 3:17 ` David Gibson 0 siblings, 1 reply; 5+ messages in thread From: Frank Mehnert @ 2020-08-13 15:26 UTC (permalink / raw) To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: David Gibson fdt_check_node_offset_() checks for a valid offset but also changes the offset by calling fdt_next_tag(). Hence, do not skip this function if ASSUME_VALID_INPUT is set but only omit the initial offset check in that case. As this function works very similar to fdt_check_prop_offset_(), do the offset check there as well depending on ASSUME_VALID_INPUT. --- libfdt/fdt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libfdt/fdt.c b/libfdt/fdt.c index c28fcc1..37b7b93 100644 --- a/libfdt/fdt.c +++ b/libfdt/fdt.c @@ -206,10 +206,11 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) int fdt_check_node_offset_(const void *fdt, int offset) { - if (can_assume(VALID_INPUT)) - return offset; - if ((offset < 0) || (offset % FDT_TAGSIZE) - || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) + if (!can_assume(VALID_INPUT) + && ((offset < 0) || (offset % FDT_TAGSIZE))) + return -FDT_ERR_BADOFFSET; + + if (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE) return -FDT_ERR_BADOFFSET; return offset; @@ -217,8 +218,11 @@ int fdt_check_node_offset_(const void *fdt, int offset) int fdt_check_prop_offset_(const void *fdt, int offset) { - if ((offset < 0) || (offset % FDT_TAGSIZE) - || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) + if (!can_assume(VALID_INPUT) + && ((offset < 0) || (offset % FDT_TAGSIZE))) + return -FDT_ERR_BADOFFSET; + + if (fdt_next_tag(fdt, offset, &offset) != FDT_PROP) return -FDT_ERR_BADOFFSET; return offset; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT 2020-08-13 15:26 ` Frank Mehnert @ 2020-08-14 3:17 ` David Gibson [not found] ` <20200814031748.GA12805-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: David Gibson @ 2020-08-14 3:17 UTC (permalink / raw) To: Frank Mehnert; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 2240 bytes --] On Thu, Aug 13, 2020 at 05:26:26PM +0200, Frank Mehnert wrote: > fdt_check_node_offset_() checks for a valid offset but also changes the > offset by calling fdt_next_tag(). Hence, do not skip this function if > ASSUME_VALID_INPUT is set but only omit the initial offset check in that > case. > > As this function works very similar to fdt_check_prop_offset_(), do the > offset check there as well depending on ASSUME_VALID_INPUT. So, it looks like your mailer has mangled the patch (replacing tabs with spaces). Since it's simple, I fixed it up this time, though. Applied. > --- > libfdt/fdt.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/libfdt/fdt.c b/libfdt/fdt.c > index c28fcc1..37b7b93 100644 > --- a/libfdt/fdt.c > +++ b/libfdt/fdt.c > @@ -206,10 +206,11 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) > > int fdt_check_node_offset_(const void *fdt, int offset) > { > - if (can_assume(VALID_INPUT)) > - return offset; > - if ((offset < 0) || (offset % FDT_TAGSIZE) > - || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)) > + if (!can_assume(VALID_INPUT) > + && ((offset < 0) || (offset % FDT_TAGSIZE))) > + return -FDT_ERR_BADOFFSET; > + > + if (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE) > return -FDT_ERR_BADOFFSET; > > return offset; > @@ -217,8 +218,11 @@ int fdt_check_node_offset_(const void *fdt, int offset) > > int fdt_check_prop_offset_(const void *fdt, int offset) > { > - if ((offset < 0) || (offset % FDT_TAGSIZE) > - || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)) > + if (!can_assume(VALID_INPUT) > + && ((offset < 0) || (offset % FDT_TAGSIZE))) > + return -FDT_ERR_BADOFFSET; > + > + if (fdt_next_tag(fdt, offset, &offset) != FDT_PROP) > return -FDT_ERR_BADOFFSET; > > return offset; -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20200814031748.GA12805-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>]
* Re: [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT [not found] ` <20200814031748.GA12805-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org> @ 2020-08-14 6:47 ` Frank Mehnert 0 siblings, 0 replies; 5+ messages in thread From: Frank Mehnert @ 2020-08-14 6:47 UTC (permalink / raw) To: David Gibson; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA On Freitag, 14. August 2020 05:17:48 CEST David Gibson wrote: > On Thu, Aug 13, 2020 at 05:26:26PM +0200, Frank Mehnert wrote: > > fdt_check_node_offset_() checks for a valid offset but also changes the > > offset by calling fdt_next_tag(). Hence, do not skip this function if > > ASSUME_VALID_INPUT is set but only omit the initial offset check in that > > case. > > > > As this function works very similar to fdt_check_prop_offset_(), do the > > offset check there as well depending on ASSUME_VALID_INPUT. > > So, it looks like your mailer has mangled the patch (replacing tabs > with spaces). Since it's simple, I fixed it up this time, though. > > Applied. Thanks! Frank -- Dr.-Ing. Frank Mehnert, frank.mehnert-2ptZNfhJYoRaodhZ+FW2PA@public.gmane.org, +49-351-41 883 224 Kernkonzept GmbH. Sitz: Dresden. Amtsgericht Dresden, HRB 31129. Geschäftsführer: Dr.-Ing. Michael Hohmuth ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-14 6:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-13 7:55 [PATCH] libfdt: fix fdt_check_node_offset_ w/ VALID_INPUT Frank Mehnert
2020-08-13 9:51 ` David Gibson
[not found] ` <20200813095108.GA181791-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-08-13 15:26 ` Frank Mehnert
2020-08-14 3:17 ` David Gibson
[not found] ` <20200814031748.GA12805-l+x2Y8Cxqc4e6aEkudXLsA@public.gmane.org>
2020-08-14 6:47 ` Frank Mehnert
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.