* [PATCH] kern/sys: Compat sysinfo syscall fix undefined behavior
@ 2014-09-04 18:46 Scotty Bauer
2014-09-04 20:14 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Scotty Bauer @ 2014-09-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, clemens
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: compat_sysinfo.patch --]
[-- Type: text/x-diff, Size: 709 bytes --]
Fix undefined behavior and compiler warning by replacing right
shift 32 with upper_32_bits macro
Signed-off-by: Scotty Bauer <sbauer@eng.utah.edu>
---
kernel/sys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sys.c b/kernel/sys.c
index ce81291..c78530b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2135,7 +2135,7 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
/* Check to see if any memory value is too large for 32-bit and scale
* down if needed
*/
- if ((s.totalram >> 32) || (s.totalswap >> 32)) {
+ if (upper_32_bits(s.totalram) || upper_32_bits(s.totalswap)) {
int bitcount = 0;
while (s.mem_unit < PAGE_SIZE) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] kern/sys: Compat sysinfo syscall fix undefined behavior
2014-09-04 18:46 [PATCH] kern/sys: Compat sysinfo syscall fix undefined behavior Scotty Bauer
@ 2014-09-04 20:14 ` Andrew Morton
2014-09-04 20:35 ` Scotty Bauer
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2014-09-04 20:14 UTC (permalink / raw)
To: Scotty Bauer; +Cc: linux-kernel, clemens
On Thu, 04 Sep 2014 12:46:53 -0600 Scotty Bauer <sbauer@eng.utah.edu> wrote:
> Fix undefined behavior and compiler warning by replacing right
> shift 32 with upper_32_bits macro
>
> Signed-off-by: Scotty Bauer <sbauer@eng.utah.edu>
> ---
> kernel/sys.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sys.c b/kernel/sys.c
> index ce81291..c78530b 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -2135,7 +2135,7 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
> /* Check to see if any memory value is too large for 32-bit and scale
> * down if needed
> */
> - if ((s.totalram >> 32) || (s.totalswap >> 32)) {
> + if (upper_32_bits(s.totalram) || upper_32_bits(s.totalswap)) {
> int bitcount = 0;
>
> while (s.mem_unit < PAGE_SIZE) {
Fair enough.
If I'm reading it correctly, this is all dead code because si_meminfo()
unconditionally sets sysinfo.mem_unit to PAGE_SIZE.
It could all do with a bit of a cleanup, I suspect.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] kern/sys: Compat sysinfo syscall fix undefined behavior
2014-09-04 20:14 ` Andrew Morton
@ 2014-09-04 20:35 ` Scotty Bauer
0 siblings, 0 replies; 3+ messages in thread
From: Scotty Bauer @ 2014-09-04 20:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, clemens
On 09/04/2014 02:14 PM, Andrew Morton wrote:
> If I'm reading it correctly, this is all dead code because si_meminfo() unconditionally sets sysinfo.mem_unit to PAGE_SIZE. It could all do with a bit of a cleanup, I suspect.
I'll do a little more research on this and do further clean up, if required.
-Scotty
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-04 20:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-04 18:46 [PATCH] kern/sys: Compat sysinfo syscall fix undefined behavior Scotty Bauer
2014-09-04 20:14 ` Andrew Morton
2014-09-04 20:35 ` Scotty Bauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox