From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 62DC919C546 for ; Thu, 9 Jan 2025 18:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736448725; cv=none; b=MJMGXDO53wZ0h+/PixKyJsCv5dOdGo6VDtTto6+pNsVN1KwHbeDlSr5P8Tx3mjwMqNDFEUOPkqeGyFz/kP8cnY3SO5l4L8BWwJZVKe+OfEZ36NwNv0QFeChjM4J5FYlXPoB4osvQkq6wtQVfAou/8hDeH1MYtps5fKyMXAe3i1s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736448725; c=relaxed/simple; bh=nK0/2Y3vHYxFDzU0fGt9iZboYWU0PmjHEd+H/QwUl+0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=munIkf77dLUMJ34Qv73W+vMgVhoXOd2ed812T2QId8vCWbJkX50QkrafKVvcOWMwbTYoCSd9dDcLhe0Lj+0O9AKM97IrRXqRh2HHjZ8nnLRR0gcLdk7iTgXoNcXzDXChMIAkjTOqdU2FFam97jbYlGBiFaZhDkoli6mW8Aa3mQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ToL8ljCY; arc=none smtp.client-ip=209.85.214.170 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ToL8ljCY" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-215740b7fb8so15585ad.0 for ; Thu, 09 Jan 2025 10:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736448723; x=1737053523; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=oyaoWSwPC0Zu+EGXJyxxL+6bVmHYUqZLMJYfZEnGh1A=; b=ToL8ljCYIlVv2XC5MY+tK0JJ2zU+C6a93orUYxRKqbOmHbdwY5BKWx5DUyvw3HowLR /RFg3eZzAsbJr5iYMXykOlU201pAkQak8vEczM5KGIAFKqxdN8eOD4LSeksg97JYOz9g 1h9Msxotw6iikLNmuPj1dIbXJDJD/dPKIfQBdx4viFefxesJYNY7DbBXSkJc2fXCqHvO ylt7s7LbcwxBKxUoKtNmILb88qRFqBBhkHzYVHp/KXC4vGOMNRgSK8TdXo5xNfFi+Urj Zquu6KTU7xdbGrfeFwa3PLyd4X+UJSXWK3Am/Jn4yFKNWqj1gsfyoR5NxX0pMXwu06In +jJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736448723; x=1737053523; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oyaoWSwPC0Zu+EGXJyxxL+6bVmHYUqZLMJYfZEnGh1A=; b=wvUniHH+FEj7ChCmspYvxn1MVfSj0q7ygSp0WUYVvGoCeJMyFH7koS+hCX4Nv2e7Hm 7M7oBVk6j2jnkRXfR+raJdPgcArngBVTFyQzTwisH4Uu1KfHfVAkWkoZZqQxrk24vgj/ eGL1ELKUxv83h/UEYWkFyqPW7vjMytaOuIxfcGmgRbH8Ouwrew5Rh4ceAwOf4PHrHTzB rZcQpNu+vbJD31bEf53g45eoW5md34xoRBTS8C19XTXMgUngQbMZWALSyNozTDz5vuWL f/D0G6qD00bPWtRT4ndj3CEJEWvcpsJF1qMAJOcFhkupYoi92pcmz3dwLLhItIdsHANd JNGA== X-Forwarded-Encrypted: i=1; AJvYcCUFNRzWxtMMKlHbLsa26sPpYSthjnHIs+j62QE2QjPnrT0k37MobZT6BG5iBsr4vL83ZcEcKYM88idlZ+4=@vger.kernel.org X-Gm-Message-State: AOJu0YyqWjOXnZKDvb9G0HsmcyQ9X7U8qpWS/HBe4fv/LkJ/Z4moAxkC Ow2Zdq1r9vtj4j6prrhO/LBopFm0GZVa2/C2Arw18iljD1z8QUR8edGG/tVdbA== X-Gm-Gg: ASbGncvduj2S335jy89gDSKfhekj1k2IxYYCsTYmBQilr5YHeU6BwEw6+sIv+NbM8+U rBbZpWYCfIyK4Hbfn0Y8gHKQL/CHetOc9WkqnMtuNsLFwlDVZacO8n4OFSax4Hb/bk6zDMfi+Mj G62mnH7dkm49Zd+sDJAhDbWChO8EqXkfNyph4kG1YXi88wDP4IKiTHANz6r/OjyKNhPxXZCC6xC cbMC5kq9zMCjDM8QxX5sic4OonVNUhgOVkrheEbHi/biejkVs7r7Xq1CnvBDGI3HHq/Uo5YAdJn mwsQgLd+BQ3gLxEsP60= X-Google-Smtp-Source: AGHT+IHMmONjzAo9BqIQe7XqdyQWzW64sGl6Iou/pft83SRCuwhvbUokrsleTsR7Z7WKFgogy+MG+Q== X-Received: by 2002:a17:903:3281:b0:216:48d4:b3a8 with SMTP id d9443c01a7336-21aa0821c58mr99825ad.16.1736448723450; Thu, 09 Jan 2025 10:52:03 -0800 (PST) Received: from google.com (57.145.233.35.bc.googleusercontent.com. [35.233.145.57]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f219e44sm1111895ad.120.2025.01.09.10.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 10:52:02 -0800 (PST) Date: Thu, 9 Jan 2025 18:51:59 +0000 From: Carlos Llamas To: Li Li Cc: dualli@google.com, corbet@lwn.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, donald.hunter@gmail.com, gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com, maco@android.com, joel@joelfernandes.org, brauner@kernel.org, surenb@google.com, arnd@arndb.de, masahiroy@kernel.org, bagasdotme@gmail.com, horms@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, hridya@google.com, smoreland@google.com, kernel-team@android.com Subject: Re: [PATCH v11 2/2] binder: report txn errors via generic netlink Message-ID: References: <20241218203740.4081865-1-dualli@chromium.org> <20241218203740.4081865-3-dualli@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jan 07, 2025 at 04:00:39PM -0800, Li Li wrote: > On Tue, Jan 7, 2025 at 1:41 PM Carlos Llamas wrote: > > > > On Tue, Jan 07, 2025 at 09:29:08PM +0000, Carlos Llamas wrote: > > > On Wed, Dec 18, 2024 at 12:37:40PM -0800, Li Li wrote: > > > > From: Li Li > > > > > > > @@ -6137,6 +6264,11 @@ static int binder_release(struct inode *nodp, struct file *filp) > > > > > > > > binder_defer_work(proc, BINDER_DEFERRED_RELEASE); > > > > > > > > + if (proc->pid == proc->context->report_portid) { > > > > + proc->context->report_portid = 0; > > > > + proc->context->report_flags = 0; > > > > > > Isn't ->portid the pid from the netlink report manager? How is this ever > > > going to match a certain proc->pid here? Is this manager supposed to > > > _also_ open a regular binder fd? > > > > > > It seems we are tying the cleanup of the netlink interface to the exit > > > of the regular binder device, correct? This seems unfortunate as using > > > the netlink interface should be independent. > > > > > > I was playing around with this patch with my own PoC and now I'm stuck: > > > root@debian:~# ./binder-netlink > > > ./binder-netlink: nlmsgerr No permission to set flags from 1301: Unknown error -1 > > > > > > Is there a different way to reset the protid? > > > > > > > Furthermore, this seems to be a problem when the report manager exits > > without a binder instance, we still think the report is enabled: > > > > [ 202.821346] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821421] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821304] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821306] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821387] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821464] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821467] binder: Failed to send binder netlink message to 597: -111 > > [ 202.821344] binder: Failed to send binder netlink message to 597: -111 > > [ 202.822513] binder: Failed to send binder netlink message to 597: -111 > > [ 202.822152] binder: Failed to send binder netlink message to 597: -111 > > [ 202.822683] binder: Failed to send binder netlink message to 597: -111 > > [ 202.822629] binder: Failed to send binder netlink message to 597: -111 > > As the file path (linux/drivers/android/binder.c) suggested, > binder driver is designed to work as the essential IPC in the > Android OS, where binder is used by all system and user apps. > > So the binder netlink is designed to be used with binder IPC. > > The manager service also uses the binder interface to communicate > to all other processes. When it exits, the binder file is closed, > where the netlink interface is reset. Did you happen to look into netlink_register_notifier()? That seems like an option to keep the device vs netlink socket interface from mixing up. I believe we could check for NETLINK_URELEASE events and do the cleanup then. I'll do a quick try.