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 D62F531283E for ; Wed, 24 Sep 2025 15:39:41 +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=1758728383; cv=none; b=bs8CZeSlTI2HZVjqD8Ap8O1k+bpuWLBEDxPtL/iuedzhNCA6sMPtfmXRVIWOk5r55H025AErtkq6Bc2je8aZNhlSHt0ZZac3SWNzTXNXtDBq64x28Az0aHgIRsc8hpFPuZEdqZsFj9vi2lwVDjGZc7epzyV0hpeixSbVEi40ppQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758728383; c=relaxed/simple; bh=v/Cr/IL70HpmLDXq0/COC0G/ZI+89mZIjWnRZv6XJNQ=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=T4mMKME7BW8oPYa118mYJTdeAqbDknLg7KyfBKuG3Q5JPb1+FqqDFv00LpOdVYY1Gff4ab0pDY+D9scAqMYmhdVuvmhOmnmEbOrd3DnE2ke8dKinOzRGxgk6ruyJMcLxUb84qGlyP5ZgIsAso+6kPnxbEu0lALSJHaWehX1wSVY= 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=h9yx0b8N; 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="h9yx0b8N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758728380; 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=VW0CPi1vI6VVLJVg3ytdkJ52tq0kRHmrUbFeTNhR9kk=; b=h9yx0b8N9JqmYZKxpE8ekMm28YHebC9XtlfGc+TGY6RjBNHKZZxU4IpDKlecxG2VnhRiEH 595cUXXkHBtJWCuN3VXRWukXV7UMhDcKiaNlhn6h2O7O8MEaR5Wz6ZsKdSjDOShMIAhbiZ 1ZwOqsXrXWib8JRRMRO9PTebEc3y8QY= 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-472-4lk1vFx3OCKtwoH6h-Rr2A-1; Wed, 24 Sep 2025 11:39:35 -0400 X-MC-Unique: 4lk1vFx3OCKtwoH6h-Rr2A-1 X-Mimecast-MFC-AGG-ID: 4lk1vFx3OCKtwoH6h-Rr2A_1758728374 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 097E318002E0; Wed, 24 Sep 2025 15:39:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.155]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ABDF41800451; Wed, 24 Sep 2025 15:39:29 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <745741.1758727499@warthog.procyon.org.uk> References: <745741.1758727499@warthog.procyon.org.uk> <20250911222501.1417765-1-max.kellermann@ionos.com> To: Max Kellermann Cc: dhowells@redhat.com, Paulo Alcantara , Christian Brauner , netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stable@vger.kernel.org Subject: Re: [PATCH] fs/netfs: fix reference leak 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-ID: <755694.1758728365.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 24 Sep 2025 16:39:26 +0100 Message-ID: <755695.1758728366@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 David Howells wrote: > > ... and frees the allocation (without the "call_rcu" indirection). > = > Unfortunately, this isn't good. The request has already been added to t= he > proc list and is removed in netfs_deinit_request() by netfs_proc_del_rre= q() - > but that means that someone reading /proc/fs/netfs/requests can be looki= ng at > it as you free it. > = > You still need the call_rcu() - or you have to call synchronize_rcu(). > = > I can change netfs_put_failed_request() to do the call_rcu() rather than > mempool_free()/netfs_stat_d(). How about: /* * Free a request (synchronously) that was just allocated but has failed b= efore * it could be submitted. */ void netfs_put_failed_request(struct netfs_io_request *rreq) { int r; /* New requests have two references (see netfs_alloc_request(), and * this function is only allowed on new request objects */ if (!__refcount_sub_and_test(2, &rreq->ref, &r)) WARN_ON_ONCE(1); trace_netfs_rreq_ref(rreq->debug_id, r, netfs_rreq_trace_put_failed); netfs_free_request(&rreq->cleanup_work); } David