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 3F8A83C4544 for ; Sun, 23 Aug 2026 12:47:21 +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=1787489244; cv=none; b=rTn1TeCwOSpdCu3IUNCV4BAYspd5H8Jrq9hI8/qrW8knoF1Vd2wMhHfZFPHSlm4qOBa0CS93+oYpadSOJMXD8ZbpkVVjz3lHnQVgjNJ9lPpmPrh8Y51KilifVWR/cAWUV7cKaS1IjWMSQfER/WVdKjGXa5VgzTyZvVT+rGE9xA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787489244; c=relaxed/simple; bh=HnVeTaAJCv049YmErIdwOO7yAjqWFwj8lHyZlrFP0cE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XoREFnoVNT9TAJv2UCDC5spuFiJte4+jqd1MAqDJuTvE6KSlXHba8Ocimdqno7YME2eTFyaiQB9kDHVTAqrgTawe4Jm0QX19xsWZZCZvv4LrPTGEffaSWQT0Jtj+yiYJxRQ5Oy9l75VmJa+eQTeM7Yr5CgKnG4CtvIDxT54ex2k= 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=h9jcjZGz; 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="h9jcjZGz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787489240; 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=kQdX5N0mKW1fNCAk858oGemhgCXSuAsOshSC8rhOJC0=; b=h9jcjZGzxI8QlInvl4wMQSXa9kMRgdFLMNThm3C4m3mjbGsfS9jcV+hrKVa1Z81Cd5gDFj a7TEjPxmnUoNBMZjnqq9wOvseYwvbQs+CSMxTc6YO2FB0+T6/sL51OPq9mpo1R8AT/9iCY ef6SvyQTm+8US6UzrGFz6aJgcQajqBA= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-213-ztwVacr1NlqGr8rwe_lhZg-1; Sun, 23 Aug 2026 08:47:17 -0400 X-MC-Unique: ztwVacr1NlqGr8rwe_lhZg-1 X-Mimecast-MFC-AGG-ID: ztwVacr1NlqGr8rwe_lhZg_1787489235 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 77F8F1801352; Sun, 23 Aug 2026 12:47:15 +0000 (UTC) Received: from fedora (unknown [10.44.32.9]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id F3B477D9; Sun, 23 Aug 2026 12:47:11 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 23 Aug 2026 14:47:15 +0200 (CEST) Date: Sun, 23 Aug 2026 14:47:10 +0200 From: Oleg Nesterov To: Hyunwoo Kim Cc: frederic@kernel.org, tglx@kernel.org, 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: 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=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 On 08/22, Hyunwoo Kim wrote: > > commit fb3bbcfe344e ("exit: change the release_task() paths to call > flush_sigqueue() lockless") moved the ->pending flush from __exit_signal() > to release_task(), where it runs without ->siglock. The justification was: > > after the exiting task passes __exit_signal() lock_task_sighand() can't > succeed and pid_task(tmr->it_pid) will return NULL > > That second half does not hold for the old group leader in a non-leader > exec(). de_thread() calls exchange_tids() before release_task(leader), so Indeed... Thanks a lot! I need some time to (try to ;) fully understand the problem and your fix... I'll read your patch again tomorrow with a clear head. Now... I hope that the next paragraph This means that after __exit_signal(tsk) nobody can play with tsk->pending or (if group_dead) with tsk->signal->shared_pending, from the changelog is still true, so the only problem is that it is not safe to play with q->list, right? > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -482,7 +482,11 @@ void flush_sigqueue(struct sigpending *queue) > sigemptyset(&queue->signal); > while (!list_empty(&queue->list)) { > q = list_entry(queue->list.next, struct sigqueue , list); > - list_del_init(&q->list); > + /* > + * Pairs with the list_empty() in posixtimer_send_sigqueue(). > + * release_task() gets here without ->siglock. > + */ > + list_del_init_careful(&q->list); > __sigqueue_free(q); Can't we avoid list_del_init() altogether? Can't flush_sigqueue() simply do list_for_each_entry(q, &pending->list, list) __sigqueue_free(q); ? Oleg.