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.129.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 F097F3B4EA3 for ; Tue, 25 Aug 2026 18:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787684040; cv=none; b=jpIS/jrT+EBUEfsicMJ8Rs4c9R0E6C8qAgNEtR5Qp0GmjKu3QW0FalS5q0+5FGirPnLregbnLOgbw+gCnNs2712idve2/EngOP9ZtIz4Ff+6RQzecM98J3HcmkE8ejg/qSJx/hk8Jr0JEbWiL+hKLdLpQ1tRuesYv7hZ5PBzHI4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787684040; c=relaxed/simple; bh=5N1i4xCFo2ddFTSemkNxQgkpYcvgy40t3h6mJfjip/k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O7Cn5g7s96eko2Qrd0RnqGFHGR4uUzks0oG7h7TLIb5UDtH48B2Bzq6w+z12DA86WndLJFtxdkm3mA6oTbrjc8wmfYIvIvR3Z8OooxH1EKa0ixVQ5CTaLYSkqOq9WqOq78NfKWvvoMqDn/jJDfWcPXK8Hq1CLa37Z87C1PTpRvs= 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=YU+CTLRa; arc=none smtp.client-ip=170.10.129.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="YU+CTLRa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787684036; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2LcLr2HpmgYKjhk8/KPd6S7CN5GmD4B+vdeKUZ8NEGw=; b=YU+CTLRa/IpTse8P4VdrQOLPGTFA9BKEhy0/G15NVBCYPXdhF9bSVvvFm+QtWX4ZZosex9 0Xu/7vfYO0DX79CkFGIsTSK5kzpk4Unk6PBqEG3gIwwLTS2OpxWEVS31KlJbmMLvP9PsPj mGDyZFHNNP7uAGkqUjA9/8DHRAcCmVs= Received: from mx-prod-mc-03.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-101-5tkzFxdpMImcnfsPx3EoAQ-1; Tue, 25 Aug 2026 14:53:49 -0400 X-MC-Unique: 5tkzFxdpMImcnfsPx3EoAQ-1 X-Mimecast-MFC-AGG-ID: 5tkzFxdpMImcnfsPx3EoAQ_1787684028 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A79AE19774D5; Tue, 25 Aug 2026 18:53:47 +0000 (UTC) Received: from fedora (unknown [10.44.32.9]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id B0E1B1800765; Tue, 25 Aug 2026 18:53:44 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 25 Aug 2026 20:53:47 +0200 (CEST) Date: Tue, 25 Aug 2026 20:53:43 +0200 From: Oleg Nesterov To: Thomas Gleixner Cc: Frederic Weisbecker , Hyunwoo Kim , brauner@kernel.org, peterz@infradead.org, anna-maria@linutronix.de, ebiederm@xmission.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] signal: Use list_del_init_careful() in flush_sigqueue() Message-ID: References: <875x10hrkt.ffs@fw13> <8733w3j1i1.ffs@fw13> <87pkz6gms6.ffs@fw13> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87pkz6gms6.ffs@fw13> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 On 08/25, Thomas Gleixner wrote: > > On Mon, Aug 24 2026 at 15:59, Frederic Weisbecker wrote: > > Le Mon, Aug 24, 2026 at 01:54:26PM +0200, Oleg Nesterov a écrit : > >> > Hmm, at first glance... If we change de_thread() to do this _after_ transfer_pid's > >> > (before release_task(leader)), then posixtimer_send_sigqueue() doesn't need any > >> > changes, no? > >> > >> IOW. Unless I am totally confused, we only need to flush the > >> SIGQUEUE_PREALLOC sigqueue's which were sent to the (old) leader > >> before it changed its pid. So we can do this > >> > >> diff --git a/fs/exec.c b/fs/exec.c > >> index a14f28b15607..550367e7fe6c 100644 > >> --- a/fs/exec.c > >> +++ b/fs/exec.c > >> @@ -1029,6 +1029,9 @@ static int de_thread(struct task_struct *tsk) > >> write_unlock_irq(&tasklist_lock); > >> cgroup_threadgroup_change_end(tsk); > >> > >> + scoped_guard(spinlock_irq, lock) > >> + flush_sigqueue(&leader->pending); > >> + > > > > Is there something to prevent the timer from firing on another CPU, > > racing with this tiny window and queue the signal to the old leader? After > > all exchange_tids() is just some RCU pointers changed but there is nothing > > to synchronize the readers before the flush_sigqueue(). So pid_task() may > > still return the old leader after it? > > You beat me to it. > > That's what I initialy thought when I added that exiting check into > posixtimer_send_queue(), but then the trivial variant lured me away. :) I'm afraid I am wrong again... but if change posixtimer_send_sigqueue() to check !PF_EXITING, de_thread() still can do flush_sigqueue() after exchange_tids() outside of tasklist_lock? And I'd suggest to check t->exit_state instead of PF_EXITING, posixtimer_send_sigqueue() can't miss it if it is called after scoped_guard(spinlock_irq, lock). Oleg.