Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4086018pxp; Tue, 15 Mar 2022 12:14:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH8kJ37GuiWmIzb7jeUJli8+DK+ug2w2BqPpLJ7VyUVsflPp1PntoEKYMMw/UgZW6++roY X-Received: by 2002:a17:906:2486:b0:6cf:ced9:e4cc with SMTP id e6-20020a170906248600b006cfced9e4ccmr24430568ejb.201.1647371658975; Tue, 15 Mar 2022 12:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647371658; cv=none; d=google.com; s=arc-20160816; b=yCZUPqU9ZqC4lPKe4yPoLrdoR6IxgZ1MeVXfbucpmuTXof6bGHwX/14+FfzgrBQmgZ 02uEHnBgU/bHw8i/o44apWMKLS+u8eq2axh65898xDF53K5Zbfi294C2UPbdq9dAMvSY CjZHoQdLTAGFeI8Zg0KhrgLeKOxRFl8L/a/TF1NYdJsdKGBFDTBbZuOr8ZS+wUVb0Flg I7j8fYi7MOTQeexihJ5sFwtpEPFO6R1lHawovwJhDyVaQ8BV9jQdDG9Dng77KojC37Mh iVIylUXGDzrFS4SYudBjTysL64xU8aXZQnX3pC3IzdCD5rlfos4kTSUeGY0fSd6aD4zI xgLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=mMcKlcLkl25csYGtmWB99GmowZ54MQeoPUbWxxcyFU0=; b=HuG5+3Dp3lQgQcaDN8ltqdUO/COWBUgvKSPo+F66GRYOJllBD1dlotqvK3m0ZBX8Rj 5Cj5d1agCm9ddyV7b6UgsaEELnLUxy3UdwVsdenwKAHshd7TDZwCXfs7sfdOVDScvF6H 7QctVbm5i920CtSZ58yHaemt/0UYsWH3YGQgVGMhFGzHiqvTeaWzAjWLf4/WDF83naOY lS5AnAVtxNxOr5mt44lMwhq8CLjB4i3/FV0aqyNdf5OWKjyQGPFSQ/NUPA6olQWaeHqj uwNvhJrzqRlsKTSFRous21PgCbG5jJIPeTsBgvaaJ+feUKb/SE5sqg9nI+LveLvKukgv eyFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=bp+YoIVG; 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 nd32-20020a17090762a000b006d887ed13fcsi12290686ejc.296.2022.03.15.12.13.53; Tue, 15 Mar 2022 12:14:18 -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=bp+YoIVG; 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 S1343752AbiCNXqy (ORCPT + 99 others); Mon, 14 Mar 2022 19:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239436AbiCNXqx (ORCPT ); Mon, 14 Mar 2022 19:46:53 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7072B3E5F1 for ; Mon, 14 Mar 2022 16:45:41 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id hw13so36166508ejc.9 for ; Mon, 14 Mar 2022 16:45:41 -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:content-transfer-encoding; bh=mMcKlcLkl25csYGtmWB99GmowZ54MQeoPUbWxxcyFU0=; b=bp+YoIVGfFN/43D3vqHErY1NhIRJApUAhtw6o/hQeIyaDBqIfE66EIhFuNlzouKqsM ICMTNUqtiRAq88ITvYxr1uiF5OmdPGah32szvxsrVE8+TbWCoOGxOG6L25aPWaho7kdy 3FU/jNh6QDkaRKObZiMMOkBlD8Aqv99swKSc8YZ9bFy6T0F/mbML6sVVYqbR6qCMVE6H bYhE/ZUbxEYhn6H6a+/VharXFDIBFPo45r3fdwvvEZ51SgbTUi25vilSjvica56rkM6I xTjLcOE3UXJzEYpLAj8t0ISFMLBTpHiYS87O0Yj4+2ZJb/rKhYVFzvJMGee+en585/rw GBaA== 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:content-transfer-encoding; bh=mMcKlcLkl25csYGtmWB99GmowZ54MQeoPUbWxxcyFU0=; b=2DYJaiznlr468lVJi0UP99ryW0CRBAgcJ8p0/+FKAmgDiD4cD1XQLrC4m+LKn4fbsy dBq2Env84d4rXMaSzaXaRxQ3CwLirK4g6oWGo1JKbRG/SCP94Y7U495tDR925uvxYuWi U0hMc54sV+mNCC2uPwzFMeGrWKFED1N7v6IicTmqOhSTgr2iQV54i3eNX07sgC9ZlTiJ kSvMedkbzp7lSkWVjSqHg61zDYHRlFs3pNwTh57KpQfRAIwDNSVjiT1XPr5XGoTTRkDB DBQqMSKlz0f181ee3k9i8wCZMSGzjUefsHLPb54++vW7z29bO1XDcFOOZf5stEMF9dBu yAng== X-Gm-Message-State: AOAM532UUNUmIaWg/VCoFC9JqddWi+AKrJ1JumR4eGPr80Tgm4EnsD0v IU6t2kbaYqyPPbbI0x7TyQLiAOhbLNEUv1xt7tq2uw== X-Received: by 2002:a17:906:5d08:b0:6da:b4ea:937 with SMTP id g8-20020a1709065d0800b006dab4ea0937mr20516098ejt.446.1647301539672; Mon, 14 Mar 2022 16:45:39 -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: Mon, 14 Mar 2022 16:45:28 -0700 Message-ID: Subject: Re: [RFC v3 7/8] binder: use __kernel_pid_t and __kernel_uid_t for userspace To: Todd Kjos Cc: 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" Content-Transfer-Encoding: quoted-printable 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 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 o= f > > pid_t and uid_t, whose definiton is owned by libc. This fixes the heade= r > > 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/a= ndroid/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) This seems extremely unlikely. For instance just on the topic of the first item, all of the C library implementations with pid_t definitions linked here use an int, except for Bionic which typdefs pid_t to __kernel_pid_t and Sortix which uses long. https://wiki.osdev.org/C_Library However I would argue this is already broken and should count as a bug fix since I can't do this: $ cat binder_include.c ; gcc binder_include.c #include int main() {} In file included from binder_include.c:1: /usr/include/linux/android/binder.h:291:9: error: unknown type name =E2=80= =98pid_t=E2=80=99 291 | pid_t sender_pid; | ^~~~~ /usr/include/linux/android/binder.h:292:9: error: unknown type name =E2=80= =98uid_t=E2=80=99 292 | uid_t sender_euid; | ^~~~~ This is also the only occurrence of pid_t in all of include/uapi/linux. All 40+ other uses are __kernel_pid_t, and I don't see why the binder header should be different. > > > binder_size_t data_size; /* number of bytes of data */ > > binder_size_t offsets_size; /* number of bytes of offsets *= / > > > > -- > > 2.35.1.616.g0bdcbb4464-goog > >