taskset fails on big endian system (mips)

Karl Vogel karl.vogel at gmail.com
Mon Jun 10 07:21:27 UTC 2013


In busybox/miscutils/taskset.c the function from_cpuset has following
logic for big endian systems:

---
#if BB_BIG_ENDIAN
    /* For big endian, it means LAST bits */
    if (CPU_SETSIZE < sizeof(long))
        p += CPU_SETSIZE - sizeof(int);
    else if (CPU_SETSIZE < sizeof(long long))
        p += CPU_SETSIZE - sizeof(long);
    else
        p += CPU_SETSIZE - sizeof(long long);
#endif
---

First issue is that CPU_SETSIZE is in bits, while this calculation
uses it as bytes, so we overwrite part of the stack from the calling
function.

Another issue on the platform I'm running it on, is that CPU_SETSIZE
is 1024 bits (128 bytes). This logic here takes the last "long long"
out of the structure, but the result is actually stored in the first
few bytes of the structure. I'm not sure if all big endian systems
follow this logic?!

The "fancy feature" implementation on the other hand, works fine.



More information about the busybox mailing list