From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751757AbcISOqe (ORCPT ); Mon, 19 Sep 2016 10:46:34 -0400 Received: from mail.southpole.se ([37.247.8.11]:36449 "EHLO mail.southpole.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085AbcISOqd (ORCPT ); Mon, 19 Sep 2016 10:46:33 -0400 Subject: Re: [PATCH 1/7] Apply transparent_union attribute to union semun To: Stafford Horne , Stefan Kristiansson , Andrew Morton References: <1474036985-20981-1-git-send-email-shorne@gmail.com> <1474036985-20981-2-git-send-email-shorne@gmail.com> Cc: linux-kernel@vger.kernel.org From: Jonas Bonn Message-ID: <57DFF593.9030200@southpole.se> Date: Mon, 19 Sep 2016 16:26:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1474036985-20981-2-git-send-email-shorne@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Assp-Version: 2.5.1(16177) on assp.southpole.se X-Assp-ID: assp.southpole.se 95188-04626 X-Assp-Session: 7F0FD21AF6E0 (mail 1) X-Assp-Client-SSL: yes X-Assp-Server-TLS: yes Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NAK... this breaks other architectures. The OpenRISC toolchain is broken with regard to this issue. Five years ago (last I looked) nobody seemed interesting in fixing it. Has anything changed here? /Jonas On 09/16/2016 04:42 PM, Stafford Horne wrote: > ..From: Jonas Bonn > > The syscall handler for semctl is written under the assumption that the > toolchain will pass "small" unions as function parameters directly instead > of by reference. The union semun is "small" and thus fits this description. > > Since it is assumed that the union will be passed directly and not by > reference, it is safe to access the union members without going via > get_user. > > The OpenRISC architecture, however, passes all unions by reference, thus > breaking the above assumption. > > The technically correct fix here is to mark the union as being transparent > so that the ABI of the union's first element determines the parameter > passing method and thus make explicit what's already implied in the function > definition. > > Signed-off-by: Jonas Bonn > Signed-off-by: Stafford Horne > --- > include/uapi/linux/sem.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/linux/sem.h b/include/uapi/linux/sem.h > index dd73b90..aabe50f 100644 > --- a/include/uapi/linux/sem.h > +++ b/include/uapi/linux/sem.h > @@ -48,7 +48,7 @@ union semun { > unsigned short __user *array; /* array for GETALL & SETALL */ > struct seminfo __user *__buf; /* buffer for IPC_INFO */ > void __user *__pad; > -}; > +} __attribute__ ((transparent_union)); > > struct seminfo { > int semmap;