* [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms @ 2019-10-01 15:14 Helge Deller 2019-10-03 8:14 ` Simon Horman 0 siblings, 1 reply; 8+ messages in thread From: Helge Deller @ 2019-10-01 15:14 UTC (permalink / raw) To: Simon Horman, kexec; +Cc: Sven Schnelle When compiling kexec-tools on a 32-bit platform, assigning an (unsigned long long) value to an (unsigned long) variable creates this warning: elf_info.c: In function 'read_phys_offset_elf_kcore': elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' 805 | *phys_off = UINT64_MAX; | ^~~~~~~~~~ Fix it by casting UINT64_MAX to (unsigned long) before storing it to *phys_off. Signed-off-by: Helge Deller <deller@gmx.de> diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c index 2bce5cb..4d16983 100644 --- a/util_lib/elf_info.c +++ b/util_lib/elf_info.c @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) { int ret; - *phys_off = UINT64_MAX; + *phys_off = (unsigned long) UINT64_MAX; ret = read_elf(fd); if (!ret) { _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-01 15:14 [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms Helge Deller @ 2019-10-03 8:14 ` Simon Horman 2019-10-03 8:52 ` Helge Deller 0 siblings, 1 reply; 8+ messages in thread From: Simon Horman @ 2019-10-03 8:14 UTC (permalink / raw) To: Helge Deller; +Cc: Sven Schnelle, kexec On Tue, Oct 01, 2019 at 05:14:16PM +0200, Helge Deller wrote: > When compiling kexec-tools on a 32-bit platform, assigning an > (unsigned long long) value to an (unsigned long) variable creates > this warning: > > elf_info.c: In function 'read_phys_offset_elf_kcore': > elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' > 805 | *phys_off = UINT64_MAX; > | ^~~~~~~~~~ > > Fix it by casting UINT64_MAX to (unsigned long) before storing it to *phys_off. > > Signed-off-by: Helge Deller <deller@gmx.de> > > diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c > index 2bce5cb..4d16983 100644 > --- a/util_lib/elf_info.c > +++ b/util_lib/elf_info.c > @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) > { > int ret; > > - *phys_off = UINT64_MAX; > + *phys_off = (unsigned long) UINT64_MAX; This seems to mask the problem that UINT64_MAX is not the right initialiser for unsigned long values on 32-bit platforms. Could we consider using UINT64_MAX from limits.h instead? > > ret = read_elf(fd); > if (!ret) { > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-03 8:14 ` Simon Horman @ 2019-10-03 8:52 ` Helge Deller 2019-10-04 9:37 ` Simon Horman 0 siblings, 1 reply; 8+ messages in thread From: Helge Deller @ 2019-10-03 8:52 UTC (permalink / raw) To: Simon Horman; +Cc: Sven Schnelle, kexec On 03.10.19 10:14, Simon Horman wrote: > On Tue, Oct 01, 2019 at 05:14:16PM +0200, Helge Deller wrote: >> When compiling kexec-tools on a 32-bit platform, assigning an >> (unsigned long long) value to an (unsigned long) variable creates >> this warning: >> >> elf_info.c: In function 'read_phys_offset_elf_kcore': >> elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' >> 805 | *phys_off = UINT64_MAX; >> | ^~~~~~~~~~ >> >> Fix it by casting UINT64_MAX to (unsigned long) before storing it to *phys_off. >> >> Signed-off-by: Helge Deller <deller@gmx.de> >> >> diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c >> index 2bce5cb..4d16983 100644 >> --- a/util_lib/elf_info.c >> +++ b/util_lib/elf_info.c >> @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) >> { >> int ret; >> >> - *phys_off = UINT64_MAX; >> + *phys_off = (unsigned long) UINT64_MAX; > > This seems to mask the problem that UINT64_MAX is not the right > initialiser for unsigned long values on 32-bit platforms. > Could we consider using UINT64_MAX from limits.h instead? UINT64 means it is a 64bit value, while "unsigned long" is either 32-bit, 64bit (or maybe in the future even 128bit?). Even assigning UINT32_MAX on a 32bit platform might be wrong. So I think the cast above is probably the best solution. Helge _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-03 8:52 ` Helge Deller @ 2019-10-04 9:37 ` Simon Horman 2019-10-04 9:51 ` Helge Deller 0 siblings, 1 reply; 8+ messages in thread From: Simon Horman @ 2019-10-04 9:37 UTC (permalink / raw) To: Helge Deller; +Cc: Sven Schnelle, kexec On Thu, Oct 03, 2019 at 10:52:37AM +0200, Helge Deller wrote: > On 03.10.19 10:14, Simon Horman wrote: > > On Tue, Oct 01, 2019 at 05:14:16PM +0200, Helge Deller wrote: > > > When compiling kexec-tools on a 32-bit platform, assigning an > > > (unsigned long long) value to an (unsigned long) variable creates > > > this warning: > > > > > > elf_info.c: In function 'read_phys_offset_elf_kcore': > > > elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' > > > 805 | *phys_off = UINT64_MAX; > > > | ^~~~~~~~~~ > > > > > > Fix it by casting UINT64_MAX to (unsigned long) before storing it to *phys_off. > > > > > > Signed-off-by: Helge Deller <deller@gmx.de> > > > > > > diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c > > > index 2bce5cb..4d16983 100644 > > > --- a/util_lib/elf_info.c > > > +++ b/util_lib/elf_info.c > > > @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) > > > { > > > int ret; > > > > > > - *phys_off = UINT64_MAX; > > > + *phys_off = (unsigned long) UINT64_MAX; > > > > This seems to mask the problem that UINT64_MAX is not the right > > initialiser for unsigned long values on 32-bit platforms. > > Could we consider using UINT64_MAX from limits.h instead? > > UINT64 means it is a 64bit value, while "unsigned long" is either 32-bit, > 64bit (or maybe in the future even 128bit?). > Even assigning UINT32_MAX on a 32bit platform might be wrong. > So I think the cast above is probably the best solution. Sorry, I made a typo above. What I meant is, can we consider using ULONG_MAX. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-04 9:37 ` Simon Horman @ 2019-10-04 9:51 ` Helge Deller 2019-10-04 10:14 ` Simon Horman 0 siblings, 1 reply; 8+ messages in thread From: Helge Deller @ 2019-10-04 9:51 UTC (permalink / raw) To: Simon Horman; +Cc: Sven Schnelle, kexec On 04.10.19 11:37, Simon Horman wrote: > On Thu, Oct 03, 2019 at 10:52:37AM +0200, Helge Deller wrote: >> On 03.10.19 10:14, Simon Horman wrote: >>> On Tue, Oct 01, 2019 at 05:14:16PM +0200, Helge Deller wrote: >>>> When compiling kexec-tools on a 32-bit platform, assigning an >>>> (unsigned long long) value to an (unsigned long) variable creates >>>> this warning: >>>> >>>> elf_info.c: In function 'read_phys_offset_elf_kcore': >>>> elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' >>>> 805 | *phys_off = UINT64_MAX; >>>> | ^~~~~~~~~~ >>>> >>>> Fix it by casting UINT64_MAX to (unsigned long) before storing it to *phys_off. >>>> >>>> Signed-off-by: Helge Deller <deller@gmx.de> >>>> >>>> diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c >>>> index 2bce5cb..4d16983 100644 >>>> --- a/util_lib/elf_info.c >>>> +++ b/util_lib/elf_info.c >>>> @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) >>>> { >>>> int ret; >>>> >>>> - *phys_off = UINT64_MAX; >>>> + *phys_off = (unsigned long) UINT64_MAX; >>> >>> This seems to mask the problem that UINT64_MAX is not the right >>> initialiser for unsigned long values on 32-bit platforms. >>> Could we consider using UINT64_MAX from limits.h instead? >> >> UINT64 means it is a 64bit value, while "unsigned long" is either 32-bit, >> 64bit (or maybe in the future even 128bit?). >> Even assigning UINT32_MAX on a 32bit platform might be wrong. >> So I think the cast above is probably the best solution. > > Sorry, I made a typo above. > What I meant is, can we consider using ULONG_MAX. Yes, that's probably ok. Helge _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-04 9:51 ` Helge Deller @ 2019-10-04 10:14 ` Simon Horman 2019-10-04 11:01 ` Helge Deller 0 siblings, 1 reply; 8+ messages in thread From: Simon Horman @ 2019-10-04 10:14 UTC (permalink / raw) To: Helge Deller; +Cc: Sven Schnelle, kexec On Fri, Oct 04, 2019 at 11:51:05AM +0200, Helge Deller wrote: > On 04.10.19 11:37, Simon Horman wrote: > > On Thu, Oct 03, 2019 at 10:52:37AM +0200, Helge Deller wrote: > > > On 03.10.19 10:14, Simon Horman wrote: > > > > On Tue, Oct 01, 2019 at 05:14:16PM +0200, Helge Deller wrote: > > > > > When compiling kexec-tools on a 32-bit platform, assigning an > > > > > (unsigned long long) value to an (unsigned long) variable creates > > > > > this warning: > > > > > > > > > > elf_info.c: In function 'read_phys_offset_elf_kcore': > > > > > elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' > > > > > 805 | *phys_off = UINT64_MAX; > > > > > | ^~~~~~~~~~ > > > > > > > > > > Fix it by casting UINT64_MAX to (unsigned long) before storing it to *phys_off. > > > > > > > > > > Signed-off-by: Helge Deller <deller@gmx.de> > > > > > > > > > > diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c > > > > > index 2bce5cb..4d16983 100644 > > > > > --- a/util_lib/elf_info.c > > > > > +++ b/util_lib/elf_info.c > > > > > @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) > > > > > { > > > > > int ret; > > > > > > > > > > - *phys_off = UINT64_MAX; > > > > > + *phys_off = (unsigned long) UINT64_MAX; > > > > > > > > This seems to mask the problem that UINT64_MAX is not the right > > > > initialiser for unsigned long values on 32-bit platforms. > > > > Could we consider using UINT64_MAX from limits.h instead? > > > > > > UINT64 means it is a 64bit value, while "unsigned long" is either 32-bit, > > > 64bit (or maybe in the future even 128bit?). > > > Even assigning UINT32_MAX on a 32bit platform might be wrong. > > > So I think the cast above is probably the best solution. > > > > Sorry, I made a typo above. > > What I meant is, can we consider using ULONG_MAX. > > Yes, that's probably ok. Thanks. Will you send an updated patch? _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-04 10:14 ` Simon Horman @ 2019-10-04 11:01 ` Helge Deller 2019-10-07 7:12 ` Simon Horman 0 siblings, 1 reply; 8+ messages in thread From: Helge Deller @ 2019-10-04 11:01 UTC (permalink / raw) To: Simon Horman, kexec; +Cc: Sven Schnelle When compiling kexec-tools on a 32-bit platform, assigning an (unsigned long long) value to an (unsigned long) variable creates this warning: elf_info.c: In function 'read_phys_offset_elf_kcore': elf_info.c:805:14: warning: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' 805 | *phys_off = UINT64_MAX; Fix it by using ULONG_MAX instead of UINT64_MAX. Signed-off-by: Helge Deller <deller@gmx.de> diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c index 2bce5cb..7803a94 100644 --- a/util_lib/elf_info.c +++ b/util_lib/elf_info.c @@ -802,7 +802,7 @@ int read_phys_offset_elf_kcore(int fd, unsigned long *phys_off) { int ret; - *phys_off = UINT64_MAX; + *phys_off = ULONG_MAX; ret = read_elf(fd); if (!ret) { _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms 2019-10-04 11:01 ` Helge Deller @ 2019-10-07 7:12 ` Simon Horman 0 siblings, 0 replies; 8+ messages in thread From: Simon Horman @ 2019-10-07 7:12 UTC (permalink / raw) To: Helge Deller; +Cc: Sven Schnelle, kexec On Fri, Oct 04, 2019 at 01:01:09PM +0200, Helge Deller wrote: > When compiling kexec-tools on a 32-bit platform, assigning an > (unsigned long long) value to an (unsigned long) variable creates > this warning: > > elf_info.c: In function 'read_phys_offset_elf_kcore': > elf_info.c:805:14: warning: conversion from 'long long unsigned int' to > 'long unsigned int' changes value from '18446744073709551615' to '4294967295' > 805 | *phys_off = UINT64_MAX; > > Fix it by using ULONG_MAX instead of UINT64_MAX. > > Signed-off-by: Helge Deller <deller@gmx.de> Thanks, applied. _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-07 7:13 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-01 15:14 [PATCH] kexec-tools: Fix conversion overflow when compiling on 32-bit platforms Helge Deller 2019-10-03 8:14 ` Simon Horman 2019-10-03 8:52 ` Helge Deller 2019-10-04 9:37 ` Simon Horman 2019-10-04 9:51 ` Helge Deller 2019-10-04 10:14 ` Simon Horman 2019-10-04 11:01 ` Helge Deller 2019-10-07 7:12 ` Simon Horman
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.