mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Carlos Llamas <cmllamas@google.com>
To: "Alice Ryhl" <aliceryhl@google.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Donald Hunter" <donald.hunter@gmail.com>,
	"Li Li" <dualli@google.com>
Cc: "Tiffany Yang" <ynaffit@google.com>,
	"John Stultz" <jstultz@google.com>,
	"Shai Barack" <shayba@google.com>,
	"Thiébaud Weksteen" <tweek@google.com>,
	kernel-team@android.com, linux-kernel@vger.kernel.org,
	"open list:NETWORKING [GENERAL]" <netdev@vger.kernel.org>
Subject: Re: [PATCH v19 3/5] binder: introduce transaction reports via netlink
Date: Sun, 27 Jul 2025 18:18:00 +0000	[thread overview]
Message-ID: <aIZtWGPFCsHdNvq1@google.com> (raw)
In-Reply-To: <20250725183811.409580-4-cmllamas@google.com>

On Fri, Jul 25, 2025 at 06:37:46PM +0000, Carlos Llamas wrote:
> From: Li Li <dualli@google.com>
> 
> Introduce a generic netlink multicast event to report binder transaction
> failures to userspace. This allows subscribers to monitor these events
> and take appropriate actions, such as stopping a misbehaving application
> that is spamming a service with huge amount of transactions.
> 
> The multicast event contains full details of the failed transactions,
> including the sender/target PIDs, payload size and specific error code.
> This interface is defined using a YAML spec, from which the UAPI and
> kernel headers and source are auto-generated.
> 
> Signed-off-by: Li Li <dualli@google.com>
> Signed-off-by: Carlos Llamas <cmllamas@google.com>
> ---
>  Documentation/netlink/specs/binder.yaml     | 96 +++++++++++++++++++++
>  MAINTAINERS                                 |  1 +
>  drivers/android/Kconfig                     |  1 +
>  drivers/android/Makefile                    |  2 +-
>  drivers/android/binder.c                    | 85 +++++++++++++++++-
>  drivers/android/binder_netlink.c            | 32 +++++++
>  drivers/android/binder_netlink.h            | 21 +++++
>  include/uapi/linux/android/binder_netlink.h | 37 ++++++++
>  8 files changed, 270 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/netlink/specs/binder.yaml
>  create mode 100644 drivers/android/binder_netlink.c
>  create mode 100644 drivers/android/binder_netlink.h
>  create mode 100644 include/uapi/linux/android/binder_netlink.h
> 
> diff --git a/Documentation/netlink/specs/binder.yaml b/Documentation/netlink/specs/binder.yaml
> new file mode 100644
> index 000000000000..a2e54aa42448
> --- /dev/null
> +++ b/Documentation/netlink/specs/binder.yaml
> @@ -0,0 +1,96 @@
> +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
> +#
> +# Copyright 2025 Google LLC
> +#
> +---
> +name: binder
> +protocol: genetlink
> +uapi-header: linux/android/binder_netlink.h
> +doc: Binder interface over generic netlink
> +
> +attribute-sets:
> +  -
> +    name: report
> +    doc: |
> +      Attributes included within a transaction failure report. The elements
> +      correspond directly with the specific transaction that failed, along
> +      with the error returned to the sender e.g. BR_DEAD_REPLY.
> +
> +    attributes:
> +      -
> +        name: error
> +        type: u32
> +        doc: The enum binder_driver_return_protocol returned to the sender.
> +      -
> +        name: context
> +        type: string
> +        doc: The binder context where the transaction occurred.
> +      -
> +        name: from_pid
> +        type: u32
> +        doc: The PID of the sender process.
> +      -
> +        name: from_tid
> +        type: u32
> +        doc: The TID of the sender thread.
> +      -
> +        name: to_pid
> +        type: u32
> +        doc: |
> +          The PID of the recipient process. This attribute may not be present
> +          if the target could not be determined.
> +      -
> +        name: to_tid
> +        type: u32
> +        doc: |
> +          The TID of the recipient thread. This attribute may not be present
> +          if the target could not be determined.
> +      -
> +        name: is_reply
> +        type: flag
> +        doc: When present, indicates the failed transaction is a reply.
> +      -
> +        name: flags
> +        type: u32
> +        doc: The bitmask of enum transaction_flags from the transaction.
> +      -
> +        name: code
> +        type: u32
> +        doc: The application-defined code from the transaction.
> +      -
> +        name: data_size
> +        type: u32
> +        doc: The transaction payload size in bytes.
> +
> +operations:
> +  list:
> +    -
> +      name: report
> +      doc: |
> +        A multicast event sent to userspace subscribers to notify them about
> +        binder transaction failures. The generated report provides the full
> +        details of the specific transaction that failed. The intention is for
> +        programs to monitor these events and react to the failures as needed.
> +
> +      attribute-set: report
> +      mcgrp: report
> +      event:
> +        attributes:
> +          - error
> +          - context
> +          - from_pid
> +          - from_tid
> +          - to_pid
> +          - to_tid
> +          - is_reply
> +          - flags
> +          - code
> +          - data_size
> +
> +kernel-family:
> +  headers: ["binder_internal.h"]

Hmm, it seems this header inclusion was left in from patchset v13, where
the 'struct binder_context' needed to be exposed. Not anymore though, so
I'll send out a new version that drops this part.


  reply	other threads:[~2025-07-27 18:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 18:37 [PATCH v19 0/5] " Carlos Llamas
2025-07-25 18:37 ` [PATCH v19 1/5] binder: pre-allocate binder_transaction Carlos Llamas
2025-07-25 18:37 ` [PATCH v19 2/5] binder: add t->is_async and t->is_reply Carlos Llamas
2025-07-25 18:37 ` [PATCH v19 3/5] binder: introduce transaction reports via netlink Carlos Llamas
2025-07-27 18:18   ` Carlos Llamas [this message]
2025-07-25 18:37 ` [PATCH v19 4/5] binder: add transaction_report feature entry Carlos Llamas
2025-07-25 18:37 ` [PATCH v19 5/5] binder: add tracepoint for netlink reports Carlos Llamas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aIZtWGPFCsHdNvq1@google.com \
    --to=cmllamas@google.com \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=brauner@kernel.org \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dualli@google.com \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@kernel.org \
    --cc=joelagnelf@nvidia.com \
    --cc=jstultz@google.com \
    --cc=kernel-team@android.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@android.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shayba@google.com \
    --cc=surenb@google.com \
    --cc=tkjos@android.com \
    --cc=tweek@google.com \
    --cc=ynaffit@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®