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 5506B3AAF6D for ; Mon, 24 Aug 2026 08:29:06 +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=1787560148; cv=none; b=pCWOX5vvQTh4/OaHdzdi4wrh6T9gu1KV/JVPtJPj1W8vijeHAjh19MJShbAkWwUomP86esziRnjtV961rUmY8jEo6CrHX7RO5u8ZT+Pj11D+U4ZBr8d4nlsjcobsVtcEJ45Ml452SHtmWC7sgPzjsYoV5W/C7ClmsmAJPrZmH0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787560148; c=relaxed/simple; bh=hK4J6t8iabDM+I0PKwvQWys3tqNKBzx6X7B0halAM3w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OSTme2xxCdbsv1Ykh1+aZSliW11frka4lZerA7yj2QIPlXNCfoF/uoi5vbtQfsaLO2FtLHg+Q98frqfpEHXAFZqI9G9s8/5cqZXy2YC3mTn4wjHklV2uVCWRQODNYcooeSONCOhztha3bU4q7hl7g88EmSKbEcsmH14h0i2U8jQ= 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=JuydSeKR; 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="JuydSeKR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787560145; 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=eWX8HPxQNSHDwCFPy1IFa7O4Nz3Ofw57prfrvCuElaA=; b=JuydSeKRPNKl+SaREusCJvej7m4W0qzfl6vroHXVacXLB8IpE6ob+jX1xKsUsA56JHu0fh /1nyNXNA19FVpwE3w8dQyEIvdKb9Hk8ZAoKLhbkphuGjkMEBi4JkAs7vPmsdIZZKl3FX8X C5uxb/Jd5QVOcSYazp473qwrRCEzDYA= 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-16-mOKqO_I5PFqmEWjYyvA31A-1; Mon, 24 Aug 2026 04:29:01 -0400 X-MC-Unique: mOKqO_I5PFqmEWjYyvA31A-1 X-Mimecast-MFC-AGG-ID: mOKqO_I5PFqmEWjYyvA31A_1787560137 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 704951955DCC; Mon, 24 Aug 2026 08:28:57 +0000 (UTC) Received: from fedora (unknown [10.44.32.9]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 0B89A1955F09; Mon, 24 Aug 2026 08:28:53 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 24 Aug 2026 10:28:57 +0200 (CEST) Date: Mon, 24 Aug 2026 10:28:51 +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.0 on 10.30.177.12 On 08/24, Hyunwoo Kim wrote: > > On Sun, Aug 23, 2026 at 02:47:10PM +0200, Oleg Nesterov wrote: > > > > 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); > > > > ? > > __sigqueue_free() does kmem_cache_free() for anything which is not > PREALLOC, so the iterator reads q->list.next after it is freed. Yes, sorry, I meant _safe() of course... > And flush_signals() and selinux_bprm_committed_creds() call it on live > tasks, so the queue has to end up empty. Right, thanks, I forgot that flush_sigqueue() has other callers. > So, > > list_for_each_entry_safe(q, n, &queue->list, list) > __sigqueue_free(q); > INIT_LIST_HEAD(&queue->list); > > If you are fine with it, could you submit this patch yourself? I am also > attaching the reproducer and the mdelay diff. I hope they help. Let me think about it a bit more... And thanks a lot again. Oleg.