Use __kernel_long_t in struct mq_attr
PATCH 1/1 Use __kernel_long_t in struct mq_attr
Both x32 and x86-64 use the same struct mq_attr for system calls. But x32 long is 32-bit. This patch replaces long with __kernel_long_t in struct mq_attr.
--- include/uapi/linux/mqueue.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
include/uapi/linux/mqueue.h +5 -5
@@ -23,11 +23,11 @@#define MQ_BYTES_MAX 819200struct mq_attr { -long mq_flags;/* message queue flags */ -long mq_maxmsg;/* maximum number of messages */ -long mq_msgsize;/* maximum message size */ -long mq_curmsgs;/* number of messages currently queued */ -long __reserved[4 ];/* ignored for input, zeroed for output */ +__kernel_long_t mq_flags;/* message queue flags */ +__kernel_long_t mq_maxmsg;/* maximum number of messages */ +__kernel_long_t mq_msgsize;/* maximum message size */ +__kernel_long_t mq_curmsgs;/* number of messages currently queued */ +__kernel_long_t __reserved[4 ];/* ignored for input, zeroed for output */ };/*
Signature · 1 line
1.8.4.2
Quoted 4 lines · H.J. Lu
Both x32 and x86-64 use the same struct
mq_attrfor system calls. But x32 long is 32-bit. This patch replaces long with__kernel_long_tin structmq_attr.
Here is the updated patch which uses __kernel_long_t only if __BITS_PER_LONG == 64.
H.J.
Quoted 1 line
From
fc117a05dd0a4a9ec7e6ae286aac9433609ce155Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <[email protected]>
Date: Wed, 25 Dec 2013 08:56:22 -0800
Subject: [PATCH] Use __kernel_long_t in struct mq_attr
Both x32 and x86-64 use the same struct mq_attr for system calls. But x32 long is 32-bit. This patch replaces long with __kernel_long_t in struct mq_attr if __BITS_PER_LONG == 64.
--- include/uapi/linux/mqueue.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
include/uapi/linux/mqueue.h +13 -5
@@ -23,11 +23,19 @@#define MQ_BYTES_MAX 819200struct mq_attr { -long mq_flags;/* message queue flags */ -long mq_maxmsg;/* maximum number of messages */ -long mq_msgsize;/* maximum message size */ -long mq_curmsgs;/* number of messages currently queued */ -long __reserved[4 ];/* ignored for input, zeroed for output */ +#if __BITS_PER_LONG ==64 +__kernel_long_t mq_flags;/* message queue flags */ +__kernel_long_t mq_maxmsg;/* maximum number of messages */ +__kernel_long_t mq_msgsize;/* maximum message size */ +__kernel_long_t mq_curmsgs;/* number of messages currently queued */ +__kernel_long_t __reserved[4 ];/* ignored for input, zeroed for output */ +#else +long mq_flags;/* message queue flags */ +long mq_maxmsg;/* maximum number of messages */ +long mq_msgsize;/* maximum message size */ +long mq_curmsgs;/* number of messages currently queued */ +long __reserved[4 ];/* ignored for input, zeroed for output */ +#endif };/*
Signature · 1 line
1.8.4.2
Quoted 9 lines · H.J. Lu
Quoted 4 lines · H.J. Lu
Both x32 and x86-64 use the same struct
mq_attrfor system calls. But x32 long is 32-bit. This patch replaces long with__kernel_long_tin structmq_attr.Here is the updated patch which uses
__kernel_long_tonly if__BITS_PER_LONG== 64.
That seems wrong in multiple ways... not only does it add more clutter, but it would seem to give the wrong types when __BITS_PER_LONG in userspace is 32.
-hpa
Quoted 7 lines · H. Peter Anvin
Quoted 6 lines · H.J. Lu
Quoted 4 lines · H.J. Lu
Both x32 and x86-64 use the same struct
mq_attrfor system calls. But x32 long is 32-bit. This patch replaces long with__kernel_long_tin structmq_attr.
Quoted 5 lines
Quoted 3 lines
Here is the updated patch which uses
__kernel_long_tonly if__BITS_PER_LONG== 64.That seems wrong in multiple ways... not only does it add more clutter,
It is true for more clutter.
Quoted 3 lines
but it would seem to give the wrong types when
__BITS_PER_LONGin userspace is 32.
For x32, __BITS_PER_LONG is 64, not 32. If __BITS_PER_LONG
is 32, my patch doesn't change anything. If it works before,
it still works. If it is broken before, it remains broken.
I prefer my first patch, which is less clutter. But I can't guarantee it is correct for all x3-like ABIs. My second patch has more clutter, but it has no impact on other ABIs.
Signature · 1 line
H.J.
Quoted 5 lines · H.J. Lu
Quoted 4 lines
but it would seem to give the wrong types when
__BITS_PER_LONGin userspace is 32.
Quoted 8 lines
For x32,
__BITS_PER_LONGis 64, not 32. If__BITS_PER_LONG
is 32, my patch doesn't change anything. If it works before,
it still works. If it is broken before, it remains broken.I prefer my first patch, which is less clutter. But I can't guarantee it is correct for all x3-like ABIs. My second patch has more clutter, but it has no impact on other ABIs.
It's rather simple to prove, which is to consider the generic definition of __kernel_[u]long_t.
-hpa
Quoted 10 lines · H. Peter Anvin
Quoted 9 lines · H.J. Lu
Quoted 4 lines
but it would seem to give the wrong types when
__BITS_PER_LONGin userspace is 32.For x32,
__BITS_PER_LONGis 64, not 32. If__BITS_PER_LONG
is 32, my patch doesn't change anything. If it works before,
it still works. If it is broken before, it remains broken.
Quoted 8 lines
Quoted 4 lines
I prefer my first patch, which is less clutter. But I can't guarantee it is correct for all x3-like ABIs. My second patch has more clutter, but it has no impact on other ABIs.
It's rather simple to prove, which is to consider the generic definition of __kernel_[u]long_t.
Then. I withdrew my second alternative with __BITS_PER_LONG == 64 check.. Please use my first alternative for all my kernel_long_t and kernel_ulong_t patches.
Thanks.
Signature · 1 line
H.J.