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 3C5A03BB9F8 for ; Thu, 30 Jul 2026 09:55:47 +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=1785405348; cv=none; b=nT+swxY+oTcYDmJlEipWoyEwW6GLCZN5BGAHgdl4cmKMt/X4/dO7ZD9cfXFbVTCknIN7dVCeW6VI0y5b4OAD/x4ppyqQvtNp8Z7reqa36GU8NHyAHkY0Jrt0ZO3EZhxnkq31TnhTVQgjKQsVmJt5eyqaDMeaX/q684RDy0pP3F8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785405348; c=relaxed/simple; bh=B3SEkQ/hEbP5sv+W3Wk37AU3WK2ejG3sDo4XZLp4wFg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rqhJ1NCvfe6DICzgHV3wztsJ3cXQeobMJa3MLOavHc9fIMFQRDeqIgsfNvjp1UJ2WCZM7PYbNwreVAjapqi8whMnhTvxbIC/R3J6g1bmOCO8gqX2jNBy5T9502m/ovox9ABwESR3W/cfb0ZPF5Loyq+btWDLyBhs1ImyQhDkwPc= 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=Y39Jikgq; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=HxxO12eZ; 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="Y39Jikgq"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="HxxO12eZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785405346; 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=7Lz8IBXystSHPMs3Dd2XtqjCRsgWgqnaNeE680bLV7o=; b=Y39JikgqpcBOWGDQ7Tf5x3PpoSWeeayI/s0T1GxiIsXefy5nqvP95I0pyTQUT0TTtwoB4u xFQmC5p1vyEMLzp4aoQsXLtYs2W9KxjEwh3JN1UQIoRKOFRXoJyTr8Bk5WvW5nzxjQwZNS GOntEnH8srEW6xcRgHxH4x7ZbUVGxlg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-NeDfKx3ENPCn1oqnvC1KqQ-1; Thu, 30 Jul 2026 05:55:43 -0400 X-MC-Unique: NeDfKx3ENPCn1oqnvC1KqQ-1 X-Mimecast-MFC-AGG-ID: NeDfKx3ENPCn1oqnvC1KqQ_1785405343 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4955843c6cdso20370385e9.1 for ; Thu, 30 Jul 2026 02:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1785405342; x=1786010142; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=7Lz8IBXystSHPMs3Dd2XtqjCRsgWgqnaNeE680bLV7o=; b=HxxO12eZ0OpTyA6R2c6e8bK/fWbFfLhVgrrcUzif0tqtPEkAQjbXYCrCHKL6VQY07x z3nwnSSSIoF7tHE4ePm563RZpqeHiv2CCs0YN5sAvEyuKdt0x07eSCnXW7Mok3h52Tcx npxVhru08PR9A70VvLQmL+th8dtlMQFg1eyCm1h7Cx3myLwpA5e4lAsVWYBPVi4NcflE gd0x2VATBjM/PjGXWt3upemwWigWLCIdNfim146JAYJbJyBs0SEjkuRpm3bYjI0HisJF UpYTp7oPrZ95BemLcnE7Cw7gpDt9WPlKUxlWNmZks1kuFsYfmSHNnS1shjKXCR13i1EE UVRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785405342; x=1786010142; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7Lz8IBXystSHPMs3Dd2XtqjCRsgWgqnaNeE680bLV7o=; b=cX1CSvboz9cHoV9W5P+5xYw9xtuZo7Dv/wjCB6LgZbePNPAGmuLdiO7/0K6pzPM6EX GAR6tI5svpq5UK0RjCNZxiRVZ+zg5Ky4d93RXKbPoTcu6lZjGj2weeFEecr5gEl58zTC mMXuEiht+Y/aqMai6qh4ldYPw5cFO8Of+P1XjgcI/eqyEggkpJCJjTi/ODq6DrrWJwQ0 9VUM5upld6GosHmDudXKLXtJ8MK2TS5wIekXCjcx25zm4eeDI+Kf7CTKOfKQVNl7CGmu JfDz99t7IYeQuRImfuMjwmuXg0nvUeNJ3BEIFJER+SQTaGmoay5et2iukcUeZjFEGhKL eMLQ== X-Forwarded-Encrypted: i=1; AHgh+Rof9Sa69LpU9tflTsAZ8sdlv2Fcv5aX+ScIytDp8zoZpwbC0yHa6b8sbxsB3P8VQtCbek4nqBJ1DDD2II0=@vger.kernel.org X-Gm-Message-State: AOJu0YyYl2VBXvS0SSewRBQDRvoLGlVokVyI2qMSj5EHnd1DVLPyyi/O j5cdhsPdeVJsvS50lJnyaY+tDNyGf07HqSunRdB4XjDJatG29LjeAGb7+Hal+jlORDVYtDEcsvc ARgeKPJzkCNpmgiwo8G2mDiJ7l6aWfyFEFKUMUh5HkuGQdjz/cAQDXLYXzftgC63q9g== X-Gm-Gg: AR+sD123gKpeOGilCzVRQvLZVbY5ZzcJM8Walm8Zwz3W2LsjfQJZa79tJAMbQaGYFEt f1u89dESphljZizuCz4+XN81Rl2de4F237BQ127KqJWJ56h3zxQnOH5i2SOQ0girm9iZqR0hSE2 rpER5hhtPkS59bifMhzXx3ubVAc7LI8NPUW5dSsCmHoGIyAVgp3FlU+uujy7CkP6WcstM0hP+An K+qQ20sVprtQdmKbRy+t2q5eIOMhuft8krszgS8aLKlZd3bUZXzji94lH+KO/CdTYw2Q7Mpvw31 gO8IvH8klMcgP4q75uYPa30PMKHkmkpHjwbtrg8c2gZdtQqzvL4zt7RcB5g6+677J9Xbn9wPZYk Sl5rJ2wne8foCiHNwsleloKjppUNjLj4awfe3CDFnpTciyYomKEDJ9c/FHhpA1N0QC3nEZNVf7l zJEA== X-Received: by 2002:a05:600c:a44:b0:495:3c6d:f294 with SMTP id 5b1f17b1804b1-49800ea1a08mr26153245e9.23.1785405342473; Thu, 30 Jul 2026 02:55:42 -0700 (PDT) X-Received: by 2002:a05:600c:a44:b0:495:3c6d:f294 with SMTP id 5b1f17b1804b1-49800ea1a08mr26152705e9.23.1785405342026; Thu, 30 Jul 2026 02:55:42 -0700 (PDT) Received: from ?IPV6:2a0d:3344:5521:6b10:58fd:68f:7756:389d? ([2a0d:3344:5521:6b10:58fd:68f:7756:389d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-498011f4eb7sm45229285e9.6.2026.07.30.02.55.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jul 2026 02:55:41 -0700 (PDT) Message-ID: Date: Thu, 30 Jul 2026 11:55:39 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2] rds: synchronize info callbacks with module unload To: Chengfeng Ye , Allison Henderson , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Simon Horman , Santosh Shilimkar , Ka-Cheong Poon , Dan Carpenter Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20260720184955.3008978-1-nicoyip.dev@gmail.com> <20260727174826.135662-1-nicoyip.dev@gmail.com> From: Paolo Abeni Content-Language: en-US In-Reply-To: <20260727174826.135662-1-nicoyip.dev@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/27/26 7:48 PM, Chengfeng Ye wrote: > rds_info_getsockopt() reads a callback from rds_info_funcs and invokes it > without protecting the callback's lifetime. Transport modules register > functions stored in this array. For example, rds_tcp.ko registers > rds_tcp_tc_info() for RDS_INFO_TCP_SOCKETS. > > This permits the following interleaving: > > CPU0 CPU1 > rds_info_getsockopt() > func = rds_tcp_tc_info > rmmod rds_tcp > rds_tcp_exit() > rds_info_deregister_func() > rds_info_funcs[offset] = NULL > free rds_tcp module text > func() > > The reader can therefore branch to an address in unloaded module text. > > Protect callback invocation with SRCU. Enter the SRCU read-side critical > section before loading the callback and leave it only after the callback > returns. Clear the callback with release semantics and call > synchronize_srcu() before deregistration returns, preventing module unload > from freeing its text while an old reader is still executing it. SRCU is > required because callbacks such as RDS_INFO_COUNTERS can sleep. > > Keep the callback array unannotated and use acquire and release operations > for publication so sparse does not have to apply __rcu through the > function-pointer typedef. Replace the two callback-slot BUG_ON() checks > with WARN_ON_ONCE() and return without changing the slot on mismatch. > > Fixes: 70041088e3b9 ("RDS: Add TCP transport to RDS") > Link: https://lore.kernel.org/netdev/20260720184955.3008978-1-nicoyip.dev@gmail.com/ > Suggested-by: Allison Henderson > Signed-off-by: Chengfeng Ye @Alison: I understand you prefer this on net-next, and I'm fine with such target, but the current guidance for net-next patches is no fixes tag unless the buggy code is on net-next only. I'm going to strip the fixes tag while applying this one. Thanks, Paolo