All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Metcalf <cmetcalf@ezchip.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: linux-arch@vger.kernel.org, benh@kernel.crashing.org,
	davem@davemloft.net, mpe@ellerman.id.au, deller@gmx.de,
	hpa@zytor.com, heiko.carstens@de.ibm.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Will Deacon <Will.Deacon@arm.com>,
	jejb@parisc-linux.org, "lizefan@huawei.com" <lizefan@huawei.com>,
	Bamvor Jian Zhang <bamvor.zhangjian@huawei.com>,
	ralf@linux-mips.org,
	"dingtianhong@huawei.com" <dingtianhong@huawei.com>,
	schwidefsky@de.ibm.com, paulus@samba.org, tglx@linutronix.de,
	mingo@redhat.com,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] compat: Fix endian issue in union sigval
Date: Tue, 24 Feb 2015 16:54:17 -0500	[thread overview]
Message-ID: <54ECF309.3020509@ezchip.com> (raw)
In-Reply-To: <20150214112220.GB10246@MBP.local>

On 2/14/2015 6:22 AM, Catalin Marinas wrote:
> 1. user populates sival_int compat_sigevent and invokes
>     compat_sys_mq_notify()
> 2. kernel get_compat_sigevent() copies compat_sigevent into the native
>     sigevent. compat and native sival_int are the same, no problem so
>     far. The other half of 64-bit sival_ptr is zeroed by a memset in this
>     function (this other half can be top or bottom, depending on
>     endianness)
> 3. signal is about to be delivered to user via arch code. The
>     compat_ptr(from->si_ptr) conversion always takes the least
>     significant part of the native si_ptr. On big endian 64-bit, this is
>     zero because get_compat_sigevent() populated the top part of si_ptr
>     with si_int.
>
> So delivering such signals to compat user always sets si_int to 0.
> Little endian is fine.

I looked at this again as I was getting ready to do a tile patch, and realized
why tile and arm64 are different here: tile does a field-by-field copy in
copy_siginfo_from_user32(), like parisc and s390.  As a result, we initialize
the 64-bit kernel si_ptr value by cast from the 32-bit user si_ptr value, rather
than blindly writing into the lower-addressed half of the 64-bit sigval.

As a result, I think I will leave the existing code alone, though unfortunately
that leaves it somewhat unique in manipulating the si_ptr field directly.
But I think the s390 and parisc copy_siginfo_from_user32 leave the high
bits of si_ptr uninitialized, which also strikes me as a bad idea in general.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

WARNING: multiple messages have this Message-ID (diff)
From: Chris Metcalf <cmetcalf@ezchip.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Bamvor Jian Zhang <bamvor.zhangjian@huawei.com>,
	linux-arch@vger.kernel.org, mpe@ellerman.id.au,
	benh@kernel.crashing.org, deller@gmx.de,
	"dingtianhong@huawei.com" <dingtianhong@huawei.com>,
	heiko.carstens@de.ibm.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Will Deacon <Will.Deacon@arm.com>,
	jejb@parisc-linux.org, "lizefan@huawei.com" <lizefan@huawei.com>,
	paulus@samba.org, ralf@linux-mips.org, hpa@zytor.com,
	schwidefsky@de.ibm.com, tglx@linutronix.de, mingo@redhat.com,
	davem@davemloft.net,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] compat: Fix endian issue in union sigval
Date: Tue, 24 Feb 2015 16:54:17 -0500	[thread overview]
Message-ID: <54ECF309.3020509@ezchip.com> (raw)
Message-ID: <20150224215417._Gg6nd9nH94rZdwQwMWnRSZG_gedt6YhM5aLawqpMZ4@z> (raw)
In-Reply-To: <20150214112220.GB10246@MBP.local>

On 2/14/2015 6:22 AM, Catalin Marinas wrote:
> 1. user populates sival_int compat_sigevent and invokes
>     compat_sys_mq_notify()
> 2. kernel get_compat_sigevent() copies compat_sigevent into the native
>     sigevent. compat and native sival_int are the same, no problem so
>     far. The other half of 64-bit sival_ptr is zeroed by a memset in this
>     function (this other half can be top or bottom, depending on
>     endianness)
> 3. signal is about to be delivered to user via arch code. The
>     compat_ptr(from->si_ptr) conversion always takes the least
>     significant part of the native si_ptr. On big endian 64-bit, this is
>     zero because get_compat_sigevent() populated the top part of si_ptr
>     with si_int.
>
> So delivering such signals to compat user always sets si_int to 0.
> Little endian is fine.

