Bug 15448 - Integer overflow in sched.h cpu set CPU_* macros
Summary: Integer overflow in sched.h cpu set CPU_* macros
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.18
Assignee: Andreas Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-09 02:48 IST by Rich Felker
Modified: 2013-05-10 18:31 IST (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rich Felker 2013-05-09 02:48:34 IST
In file sysdeps/unix/sysv/linux/bits/sched.h, the cpu set macros attempt to check for overflow of the cpu index, but fail to do so properly due to an integer overflow error. The condition:

 147       __cpu < 8 * (setsize)

overflows if setsize is greater than SIZE_MAX/8. The correct test would be:

           __cpu/8 < (setsize)

which is valid since the low 3 bits of __cpu are irrelevant to whether the index overflows.
Comment 1 Andreas Jaeger 2013-05-10 18:31:04 IST
This is fixed now for glibc 2.18, thanks for your report.

commit 8a67a4b3435d8471523d3ae4f7cb46cf9b8d72d9
Author: Andreas Jaeger <aj@suse.de>
Date:   Fri May 10 20:28:40 2013 +0200

    Fix integer overflow in sysdeps/unix/sysv/linux/bits/sched.h
    
        [BZ #15448]
        * sysdeps/unix/sysv/linux/bits/sched.h (__CPU_SET_S)
        (__CPU_CLR_S, __CPU_ISSET_S): Avoid integer overflow.