From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD38EC4167B for ; Tue, 15 Mar 2022 00:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244868AbiCOANF (ORCPT ); Mon, 14 Mar 2022 20:13:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244841AbiCOAMw (ORCPT ); Mon, 14 Mar 2022 20:12:52 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BE4741323 for ; Mon, 14 Mar 2022 17:11:40 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id h14so30106133lfk.11 for ; Mon, 14 Mar 2022 17:11:40 -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=wKU4ZRqHh+/7R0KNuwH0gJELjq2wS0wK12KdzbWieg8=; b=pdvGf9PQdPL+jc2z0MSpu+kjnnZ0nHo4cryyXO4GFzrOWzzVTepjpBoNHTaE5+75bw d4VQEWt7imtT/TZ1UoujoFiquSI+9E7m+ThkkWoyWi+NQdu+QjPDRjH5KIfNJ/ZJCqHe wjyXN2uVrnZm+UyCFSacS1mv7NDERQ6PhQESj4QO2FkimAccprmrU6pc52zKBsITFDja gC5Oaweu+0IukaAZaELGkgb/0HwzwXkztXvDRCSedoxtmzVa5na/Iqy+oufxaPnjMp// X2NpOHkJ2Xep3wu3lyieE5LytahX0zC0ab4HUWMmTOWR6NF6gC0IihKhyOGQSkwmUu/9 EmUg== 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=wKU4ZRqHh+/7R0KNuwH0gJELjq2wS0wK12KdzbWieg8=; b=ZQnGwh2em0OwqhlaYioRvu8semF8GtOK83Tx6CQ5+GlVw+rHM8L7KUvpPiOsuoO5XY UIBYjj4PYh6i+nvR1VbSeJRScv0RNDrbCFF3CivbbcmSmsEvP0BfWmU3cU/EldT9uxWs kqLgYnznG0rE6Jp537o4wvcqwcoZ+PkyAV73lxS1zzA/RSdRzRiZCrbdMwTQgqbiap4+ RgVzpGbZ7Oub//wxcdEbxrvOD0azThOzeqvuOlu0epOZmEM9HB/I0KqW+vw6AGVo/8zY d8qpdKgmLoQpjb6xdlDWvO7eLgAAqxcubyc9J0uyDFM+aRKRhTeKBLnh8uYfxRM6Cb69 0fgg== X-Gm-Message-State: AOAM533m0CN7vj4VGNo8iHN82y6hgBtZhphPgY8f3c+TfngGDBxx/Tb5 NEt0J5F8n1vKd7R13HEMMLdSCgxFC1gZmFd1N2hxeQ== X-Google-Smtp-Source: ABdhPJxPtvXRGpRay/asNi1i55O48lEOmE5yWTDcG4DlXbCoDcVr3r6f/V+w4+w607DlldBSh6to9lYM41nQDiqqXho= X-Received: by 2002:ac2:5fe3:0:b0:448:5ba2:445f with SMTP id s3-20020ac25fe3000000b004485ba2445fmr15394525lfg.682.1647303098171; Mon, 14 Mar 2022 17:11:38 -0700 (PDT) MIME-Version: 1.0 References: <20220309165222.2843651-1-tjmercier@google.com> <20220309165222.2843651-8-tjmercier@google.com> In-Reply-To: From: Todd Kjos Date: Mon, 14 Mar 2022 17:11:25 -0700 Message-ID: Subject: Re: [RFC v3 7/8] binder: use __kernel_pid_t and __kernel_uid_t for userspace To: "T.J. Mercier" 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 14, 2022 at 4:45 PM T.J. Mercier wrote: > > On Thu, Mar 10, 2022 at 11:33 AM Todd Kjos wrote: > > > > On Wed, Mar 9, 2022 at 8:52 AM T.J. Mercier wrot= e: > > > > > > 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 hea= der > > > 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) > > 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. It looks like those other cases used to be pid_t, but were changed to __kernel_pid_t. Acked-by: Todd Kjos > > > > > > > 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 > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1E66C433EF for ; Tue, 15 Mar 2022 00:11:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11FAB10E28D; Tue, 15 Mar 2022 00:11:42 +0000 (UTC) Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3007010E33C for ; Tue, 15 Mar 2022 00:11:40 +0000 (UTC) Received: by mail-lf1-x135.google.com with SMTP id s29so8753813lfb.13 for ; Mon, 14 Mar 2022 17:11:40 -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=wKU4ZRqHh+/7R0KNuwH0gJELjq2wS0wK12KdzbWieg8=; b=pdvGf9PQdPL+jc2z0MSpu+kjnnZ0nHo4cryyXO4GFzrOWzzVTepjpBoNHTaE5+75bw d4VQEWt7imtT/TZ1UoujoFiquSI+9E7m+ThkkWoyWi+NQdu+QjPDRjH5KIfNJ/ZJCqHe wjyXN2uVrnZm+UyCFSacS1mv7NDERQ6PhQESj4QO2FkimAccprmrU6pc52zKBsITFDja gC5Oaweu+0IukaAZaELGkgb/0HwzwXkztXvDRCSedoxtmzVa5na/Iqy+oufxaPnjMp// X2NpOHkJ2Xep3wu3lyieE5LytahX0zC0ab4HUWMmTOWR6NF6gC0IihKhyOGQSkwmUu/9 EmUg== 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=wKU4ZRqHh+/7R0KNuwH0gJELjq2wS0wK12KdzbWieg8=; b=JD27P9OWIJ7+jbAxcOWID+NWfwpZdgREDuvEYVG0Z5rcPajeSQSD6WT4e0Y9GmDlCP avNsfG1g49wuifnwgl8hyS+oxTakLYNQn4ESVHiUEfsW072CB2o6nRo8G0d4JLiPjLyJ dbwv2apDPO4zIFH8mhZYaDBk6m4WEWrtd9oL5lwFfvPk6M/R6SEyAn1fVSCD3VwqcKMy ynT0GwTIy4PX7qETpojld5OaBd7EFYBwQX7cAG7jvqAjFSLgkdnKYsDpLzD4xH6vgydW x8wdW+MMDLbMgzuLKX4LPMWotvtzT2tIDJlPfaKMdhnjdjYgtwi1Vi4fP7YtxT0IMuv5 hBJQ== X-Gm-Message-State: AOAM532QreS9ptu5OAv67Rkso0UUXK88GpO2yBNTHmiz4y7QL7zSvaM0 h88PFpvjje06/4preu01xhKq001c1bWYyEvCOmqlMw== X-Google-Smtp-Source: ABdhPJxPtvXRGpRay/asNi1i55O48lEOmE5yWTDcG4DlXbCoDcVr3r6f/V+w4+w607DlldBSh6to9lYM41nQDiqqXho= X-Received: by 2002:ac2:5fe3:0:b0:448:5ba2:445f with SMTP id s3-20020ac25fe3000000b004485ba2445fmr15394525lfg.682.1647303098171; Mon, 14 Mar 2022 17:11:38 -0700 (PDT) MIME-Version: 1.0 References: <20220309165222.2843651-1-tjmercier@google.com> <20220309165222.2843651-8-tjmercier@google.com> In-Reply-To: From: Todd Kjos Date: Mon, 14 Mar 2022 17:11:25 -0700 Message-ID: Subject: Re: [RFC v3 7/8] binder: use __kernel_pid_t and __kernel_uid_t for userspace To: "T.J. Mercier" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zefan Li , linux-doc@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, Benjamin Gaignard , Kalesh Singh , Joel Fernandes , Shuah Khan , Sumit Semwal , Kenny.Ho@amd.com, Jonathan Corbet , Martijn Coenen , Laura Abbott , linux-media@vger.kernel.org, linux-kselftest@vger.kernel.org, Todd Kjos , linaro-mm-sig@lists.linaro.org, Tejun Heo , cgroups@vger.kernel.org, Suren Baghdasaryan , Christian Brauner , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Liam Mark , =?UTF-8?Q?Christian_K=C3=B6nig?= , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Thomas Zimmermann , Johannes Weiner , Hridya Valsaraju Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Mar 14, 2022 at 4:45 PM T.J. Mercier wrote: > > On Thu, Mar 10, 2022 at 11:33 AM Todd Kjos wrote: > > > > On Wed, Mar 9, 2022 at 8:52 AM T.J. Mercier wrot= e: > > > > > > 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 hea= der > > > 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) > > 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. It looks like those other cases used to be pid_t, but were changed to __kernel_pid_t. Acked-by: Todd Kjos > > > > > > > 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 > > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Todd Kjos Subject: Re: [RFC v3 7/8] binder: use __kernel_pid_t and __kernel_uid_t for userspace Date: Mon, 14 Mar 2022 17:11:25 -0700 Message-ID: References: <20220309165222.2843651-1-tjmercier@google.com> <20220309165222.2843651-8-tjmercier@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: 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=wKU4ZRqHh+/7R0KNuwH0gJELjq2wS0wK12KdzbWieg8=; b=pdvGf9PQdPL+jc2z0MSpu+kjnnZ0nHo4cryyXO4GFzrOWzzVTepjpBoNHTaE5+75bw d4VQEWt7imtT/TZ1UoujoFiquSI+9E7m+ThkkWoyWi+NQdu+QjPDRjH5KIfNJ/ZJCqHe wjyXN2uVrnZm+UyCFSacS1mv7NDERQ6PhQESj4QO2FkimAccprmrU6pc52zKBsITFDja gC5Oaweu+0IukaAZaELGkgb/0HwzwXkztXvDRCSedoxtmzVa5na/Iqy+oufxaPnjMp// X2NpOHkJ2Xep3wu3lyieE5LytahX0zC0ab4HUWMmTOWR6NF6gC0IihKhyOGQSkwmUu/9 EmUg== In-Reply-To: List-ID: Content-Type: text/plain; charset="utf-8" To: "T.J. Mercier" 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 , Laur On Mon, Mar 14, 2022 at 4:45 PM T.J. Mercier wrote: > > On Thu, Mar 10, 2022 at 11:33 AM Todd Kjos wrote: > > > > On Wed, Mar 9, 2022 at 8:52 AM T.J. Mercier wrot= e: > > > > > > 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 hea= der > > > 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) > > 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. It looks like those other cases used to be pid_t, but were changed to __kernel_pid_t. Acked-by: Todd Kjos > > > > > > > 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 > > >