I looked at this again as I was getting ready to do a tile patch, and realized
why tile and arm64 are different here: tile does a field-by-field copy in
copy_siginfo_from_user32(), like parisc and s390.  As a result, we initialize
the 64-bit kernel si_ptr value by cast from the 32-bit user si_ptr value, rather
than blindly writing into the lower-addressed half of the 64-bit sigval.

As a result, I think I will leave the existing code alone, though unfortunately
that leaves it somewhat unique in manipulating the si_ptr field directly.
But I think the s390 and parisc copy_siginfo_from_user32 leave the high
bits of si_ptr uninitialized, which also strikes me as a bad idea in general.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


WARNING: multiple messages have this Message-ID (diff)
From: cmetcalf@ezchip.com (Chris Metcalf)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] compat: Fix endian issue in union sigval
Date: Tue, 24 Feb 2015 16:54:17 -0500	[thread overview]
Message-ID: <54ECF309.3020509@ezchip.com> (raw)
In-Reply-To: <20150214112220.GB10246@MBP.local>

On 2/14/2015 6:22 AM, Catalin Marinas wrote:
> 1. user populates sival_int compat_sigevent and invokes
>     compat_sys_mq_notify()
> 2. kernel get_compat_sigevent() copies compat_sigevent into the native
>     sigevent. compat and native sival_int are the same, no problem so
>     far. The other half of 64-bit sival_ptr is zeroed by a memset in this
>     function (this other half can be top or bottom, depending on
>     endianness)
> 3. signal is about to be delivered to user via arch code. The
>     compat_ptr(from->si_ptr) conversion always takes the least
>     significant part of the native si_ptr. On big endian 64-bit, this is
>     zero because get_compat_sigevent() populated the top part of si_ptr
>     with si_int.
>
> So delivering such signals to compat user always sets si_int to 0.
> Little endian is fine.

I looked at this again as I was getting ready to do a tile patch, and realized
why tile and arm64 are different here: tile does a field-by-field copy in
copy_siginfo_from_user32(), like parisc and s390.  As a result, we initialize
the 64-bit kernel si_ptr value by cast from the 32-bit user si_ptr value, rather
than blindly writing into the lower-addressed half of the 64-bit sigval.

As a result, I think I will leave the existing code alone, though unfortunately
that leaves it somewhat unique in manipulating the si_ptr field directly.
But I think the s390 and parisc copy_siginfo_from_user32 leave the high
bits of si_ptr uninitialized, which also strikes me as a bad idea in general.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

WARNING: multiple messages have this Message-ID (diff)
From: Chris Metcalf <cmetcalf@ezchip.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Bamvor Jian Zhang <bamvor.zhangjian@huawei.com>,
	<linux-arch@vger.kernel.org>, <mpe@ellerman.id.au>,
	<benh@kernel.crashing.org>, <deller@gmx.de>,
	"dingtianhong@huawei.com" <dingtianhong@huawei.com>,
	<heiko.carstens@de.ibm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Will Deacon <Will.Deacon@arm.com>, <jejb@parisc-linux.org>,
	"lizefan@huawei.com" <lizefan@huawei.com>, <paulus@samba.org>,
	<ralf@linux-mips.org>, <hpa@zytor.com>, <schwidefsky@de.ibm.com>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <davem@davemloft.net>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] compat: Fix endian issue in union sigval
Date: Tue, 24 Feb 2015 16:54:17 -0500	[thread overview]
Message-ID: <54ECF309.3020509@ezchip.com> (raw)
In-Reply-To: <20150214112220.GB10246@MBP.local>

On 2/14/2015 6:22 AM, Catalin Marinas wrote:
> 1. user populates sival_int compat_sigevent and invokes
>     compat_sys_mq_notify()
> 2. kernel get_compat_sigevent() copies compat_sigevent into the native
>     sigevent. compat and native sival_int are the same, no problem so
>     far. The other half of 64-bit sival_ptr is zeroed by a memset in this
>     function (this other half can be top or bottom, depending on
>     endianness)
> 3. signal is about to be delivered to user via arch code. The
>     compat_ptr(from->si_ptr) conversion always takes the least
>     significant part of the native si_ptr. On big endian 64-bit, this is
>     zero because get_compat_sigevent() populated the top part of si_ptr
>     with si_int.
>
> So delivering such signals to compat user always sets si_int to 0.
> Little endian is fine.

