Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4201809pxp; Tue, 15 Mar 2022 15:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB2eJjEldPzZXz8nAlsuSp1JXilAcL98vIA2sD774xIj4aVtWD9CR6gHMLCSPfMOxbGYAK X-Received: by 2002:a17:906:7312:b0:6db:5729:f11 with SMTP id di18-20020a170906731200b006db57290f11mr24004427ejc.623.1647382166364; Tue, 15 Mar 2022 15:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647382166; cv=none; d=google.com; s=arc-20160816; b=pUdNjQ19pmLqocz2KZdbjUoz+B+gQvp4ekKxHkepHDzodcR3goGl8yIrRPEGSnkrAF GtPju8Z1yPKfAPjByhpXa3A+fr9EcFv+4Q4KKZPuTNniz0978OeAv8LtnTlwLDZ28npa ntuBuLvtUWMranKeFhphb75qBuKEJMFUIWVmkA7MiGzg/qRXpTWDQibvX2w5ehQLpYeX X78ZeqKim6pACszV93H873mv7UxKKxn+skI1Z8COfyInYdT70JzQkh3X9Ws/6RRYg/EH cSUJGtlqqQOyZWHhsEa5og+gQojI8XuDv1QPxS1mzbZ0dKgyDxFub1ScPRzhy26e2byw 7bIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nYOjHF+WhaOll744zl3KXczQ6UnybRfVr7cW3I5uN/U=; b=Ui0zbqyYwC5ZE1NsW00tqmZVRQZQ7KNHsaShNbO3EM2z5bQKN58kdV5g+5dipNJxPS Fp4VoSWzbd/lU4AGAy4fDVr5f8d1jMPHxPO89wIpW/+614c5vIlNIJc607KX7uysdQQj Td4bafXBSTYPl+UFqcIOTcrFuv0IiV52a85Z+/y0TaHbWRbsqmmEXB+MJx3L18LfMYqU 4wa/IdsGbOg72UTG44pQ13ZknKPLnfiWMRcvmWAvLvbON3MSDbNdaijSxq7gTmjdX+aw 6SpQcRvfTCBfHYvRFznyPaZbidqcJs3YPBc99ycQrGk8fIRHR211varOmoFf93NOg6Fn rg7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eWq9aQSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14-20020a056402190e00b0041616adb0dbsi206887edz.222.2022.03.15.15.09.01; Tue, 15 Mar 2022 15:09:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eWq9aQSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351357AbiCOTFc (ORCPT + 99 others); Tue, 15 Mar 2022 15:05:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351260AbiCOTEL (ORCPT ); Tue, 15 Mar 2022 15:04:11 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B418F5A150 for ; Tue, 15 Mar 2022 12:02:49 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id qx21so43512891ejb.13 for ; Tue, 15 Mar 2022 12:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nYOjHF+WhaOll744zl3KXczQ6UnybRfVr7cW3I5uN/U=; b=eWq9aQSnpFSM7gGPtqgzIwr8bb/qKsDMvo0mIbS4s59AMIIHEMyCDMwhpLWRS+EYBR qN4oTEZNXWPjiFCM5wbN4L3FVB0yMfHlzKy9DLlhHVCdkUAg+H8m96o6+l6phOAtZZtL HqEaabMV1A231GA5THyiGjQn+CcdPV6Wcj7+UPW4PCAGWku/81HP+8C5q//5lWvhO0Pu 3zeib+NRZoI9eWeTsoj34Li0T9JVhg3Z1kUYOR1XGxD8A2nRmcx8ve9PFlZCqJIC6N4E zEz1m0vSJoc3+NJsHrbvJr8ATMwQ+P3zv+QChYRQcRSYL4oNsBWZ06rrB2G0G0fVIJ1p NQSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nYOjHF+WhaOll744zl3KXczQ6UnybRfVr7cW3I5uN/U=; b=xpd9GtBieWsKDluA8iYeAi9Z1nQZU9vMM4KEZ8zhZ9JXS2MsPx6gE6t84tKvA278l2 GaQr6DTgPdcg28UJ0/zYagLr+Qeia2ibaoPIwaytd8f4J4r0ku8ydMDgFpO1Mne0LPGV OO7nC/eKvnqTPfoFwgJUe6HIHv43Zk7NxEvMx0TnKUP/CmmooJYB2HSS4eNkgSDT5RA9 md/3rbYTvVLrWHO6+WjwRtYcXUJY6uoxfEfPTl/3ZNW4MV297ovUxRdhiNguaZNo6FL6 d4+5E70AAwYNwtvjqJR8dUsaWoSLv000wRPlPENH2gL3q/xRdW6XCMyOC02BWL1EW+va g9kQ== X-Gm-Message-State: AOAM532D6qdkU0Rf3cyaOoK9aNEZLCo7kzmyjUOoIudsUBdrhkr9ryOL 3MFEmnQK81W1ii08FlpTZXZt/q9WCs0W0pHnVgGZiA== X-Received: by 2002:a17:907:7f2a:b0:6d6:df12:7f57 with SMTP id qf42-20020a1709077f2a00b006d6df127f57mr23761361ejc.122.1647370967391; Tue, 15 Mar 2022 12:02:47 -0700 (PDT) MIME-Version: 1.0 References: <20220309165222.2843651-1-tjmercier@google.com> <20220309165222.2843651-8-tjmercier@google.com> In-Reply-To: From: "T.J. Mercier" Date: Tue, 15 Mar 2022 12:02:35 -0700 Message-ID: Subject: Re: [RFC v3 7/8] binder: use __kernel_pid_t and __kernel_uid_t for userspace To: David Laight Cc: Todd Kjos , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , Suren Baghdasaryan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , Tejun Heo , Zefan Li , Johannes Weiner , Shuah Khan , Kalesh Singh , "Kenny.Ho@amd.com" , "dri-devel@lists.freedesktop.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linaro-mm-sig@lists.linaro.org" , "cgroups@vger.kernel.org" , "linux-kselftest@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 15, 2022 at 12:56 AM David Laight wrote: > > From: T.J. Mercier > > Sent: 14 March 2022 23:45 > > > > On Thu, Mar 10, 2022 at 11:33 AM Todd Kjos wrote: > > > > > > On Wed, Mar 9, 2022 at 8:52 AM T.J. Mercier wrote: > > > > > > > > The kernel interface should use types that the kernel defines instead of > > > > pid_t and uid_t, whose definiton is owned by libc. This fixes the header > > > > so that it can be included without first including sys/types.h. > > > > > > > > Signed-off-by: T.J. Mercier > > > > --- > > > > include/uapi/linux/android/binder.h | 4 ++-- > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h > > > > index 169fd5069a1a..aa28454dbca3 100644 > > > > --- a/include/uapi/linux/android/binder.h > > > > +++ b/include/uapi/linux/android/binder.h > > > > @@ -289,8 +289,8 @@ struct binder_transaction_data { > > > > > > > > /* General information about the transaction. */ > > > > __u32 flags; > > > > - pid_t sender_pid; > > > > - uid_t sender_euid; > > > > + __kernel_pid_t sender_pid; > > > > + __kernel_uid_t sender_euid; > > > > > > Are we guaranteed that this does not affect the UAPI at all? Userspace > > > code using this definition will have to run with kernels using the old > > > definition and visa-versa. > > > > A standards compliant userspace should be expecting a signed integer > > type here. So the only way I can think userspace would be affected is > > if: > > 1) pid_t is a long AND > > 2) sizeof(long) > sizeof(int) AND > > 3) Consumers of the pid_t definition actually attempt to mutate the > > result to make use of extra bits in the variable (which are not there) > > Or the userspace headers have a 16bit pid_t. Since the kernel uses an int for PIDs, wouldn't a 16 bit pid_t already be potentially broken (overflow) on systems where int is not 16 bits? On systems where int is 16 bits, there is no change here except to achieve uniform use of __kernel_pid_t in the kernel headers and fix the include problem. > > I can't help feeling that uapi headers should only use explicit > fixed sized types. > There is no point indirecting the type names - the sizes still > can't be changes. I think it's still unlikely to be an actual problem. For example there are other occasions where a switch like this was made: https://github.com/torvalds/linux/commit/694a58e29ef27c4c26f103a9decfd053f94dd34c https://github.com/torvalds/linux/commit/269b8fd5d058f2c0da01a42b20315ffc2640d99b And also since Binder's only known user is Android through Bionic which already expects the type of pid_t to be __kernel_pid_t. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)