From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F29A83FBEA5 for ; Mon, 24 Aug 2026 15:57:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787587052; cv=none; b=YR2Pg9UlodwVVR92QDVQWOu/tCGo3fpDKk0iPSpyaj1mjh3qaVNPqULeJFJxXyjbz4wQsEtGv0c7fw5agbneaTBUoy7pxmqcPpm/PrhFAFWicS4hcfNoUT3WYiLVhdekeT9gh5CMrxjcWPTCZuF+Pp8A+GuKSN55dC5oIuAj+XM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787587052; c=relaxed/simple; bh=WLDiteWIqF3m1z44XJzECGsDTBGJPPLigkS/d7vyfyk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: In-Reply-To:Content-Type:Content-Disposition; b=aTIhlKN1YUrWMl4LRqUbMldRLkAp+7UD6CF0e1OAYuVtMiK2h+ds5W1zV14akiCv6srM2OxBNXsS8cfrduvhE97B+kIfWkXzKtpE/gdlKGv7xtXMiA5OGBSKq8F3jOpH1h+EijSF0ceNsdRLby8ifydtUju/79TA79W7JYOU8ZA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fXbid/uy; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fXbid/uy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787587049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lt6JfU9N3TKmHx8nvPAdDqg71QI5DDY6kggznOpUqRc=; b=fXbid/uyd4y1jUk49ftnHcSSJkuvKfuF755ZbuHTOZFvzGc06bTxfcnBc6wKCaQS4c487R pPf2dkXuFEwVKPSY8rkVqJZeFANgYZrCPxn/at+dLy43kA5xDsF24BOjOPyCtCGzVwPH0b YQRPFlGsAXPQ4YzwvqV+O1HFaeixg6Q= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-Wb4jBxTKMfqBc15vuBl-vA-1; Mon, 24 Aug 2026 11:57:25 -0400 X-MC-Unique: Wb4jBxTKMfqBc15vuBl-vA-1 X-Mimecast-MFC-AGG-ID: Wb4jBxTKMfqBc15vuBl-vA_1787587042 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E2D71977535; Mon, 24 Aug 2026 15:57:22 +0000 (UTC) Received: from fedora (unknown [10.44.32.9]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 3D9CB18005B4; Mon, 24 Aug 2026 15:57:18 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 24 Aug 2026 17:57:22 +0200 (CEST) Date: Mon, 24 Aug 2026 17:57:17 +0200 From: Oleg Nesterov To: Keke Ming Cc: Andrii Nakryiko , Jiri Olsa , Masami Hiramatsu , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH] uprobes: Free utask on dup_return_instance() failure Message-ID: References: <20260822054620.452262-1-ming.jvle@gmail.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-MFC-PROC-ID: CBRTzplkKcqt-gzy2V3txP2ckwhk3hfz57yUGWetHhA_1787587042 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 08/24, Keke Ming wrote: > > On 08/24, Oleg Nesterov wrote: > > > Hmm. It is not that I think "it is not enough", I think this is pointless > > whatever we do. > > Well, I didn't mean to insist on the cleanup, I also think it may > be redundant. If the child is bound to exit, manually calling > uprobe_free_utask(t) in dup_utask() is pointless, as the normal > exit path will handle it. Yes, but the same is true if the child is not bound to exit... IOW, I still can't understand your motivation for this patch... > > But this is only the first step to cleanup > > this logic. I'll try to write another email tomorrow. > > Of course, I'm all ears. You have already mentioned "Option B" below ;) that is what I meant. > Here is my current understanding. One thing I am not sure about > is the signal semantics. If the copied uprobe state is incomplete, > the child should not return to user mode with that state. Perhaps... But consider func_which_can_be_ret_probed(void) { if (!fork) { printf("CHILD\n"); exit(0); } } > Option A: ... > ... > kill_child: > // I was thinking about SIGKILL here because it cannot be ignored > // Of course, you can correct me > send_sig(SIGKILL, t, 1); force_exit_sig(SIGILL) can't be ignored too. But I am fine either way. So yes, perhaps this makes sense. Although IMO this all is not that important; GFP_KERNEL shouldn't fail "in practice" and at least uprobe_copy_process() warns in this case... > Option B: > > > Note that uprobe_copy_process() warns but returns "void", too late > > to abort copy_process(). > > Looking at copy_process(), uprobe_copy_process() is currently called > after the "No more failure paths" point and after the child has already > been made visible through the task list and pid links. > > Would the longer term fix be to move the uprobe state copy earlier, > before the "No more failure paths" point, and then add the needed > bad_fork cleanup for p->utask? Agreed, pronably better than Option A. But in therory dup_xol_work() can still fail after fork(). Oleg.