I looked at this again as I was getting ready to do a tile patch, and realized
why tile and arm64 are different here: tile does a field-by-field copy in
copy_siginfo_from_user32(), like parisc and s390.  As a result, we initialize
the 64-bit kernel si_ptr value by cast from the 32-bit user si_ptr value, rather
than blindly writing into the lower-addressed half of the 64-bit sigval.

As a result, I think I will leave the existing code alone, though unfortunately
that leaves it somewhat unique in manipulating the si_ptr field directly.
But I think the s390 and parisc copy_siginfo_from_user32 leave the high
bits of si_ptr uninitialized, which also strikes me as a bad idea in general.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


  parent reply	other threads:[~2015-02-24 21:54 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 10:10 [PATCH] compat: Fix endian issue in union sigval Zhang Jian(Bamvor)
2015-02-10 10:10 ` Zhang Jian(Bamvor)
2015-02-10 12:27 ` Catalin Marinas
2015-02-10 12:27   ` Catalin Marinas
2015-02-11 11:22   ` Bamvor Jian Zhang
2015-02-11 11:22     ` Bamvor Jian Zhang
2015-02-11 11:22     ` Bamvor Jian Zhang
2015-02-11 15:40     ` Catalin Marinas
2015-02-11 15:40       ` Catalin Marinas
2015-02-13  8:00       ` Bamvor Jian Zhang
2015-02-13  8:00         ` Bamvor Jian Zhang
2015-02-13  8:00         ` Bamvor Jian Zhang
2015-02-13 10:44         ` Catalin Marinas
2015-02-13 10:44           ` Catalin Marinas
2015-02-13 21:56           ` Chris Metcalf
2015-02-13 21:56             ` Chris Metcalf
2015-02-13 21:56             ` Chris Metcalf
2015-02-14 11:22             ` Catalin Marinas
2015-02-14 11:22               ` Catalin Marinas
2015-02-14 11:22               ` Catalin Marinas
2015-02-17  6:42               ` Bamvor Jian Zhang
2015-02-17  6:42                 ` Bamvor Jian Zhang
2015-02-17  6:42                 ` Bamvor Jian Zhang
2015-02-21  4:05               ` Chris Metcalf
2015-02-21  4:05                 ` Chris Metcalf
2015-02-21  4:05                 ` Chris Metcalf
2015-02-21  4:05                 ` Chris Metcalf
2015-02-24 21:54               ` Chris Metcalf [this message]
2015-02-24 21:54                 ` Chris Metcalf
2015-02-24 21:54                 ` Chris Metcalf
2015-02-24 21:54                 ` Chris Metcalf
2015-02-25 10:37                 ` Catalin Marinas
2015-02-25 10:37                   ` Catalin Marinas
2015-03-16 19:04                   ` [PATCH] tile: use si_int instead of si_ptr for compat_siginfo Chris Metcalf
2015-03-16 19:04                     ` Chris Metcalf
2015-03-16 19:04                     ` Chris Metcalf
2015-03-23 12:02                     ` Catalin Marinas
2015-03-23 12:02                       ` Catalin Marinas
2015-03-24 20:51                       ` Chris Metcalf
2015-03-24 20:51                         ` Chris Metcalf
2015-03-24 20:51                         ` Chris Metcalf
2015-04-17 16:56                       ` Chris Metcalf
2015-04-17 16:56                         ` Chris Metcalf
2015-04-17 16:56                         ` Chris Metcalf
2015-02-17  7:15           ` [PATCH] compat: Fix endian issue in union sigval Bamvor Jian Zhang
2015-02-17  7:15             ` Bamvor Jian Zhang
2015-02-17  7:15             ` Bamvor Jian Zhang
2015-02-17  7:15             ` Bamvor Jian Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54ECF309.3020509@ezchip.com \
    --to=cmetcalf@ezchip.com \
    --cc=Will.Deacon@arm.com \
    --cc=bamvor.zhangjian@huawei.com \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=dingtianhong@huawei.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=jejb@parisc-linux.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.