Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752294AbbBMICN (ORCPT ); Fri, 13 Feb 2015 03:02:13 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:35778 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbbBMICK (ORCPT ); Fri, 13 Feb 2015 03:02:10 -0500 Message-ID: <54DDAF2B.2070707@huawei.com> Date: Fri, 13 Feb 2015 16:00:43 +0800 From: Bamvor Jian Zhang User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Catalin Marinas CC: , Will Deacon , "linux-kernel@vger.kernel.org" , "lizefan@huawei.com" , "dingtianhong@huawei.com" , "linux-arm-kernel@lists.infradead.org" , , , , , , , , , , , , , Subject: Re: [PATCH] compat: Fix endian issue in union sigval References: <1423563011-12377-1-git-send-email-bamvor.zhangjian@huawei.com> <20150210122718.GC32052@e104818-lin.cambridge.arm.com> <54DB3B60.4050100@huawei.com> <20150211154054.GD9058@e104818-lin.cambridge.arm.com> In-Reply-To: <20150211154054.GD9058@e104818-lin.cambridge.arm.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.75.31] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.54DDAF46.006A,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f9a882cddbc9b6c6a6e96df476d0c61c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3212 Lines: 74 On 2015/2/11 23:40, Catalin Marinas wrote: > On Wed, Feb 11, 2015 at 07:22:08PM +0800, Bamvor Jian Zhang wrote: >> On 2015/2/10 20:27, Catalin Marinas wrote: >>> On Tue, Feb 10, 2015 at 10:10:11AM +0000, Zhang Jian(Bamvor) wrote: ... > The native sigval_t is also a union but on 64-bit big endian, the > sival_int overlaps with the most significant 32-bit of the sival_ptr. > So reading sival_int would always be 0. When the compat siginfo is > copied to user, arm64 reads the native sival_ptr (si_ptr) and converts > it to the compat one, getting the correct 32-bit value. However, other > architectures access sival_int (si_int) instead which breaks with your > get_compat_sigevent() changes. > >>> I think the correct fix is in the arm64 code: >> >> The following code could fix my issue. > > Without any parts of your patch? Yes. As you mentioned above, sival_int overlaps the most significant 32bit of the sival_ptr, it seems that your patch is right if sival_ptr is less than 32bit. > I think that's correct fix since in the SIGEV_THREAD mq_notify case, we > would not deliver a signal as notification, so the sival_int value is > irrelevant (it would be 0 for big-endian compat tasks because of the > sigval_t union on 64-bit). > > Your patch would work as well but you have to change all the other > architectures to use si_ptr when copying to a compat siginfo. Yeah, it seems that my patch is useful only if the sival_ptr is bigger than 32bit. It need the similar changes with following catalin's patch in the following 64bit architecture: x86: arch/x86/ia32/ia32_signal.c tile, s390: arch/xxx/kernel/compat_signal.c parisc, sparc, mips: arch/xxx/kernel/signal32.c powerpc: arch/xxx/kernel/signal_32.c cc these maintainers for input. regards bamvor >>> diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c >>> index e299de396e9b..32601939a3c8 100644 >>> --- a/arch/arm64/kernel/signal32.c >>> +++ b/arch/arm64/kernel/signal32.c >>> @@ -154,8 +154,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) >>> case __SI_TIMER: >>> err |= __put_user(from->si_tid, &to->si_tid); >>> err |= __put_user(from->si_overrun, &to->si_overrun); >>> - err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, >>> - &to->si_ptr); >>> + err |= __put_user(from->si_int, &to->si_int); >>> break; >>> case __SI_POLL: >>> err |= __put_user(from->si_band, &to->si_band); >>> @@ -184,7 +183,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) >>> case __SI_MESGQ: /* But this is */ >>> err |= __put_user(from->si_pid, &to->si_pid); >>> err |= __put_user(from->si_uid, &to->si_uid); >>> - err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, &to->si_ptr); >>> + err |= __put_user(from->si_int, &to->si_int); >>> break; >>> case __SI_SYS: >>> err |= __put_user((compat_uptr_t)(unsigned long) > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/