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 3CA5A42377F for ; Sun, 4 Oct 2026 11:31:46 +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=1791113508; cv=none; b=qGTmq4rJoB0NnaVABZPjkf0YTePtGM05VnRNSfGrQBkL/8S0VYdNH/CO6ySJtrP+Z0Y9nUgM/IUUmF8Ozbf+SWhd0bDl0tU61ghowxeIHVLNXhR+JpUq/lCbbCQT4h6fLiiA/+DG3Hc2kQWdnf+G4hRgDFgIKYGzPBdfvjK9/UA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791113508; c=relaxed/simple; bh=aUgxd9TA7WMOVTILaCBJsOIAFwv3UxVoD9m4EUHKiXY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z/1HDJLtC/CiqtrYlyaecgRZ9B0PNviJJ5GMdxSm2TsB7FqezdUXbgnbupWNBdhcXU7ujX5bDCtvRvKLG3M2sidt/u/NxbbL6tmpuDb1EcTpOLnHphLc9QLv9p2pjJ6JyIepG9wgqazsG7NnPO+GLcdmfQUQ/aCocXHzbMDl2LY= 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=TiezjxQb; 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="TiezjxQb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1791113506; 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=mkxXo9AfDcNdhvbdcD3GjIhYv53nYGA82heubJlRsjg=; b=TiezjxQb7D62WbUy9rVlvC5EpCIhFKmHvF1YO+ax1dSGEblIgM81yOqn5qc8XqhY/XhCxD 9YsPpv0CzUZUvBujxKPb7Oy/X7mdddhNdsOW3+Do2a88tMgXUGuTW9eFZ4lN50f11bmmCd 3f0D8lMGmX0U3GkdvL1epEPWMA0qH4M= Received: from mx-prod-mc-06.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-587-CqjACYORMk6L8s_JE9t3cQ-1; Sun, 04 Oct 2026 07:31:40 -0400 X-MC-Unique: CqjACYORMk6L8s_JE9t3cQ-1 X-Mimecast-MFC-AGG-ID: CqjACYORMk6L8s_JE9t3cQ_1791113499 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C45CF18413AD; Sun, 4 Oct 2026 11:31:38 +0000 (UTC) Received: from onestero-thinkpadp1gen7.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 890C7180049F; Sun, 4 Oct 2026 11:31:35 +0000 (UTC) Received: by onestero-thinkpadp1gen7.tpbc.csb (nbSMTP-1.00) for uid 13628 oleg@redhat.com; Sun, 4 Oct 2026 13:31:38 +0200 (CEST) Date: Sun, 4 Oct 2026 13:31:34 +0200 From: Oleg Nesterov To: w15303746062@163.com, David Laight Cc: jlayton@kernel.org, chuck.lever@oracle.com, viro@zeniv.linux.org.uk, brauner@kernel.org, alex.aring@gmail.com, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Mingyu Wang <25181214217@stu.xidian.edu.cn> Subject: Re: [PATCH v2] fs/fcntl: fix SOFTIRQ-unsafe lock order in fasync signaling Message-ID: References: <20260523135210.590928-1-w15303746062@163.com> 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: <20260523135210.590928-1-w15303746062@163.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Hi, On 05/23, w15303746062@163.com wrote: > > Since PID hashing and do_each_pid_task() traversals are already > RCU-protected, the read_lock on tasklist_lock is no longer strictly > required for safe traversal. Fix this by replacing tasklist_lock with > rcu_read_lock(), I don't think we can simply avoid tasklist_lock. Let me quote my old email, do_each_pid_task(PIDTYPE_PGID) can race with change_pid(PIDTYPE_PGID) which moves the task from one hlist to another. Yes, it is safe in that task_struct can't go away. But still this is not right because do_each_pid_task() can scan the wrong (2nd) hlist. And... I need to recheck, but perhaps signal_struct->multiprocess logic is another reason why the lockless do_each_pid_task() is wrong... See also the recent discussion https://lore.kernel.org/all/20261003182224.2171b574@pumpkin/ Oleg. > --- a/fs/fcntl.c > +++ b/fs/fcntl.c > @@ -929,11 +929,11 @@ void send_sigio(struct fown_struct *fown, int fd, int band) > send_sigio_to_task(p, fown, fd, band, type); > rcu_read_unlock(); > } else { > - read_lock(&tasklist_lock); > + rcu_read_lock(); > do_each_pid_task(pid, type, p) { > send_sigio_to_task(p, fown, fd, band, type); > } while_each_pid_task(pid, type, p); > - read_unlock(&tasklist_lock); > + rcu_read_unlock(); > } > out_unlock_fown: > read_unlock_irqrestore(&fown->lock, flags); > @@ -975,11 +975,11 @@ int send_sigurg(struct file *file) > send_sigurg_to_task(p, fown, type); > rcu_read_unlock(); > } else { > - read_lock(&tasklist_lock); > + rcu_read_lock(); > do_each_pid_task(pid, type, p) { > send_sigurg_to_task(p, fown, type); > } while_each_pid_task(pid, type, p); > - read_unlock(&tasklist_lock); > + rcu_read_unlock(); > } > out_unlock_fown: > read_unlock_irqrestore(&fown->lock, flags); > -- > 2.34.1 >