include/linux/sched.h implements TASK_SIZE_OF as TASK_SIZE if it
is not set by the architecture headers. TASK_SIZE uses the
current task to determine the size of the virtual address space.
On a 64-bit kernel this will cause reading /proc/pid/pagemap of a
64-bit process from a 32-bit process to return EOF when it reads
past 0xffffffff.
Implement TASK_SIZE_OF exactly the same as TASK_SIZE with
test_tsk_thread_flag instead of test_thread_flag.
Cc: [email protected]
Signed-off-by: Colin Cross <[email protected]>
---
arch/arm64/include/asm/memory.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 993bce527b85..902eb708804a 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -56,6 +56,8 @@
#define TASK_SIZE_32 UL(0x100000000)
#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
TASK_SIZE_32 : TASK_SIZE_64)
+#define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
+ TASK_SIZE_32 : TASK_SIZE_64)
#else
#define TASK_SIZE TASK_SIZE_64
#endif /* CONFIG_COMPAT */
--
2.0.0.526.g5318336
Hi Colin,
On Wed, Jun 18, 2014 at 09:10:09PM +0100, Colin Cross wrote:
> include/linux/sched.h implements TASK_SIZE_OF as TASK_SIZE if it
> is not set by the architecture headers. TASK_SIZE uses the
> current task to determine the size of the virtual address space.
> On a 64-bit kernel this will cause reading /proc/pid/pagemap of a
> 64-bit process from a 32-bit process to return EOF when it reads
> past 0xffffffff.
>
> Implement TASK_SIZE_OF exactly the same as TASK_SIZE with
> test_tsk_thread_flag instead of test_thread_flag.
Looks sane to me.
Acked-by: Will Deacon <[email protected]>
I take it you're being bitten by this in real software, hence the CC stable
tag?
Will
On Fri, Jun 20, 2014 at 1:25 AM, Will Deacon <[email protected]> wrote:
> Hi Colin,
>
> On Wed, Jun 18, 2014 at 09:10:09PM +0100, Colin Cross wrote:
>> include/linux/sched.h implements TASK_SIZE_OF as TASK_SIZE if it
>> is not set by the architecture headers. TASK_SIZE uses the
>> current task to determine the size of the virtual address space.
>> On a 64-bit kernel this will cause reading /proc/pid/pagemap of a
>> 64-bit process from a 32-bit process to return EOF when it reads
>> past 0xffffffff.
>>
>> Implement TASK_SIZE_OF exactly the same as TASK_SIZE with
>> test_tsk_thread_flag instead of test_thread_flag.
>
> Looks sane to me.
>
> Acked-by: Will Deacon <[email protected]>
>
> I take it you're being bitten by this in real software, hence the CC stable
> tag?
>
> Will
Yes, it causes memory statistics produced by Android's procrank tool
to be completely wrong. It applies cleanly to at least 3.10.44,
3.12.22, and 3.14.8.
On Wed, Jun 18, 2014 at 09:10:09PM +0100, Colin Cross wrote:
> include/linux/sched.h implements TASK_SIZE_OF as TASK_SIZE if it
> is not set by the architecture headers. TASK_SIZE uses the
> current task to determine the size of the virtual address space.
> On a 64-bit kernel this will cause reading /proc/pid/pagemap of a
> 64-bit process from a 32-bit process to return EOF when it reads
> past 0xffffffff.
>
> Implement TASK_SIZE_OF exactly the same as TASK_SIZE with
> test_tsk_thread_flag instead of test_thread_flag.
>
> Cc: [email protected]
> Signed-off-by: Colin Cross <[email protected]>
Thanks. Applied.
--
Catalin