linux/drivers/android/binder/netlink.rs
Linus Torvalds 93e4b3076b Char/Misc/IIO/etc driver update for 7.3-rc1
Here is the big set of char, misc, iio, counter, fpga, and other small
 driver subsystems for 7.3-rc1.
 
 Overall, due to some driver removals we only added a bit more code than
 removed, which was a nice change.  Highlights in this merge request are:
   - Loads of IIO driver updates and additions
   - binder driver updates (more on that below...)
   - Removal of the SGI XP and GRU drivers as they are not used anymore
     and turn out to be pretty insecure overall
   - Removal of the obsolete ibmasm driver as it's not being used anymore
   - Coresight driver updates and additions
   - Mei driver udpates
   - Counter driver updates
   - FPGA driver updates
   - ICC driver updates
   - lots and lots of other tiny driver updates to resolve reported
     issues
 
 All of these have been in linux-next for a while, with the only reported
 issues being some major merge conflicts.  Miguel pointed out some of
 these with the Rust tree merge, which is the majority of them.  I'll
 follow up with a diffstat of the merge resolution I made against your
 most recent tree, which works for me.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCao143A8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymtUgCeKB62gT1JfA86cg3NDB1opp+10N0An3oBBegQ
 IJLqJgK45dTNtMGBwGFV
 =68af
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc/IIO/etc driver updates from Greg KH:
 "Here is the big set of char, misc, iio, counter, fpga, and other small
  driver subsystems for 7.3-rc1.

  Overall, due to some driver removals we only added a bit more code
  than removed, which was a nice change. Highlights in this merge
  request are:

   - Loads of IIO driver updates and additions

   - binder driver updates (more on that below...)

   - Removal of the SGI XP and GRU drivers as they are not used anymore
     and turn out to be pretty insecure overall

   - Removal of the obsolete ibmasm driver as it's not being used
     anymore

   - Coresight driver updates and additions

   - Mei driver udpates

   - Counter driver updates

   - FPGA driver updates

   - ICC driver updates

   - lots and lots of other tiny driver updates to resolve reported
     issues

  All of these have been in linux-next for a while"

* tag 'char-misc-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (513 commits)
  iio: chemical: atlas-sensor: use iio_trigger_poll_nested() to fix remove UAF
  iio: adc: pac1921: fix wrong channel used in trigger handler read
  iio: light: gp2ap002: re-enable irq if runtime suspend fails
  iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes
  iio: light: apds9306: fix PM reference leak in apds9306_read_data()
  iio: gyro: mpu3050: fix sign of raw angular velocity readings
  iio: srf04: fix pm_runtime handling on probe error path
  iio: adc: ad4080: configure backend data size
  iio: adc: adi-axi-adc: add data size support for AD408X backend
  iio: chemical: atlas-sensor: fix PM reference leak in buffer postenable
  iio: dac: ad5446: fix OF module device table
  iio: light: opt4001: Fix reversed GENMASK() arguments in fault count mask
  iio: light: opt4001: Reject integration times with a non-zero seconds part
  iio: light: opt4001: Fix incompatible pointer type passed to div_u64_rem()
  iio: light: opt4001: Fix power down clearing bits of the wrong register
  iio: light: opt4060: Fix incorrect register name in threshold read error message
  iio: light: opt4060: Fix pointer type passed to div_u64_rem()
  iio: light: opt4060: Reject integration times with a non-zero seconds part
  iio: light: ltrf216a: fix runtime PM reference leak in error path
  iio: pressure: dps310: fix NULL pointer dereference on ACPI probe
  ...
2026-08-25 09:38:50 -07:00

118 lines
4.4 KiB
Rust

// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
/* Based on: Documentation/netlink/specs/binder.yaml */
#![allow(unreachable_pub, clippy::wrong_self_convention)]
use kernel::{
net::netlink::{
Family,
GenlMsg,
MulticastGroup,
NetlinkSkBuff, //
},
prelude::*, //
};
pub static BINDER_NL_FAMILY: Family = Family::const_new(
kernel::module::this_module::<crate::LocalModule>(),
kernel::uapi::BINDER_FAMILY_NAME,
kernel::uapi::BINDER_FAMILY_VERSION,
&BINDER_NL_FAMILY_MCGRPS,
);
static BINDER_NL_FAMILY_MCGRPS: [MulticastGroup; 1] = [MulticastGroup::const_new(c"report")];
/// 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.
pub struct Report {
skb: GenlMsg,
}
impl Report {
/// Create a new multicast message.
pub fn new(
size: usize,
portid: u32,
seq: u32,
flags: kernel::alloc::Flags,
) -> Result<Self, kernel::alloc::AllocError> {
const BINDER_CMD_REPORT: u8 = kernel::uapi::BINDER_CMD_REPORT as u8;
let skb = NetlinkSkBuff::new(size, flags)?;
let skb = skb.genlmsg_put(portid, seq, &BINDER_NL_FAMILY, BINDER_CMD_REPORT)?;
Ok(Self { skb })
}
/// Broadcast this message.
pub fn multicast(self, portid: u32, flags: kernel::alloc::Flags) -> Result {
self.skb.multicast(&BINDER_NL_FAMILY, portid, 0, flags)
}
/// Check if this message type has listeners.
pub fn has_listeners() -> bool {
BINDER_NL_FAMILY.has_listeners(0)
}
/// The enum binder_driver_return_protocol returned to the sender.
pub fn error(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_ERROR: c_int = kernel::uapi::BINDER_A_REPORT_ERROR as c_int;
self.skb.put_u32(BINDER_A_REPORT_ERROR, val)
}
/// The binder context where the transaction occurred.
pub fn context(&mut self, val: &CStr) -> Result {
const BINDER_A_REPORT_CONTEXT: c_int = kernel::uapi::BINDER_A_REPORT_CONTEXT as c_int;
self.skb.put_string(BINDER_A_REPORT_CONTEXT, val)
}
/// The PID of the sender process.
pub fn from_pid(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_FROM_PID: c_int = kernel::uapi::BINDER_A_REPORT_FROM_PID as c_int;
self.skb.put_u32(BINDER_A_REPORT_FROM_PID, val)
}
/// The TID of the sender thread.
pub fn from_tid(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_FROM_TID: c_int = kernel::uapi::BINDER_A_REPORT_FROM_TID as c_int;
self.skb.put_u32(BINDER_A_REPORT_FROM_TID, val)
}
/// The PID of the recipient process. This attribute may not be present
/// if the target could not be determined.
pub fn to_pid(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_TO_PID: c_int = kernel::uapi::BINDER_A_REPORT_TO_PID as c_int;
self.skb.put_u32(BINDER_A_REPORT_TO_PID, val)
}
/// The TID of the recipient thread. This attribute may not be present
/// if the target could not be determined.
pub fn to_tid(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_TO_TID: c_int = kernel::uapi::BINDER_A_REPORT_TO_TID as c_int;
self.skb.put_u32(BINDER_A_REPORT_TO_TID, val)
}
/// When present, indicates the failed transaction is a reply.
pub fn is_reply(&mut self) -> Result {
const BINDER_A_REPORT_IS_REPLY: c_int = kernel::uapi::BINDER_A_REPORT_IS_REPLY as c_int;
self.skb.put_flag(BINDER_A_REPORT_IS_REPLY)
}
/// The bitmask of enum transaction_flags from the transaction.
pub fn flags(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_FLAGS: c_int = kernel::uapi::BINDER_A_REPORT_FLAGS as c_int;
self.skb.put_u32(BINDER_A_REPORT_FLAGS, val)
}
/// The application-defined code from the transaction.
pub fn code(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_CODE: c_int = kernel::uapi::BINDER_A_REPORT_CODE as c_int;
self.skb.put_u32(BINDER_A_REPORT_CODE, val)
}
/// The transaction payload size in bytes.
pub fn data_size(&mut self, val: u32) -> Result {
const BINDER_A_REPORT_DATA_SIZE: c_int = kernel::uapi::BINDER_A_REPORT_DATA_SIZE as c_int;
self.skb.put_u32(BINDER_A_REPORT_DATA_SIZE, val)
}
}