From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EF14E43305A for ; Mon, 24 Aug 2026 13:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787579993; cv=none; b=Sd0CcW9kFFA61EgNeIm/5OHdOx/HMgwbGi+gaAn8lpoi7FrslpkIllGeVl7oKjv4TiA5TzFO/1OxG2o7spmoAU8cMv2rr2uHr7ufQ/rdMWnsyz1L32/Oy6RXG8eDCmk8b+qAvCgXCmRGSTghEDARIEIsP49hWqqJisPEBn3/EJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787579993; c=relaxed/simple; bh=wOoPHCy4TMeZJqw70QmLT2aBBdb6ApErNDEiqPVgbok=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iP7DVlCOF71XtTWmfU1lCdqoh12WKOrUC7iIXdetryfvEIZr5sHuWglpHVJmlIzI42b2QC9BPGB8i28Xz34csV/A4PjqrQk5xWTrju4fsb2ioaHt0utC6bZekQhLOQAGGTdyFCE8OTFxGdtPLSxz7UIdv+amTx5BY26bDUXZNCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IPDhqowa; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IPDhqowa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 249FF1F00A3A; Mon, 24 Aug 2026 13:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787579991; bh=rcFSXY/PcZNAVFGdOwxDVJukT9TY2UgP2DT8TBQbRUk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=IPDhqowaZWplWwMmm+Ag6aIzrZxYUdCHzuUsL8Y1HgF30floaYzl1DSzDm+MjVdYX SJyfU2WlW6K1AxNUIZDHqGEldPl2XAMmXJGdKiHTsMQC/Pj33+e8BT72+33kmerMFV YkeO/QBQK7kO8gzEQgZEsMflNg+5cTcbJfqjLyGwC6lecsZ/9uWPskzlC2GW7uzYop j0SrPP7YVZDgkdC0u9jwZr+t3nkI2ND7QPe+KZw50HTOOTyN+YD2ZyIJjPCOFtpDb4 ppWzquiQtoYVzCZgTfXSgOKGy80HNEcu2ooaZWqwoTGwgshUPcP7SWXzYy9Q2qy9Zf fni53mrq8GZUw== Date: Mon, 24 Aug 2026 15:59:48 +0200 From: Frederic Weisbecker To: Oleg Nesterov Cc: Thomas Gleixner , 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> 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: Le Mon, Aug 24, 2026 at 01:54:26PM +0200, Oleg Nesterov a écrit : > On 08/24, Oleg Nesterov wrote: > > > > On 08/24, Thomas Gleixner wrote: > > > > > > --- a/fs/exec.c > > > +++ b/fs/exec.c > > > @@ -983,6 +983,18 @@ static int de_thread(struct task_struct > > > } > > > > > > /* > > > + * Ensure that POSIX timer SIGEV_THREAD_ID signals pending for > > > + * the former leader are removed under sighand::siglock _before_ > > > + * taking over the leader's TID. Otherwise the lockless cleanup > > > + * in release_task() can race against a concurrent signal > > > + * delivery to the new leader. The former leader has PF_EXITING > > > + * set which prevents queueing of SIGEV_THREAD_ID signals up to > > > + * the point where it's sighand gets cleared. > > > + */ > > > + scoped_guard(spinlock_irq, lock) > > > + flush_sigqueue(&leader->pending); > > scoped_guard(spinlock_irq) is not right. This needs scoped_guard(spinlock), > the code runs with irqs disabled. > > > 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? > release_task(leader); Thanks. -- Frederic Weisbecker SUSE Labs