From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753145AbbBXV7w (ORCPT ); Tue, 24 Feb 2015 16:59:52 -0500 Received: from mail-am1on0055.outbound.protection.outlook.com ([157.56.112.55]:18828 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752492AbbBXV7t (ORCPT ); Tue, 24 Feb 2015 16:59:49 -0500 Message-ID: <54ECF309.3020509@ezchip.com> Date: Tue, 24 Feb 2015 16:54:17 -0500 From: Chris Metcalf User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Catalin Marinas CC: Bamvor Jian Zhang , , , , , "dingtianhong@huawei.com" , , "linux-kernel@vger.kernel.org" , Will Deacon , , "lizefan@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> <54DDAF2B.2070707@huawei.com> <20150213104455.GA3508@e104818-lin.cambridge.arm.com> <54DE730D.3090100@ezchip.com> <20150214112220.GB10246@MBP.local> In-Reply-To: <20150214112220.GB10246@MBP.local> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [12.216.194.146] X-ClientProxiedBy: CO2PR11CA0031.namprd11.prod.outlook.com (10.141.242.169) To DB3PR02MB0537.eurprd02.prod.outlook.com (25.160.51.149) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=cmetcalf@ezchip.com; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB0537; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005004);SRVR:DB3PR02MB0537; X-Forefront-PRVS: 04976078F0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6049001)(189002)(377454003)(24454002)(51704005)(479174004)(199003)(80316001)(86362001)(83506001)(15975445007)(19580395003)(77096005)(68736005)(42186005)(2950100001)(33656002)(97736003)(66066001)(106356001)(92566002)(105586002)(65806001)(110136001)(40100003)(122386002)(23746002)(62966003)(77156002)(54356999)(76176999)(87266999)(50986999)(65816999)(59896002)(87976001)(93886004)(47776003)(64706001)(65956001)(64126003)(46102003)(50466002)(36756003)(101416001)(7059030)(18886065003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR02MB0537;H:[10.7.0.239];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB0537; X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2015 21:54:32.4510 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR02MB0537 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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