From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4518E329E5D for ; Sat, 4 Jul 2026 21:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783199696; cv=none; b=YfiSncpp6/hFMsl/avUuJfov4eflBWcdCFPvBf947yN2SSAxSWYg5r76NjPgpEbH+5jEhwSdaa+MWOhvTfm0ZEWHP+oOrlPhF4oTY0dWxSJklTdWwg72Y69ZvXgPo7mEwMQAX2lv9KT6YTnjpomKfk32ZNzRHQjGDKXYtn95WU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783199696; c=relaxed/simple; bh=BSHR4ttVlfM/MI9YFove/Sa1l0bWTaHQI2IpkAs5frA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OJTqKU4XE+F8NX0DFnrq/JFRs7sChQfebE8gdHB9zYdLFeewd/1cXX1uqoGQMom2MjfYj0dsl2vbK9n7FIsZo79OTJsbNwFjArGFG5zwXHAzTEpxpsHDIn1NgmA3gtcDTpDpbazPSJuBwVz6fPp3+uYl/6wlQHOol/6azTOgPys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=u3hHohta; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u3hHohta" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-493ae2a6a72so13509365e9.0 for ; Sat, 04 Jul 2026 14:14:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783199694; x=1783804494; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=g+w9JsyReqy5NRh0OObX9dETSAh/Qjwi6VUEXnAmr9Y=; b=u3hHohta/koNpckKjEWeqMMJKxj8liCd4pckWDjYB4ipjupe/XTBG4dXaGImr0Vz4m BXXIFU7uYB6qtFEp/UdpPfm1QXIyEQT8x+WgxBhF3YWHr5EFa8xAeHDeGHn1bS4mWn+s +tdNd1IKg3tRw1D5caZ8HH0L0NjKyzOL0roXu4mNd4JALfUGQyOobZ56GiX1mPNMPgEt sOk66Ju/Ef7OQm0jOR3rbEIIo0WfybJ2iLWDm2Q9AXYgoBFszcXLpZHXPV9kpuDMb20i prbNw9sXvET1sOxNZohOYpAKRgvQQkJoBHk7POJyQv63DBthSOZq6msy0uRbQnh99pZc aIYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783199694; x=1783804494; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g+w9JsyReqy5NRh0OObX9dETSAh/Qjwi6VUEXnAmr9Y=; b=eLUNb8Q88fwztYLlHTTTlg0EoIHm/I8OL3pCW+6rGNpssdFtwGEvjiUgWvs5UYO9Zg KVt6Ff1yvZtSghNFQnPqWMTxMQeEAXg2NbWeUbZAH2BEVnbBSq5vimpYdvNa8LdVkJIU OnxSpqgxTWWSsQNRtkAh4EpY/vGn0hFm7YbK2H2irAZaFKIaDu7n4z1wD5nWpOioRBPA Sqp4YSgp02FEsL5C9cdTQ2E3NovrLSjU2KjFa2pl0SYPz+k0VXCT7ZH+Z0zPAliVDtgR u1TIi5fr/7DotAlk30TmGqeZO1QlORMPWItlIFgesyn44uOHILOjsX5cj9xHDa1xE38P KlmA== X-Forwarded-Encrypted: i=1; AFNElJ+rOUBItudaYI2GXJT6UjhGdYW9/UYhvPqzhIhBeMH+SQUqiknhHVRBxGvifFuoEW6bDLgg0iFvgCZPGGA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxh7sWIUmuMp7h7FgNrfDwhpDlU6YUt5hwHAYEs6Q/ZaeCwOnOv wJlok8sfOPAAPfLd4syWUjlj9oBt66XAgbl0iairA02KBeV3jMDHcjK8vauP7qlovaf9ZcuSKTv WCAvFfPDhu2zOof4Uzw== X-Received: from wmsl10.prod.google.com ([2002:a05:600c:1d0a:b0:493:bea4:1b1f]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a01:b0:493:a7bc:5bcf with SMTP id 5b1f17b1804b1-493d11f033cmr48987025e9.24.1783199693501; Sat, 04 Jul 2026 14:14:53 -0700 (PDT) Date: Sat, 4 Jul 2026 21:14:52 +0000 In-Reply-To: <20260703-rust_binder_debug_mask-v1-3-9bdf12b5325c@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260703-rust_binder_debug_mask-v1-0-9bdf12b5325c@google.com> <20260703-rust_binder_debug_mask-v1-3-9bdf12b5325c@google.com> Message-ID: Subject: Re: [PATCH 3/7] rust_binder: Implement the BINDER_DEBUG_USER_ERROR logging mask for reference counting and death notification operations From: Alice Ryhl To: Jahnavi MN Cc: Greg Kroah-Hartman , "Arve =?utf-8?B?SGrDuG5uZXbDpWc=?=" , Todd Kjos , Christian Brauner , Carlos Llamas , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , "Onur =?utf-8?B?w5Z6a2Fu?=" , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Jul 03, 2026 at 03:29:24PM +0000, Jahnavi MN wrote: > This adds dynamic debug logs for: > - Decrementing handle reference counts that are already zero. > - Mismatched reference states (calling inc_ref_done with no active > inc_refs, or using a weak reference as a strong reference). > - Requesting or clearing death notifications on invalid references, > already active notifications, or with mismatched cookies. > > Signed-off-by: Jahnavi MN The commit title is pretty long. Could we shorten it? For example: rust_binder: use BINDER_DEBUG_USER_ERROR mask for refcount errors > *count += 1; > } else { > if *count == 0 { > - pr_warn!( > - "pid {} performed invalid decrement on ref\n", > - kernel::current!().pid() > + binder_debug!( > + crate::debug::BINDER_DEBUG_USER_ERROR, > + "performed invalid decrement on ref (strong: {})", > + strong Instead of printing (strong: true) or (strong: false), I think it would be nicer to print strong or weak directly in the text: binder_debug!( crate::debug::BINDER_DEBUG_USER_ERROR, "performed invalid {} decrement on ref", if strong { "strong" } else { "weak" } > pub(crate) fn get_transaction_node(&self, handle: u32) -> BinderResult { > - if handle == 0 { > - Ok(self.ctx.get_manager_node(true)?) > + // When handle is zero, try to get the context manager. > + let res = if handle == 0 { > + self.ctx.get_manager_node(true) > } else { > - Ok(self.get_node_from_handle(handle, true)?) > + self.get_node_from_handle(handle, true).map_err(Into::into) > + }; > + > + match res { > + Ok(node_ref) => Ok(node_ref), > + Err(err) => { > + binder_debug!( > + crate::debug::BINDER_DEBUG_USER_ERROR, > + "got transaction to invalid handle {}", > + handle > + ); > + Err(err) > + } This is probably only a user error if `handle != 0`. The application has no way of knowing the context manager is dead, so that case isn't a bug in the application. So I think we can move this println inside the else {} block. > @@ -1268,17 +1291,27 @@ pub(crate) fn clear_death(&self, reader: &mut UserSliceReader, thread: &Thread) > > let mut refs = self.node_refs.lock(); > let Some(info) = refs.by_handle.get_mut(&handle) else { > - pr_warn!("BC_CLEAR_DEATH_NOTIFICATION invalid ref {handle}\n"); > + binder_debug!( > + crate::debug::BINDER_DEBUG_USER_ERROR, > + "BC_CLEAR_DEATH_NOTIFICATION invalid ref {}", > + handle > + ); Does the {handle} syntax that the println is currently using work here? If not, then I think we should try to get it working. Alice