From patchwork Thu Nov 16 15:53:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 165888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp3303165vqg; Thu, 16 Nov 2023 07:53:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLs6YmZAbsZJ4W1PpYlG+FO23FcHU4qaNZLAaoGxbmsIzS2YILJNYYgOpQ2hGGBQ00O9hN X-Received: by 2002:a05:6a00:4510:b0:68f:d35d:217e with SMTP id cw16-20020a056a00451000b0068fd35d217emr16563611pfb.2.1700150034888; Thu, 16 Nov 2023 07:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700150034; cv=none; d=google.com; s=arc-20160816; b=nlA5ShyeSK/wKs9u27YapRNoyTRxpYux4qrbTr5Z1CCUDYu0UPzL7sexKbYwNTxu7i X5k78OSBnPKjoodf4Pg57KAHuAHF2pi9kTLOaEfxXT+1Rcwq9YYolkBU98UX109srUHt a1FWofLr9k7IPYT6Ywo0INo9yJ2/kikpHZhAhfgGBMdhU1UbYZfwJKzUflLI5lzHEhhV 8Lfx5ZBGc9i8SM6qAF9xnGfi1m0bm2GnpZYFYf/6GNNTQqr9ZJ9ZW7UIhy57pf5eahMR h+UgAX1qWbSaGcwipkRSW+kOJYZjw7MPDZzmdWy9B4jvFPl4OhuguPUdSZq6m+CRFwvq Gugg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S3Nkl26BdZ6XNwFHoko5KRDQDv/tiZrd51e5XRL9ph4=; fh=9hT4l0EMR1D2zdgUoRXiqFwsybSJyrmM/FC/blQlPsI=; b=M5FG7MWpwIqZ37NYkZM2++6/iVW+toX8xISjvY35uUZ0gSBkHbRdKvKxKYmDHTYcOB mdfwwyByKHDDRKFhKce8fGQq3Olnlk18bZy+beg+V689diJuweKyLhTRJsyXpuF00Kvu 09HajJCoOYjuJfOqQ5rPZYK2ari5OYKYBsde/JJVrjmkJmDBSdhC7mf/ufaQ9ooZcku5 cMdjusHAlIALKoeRYdxXBr19rAJnJt2hqBK1v5wqnHCZ5Cgyk5Pl2QidYpa9nBg6DPlO mNUY/c2OK8sYFEP7+ycw7V8IbFTYGM5nq5btSiiJIHrNF1mJ2Lp2NKa9SR6lXu0YurJd x1xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZuR36NRB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w7-20020a056a0014c700b0068ff741579fsi13089354pfu.318.2023.11.16.07.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 07:53:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZuR36NRB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E977C817C8BB; Thu, 16 Nov 2023 07:53:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345405AbjKPPx1 (ORCPT + 30 others); Thu, 16 Nov 2023 10:53:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345330AbjKPPxX (ORCPT ); Thu, 16 Nov 2023 10:53:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 644CF11F for ; Thu, 16 Nov 2023 07:53:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700149999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S3Nkl26BdZ6XNwFHoko5KRDQDv/tiZrd51e5XRL9ph4=; b=ZuR36NRBtX4DcVuNyzU0p+Dcd/tkcCiYx0aNE25IGclxGRBhZpdSh/qDDwynyIJNXIXbDC yOfkVIZqpmGJO4NC0gjh1vDx08kFlLI4CDzKavzuajUqZYvcx0poP4YJe2T+7W+GoNHTBt 698E3a3+ChdW7sosQcf3LvihTuZegOs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-TBf8Q3zzNiyerMSqa1Uyuw-1; Thu, 16 Nov 2023 10:53:18 -0500 X-MC-Unique: TBf8Q3zzNiyerMSqa1Uyuw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC8C28528C9; Thu, 16 Nov 2023 15:53:17 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id E770BC157E5; Thu, 16 Nov 2023 15:53:16 +0000 (UTC) From: David Howells To: Marc Dionne Cc: David Howells , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] afs: Fix afs_server_list to be cleaned up with RCU Date: Thu, 16 Nov 2023 15:53:08 +0000 Message-ID: <20231116155312.156593-2-dhowells@redhat.com> In-Reply-To: <20231116155312.156593-1-dhowells@redhat.com> References: <20231116155312.156593-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 07:53:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782736522998156761 X-GMAIL-MSGID: 1782736522998156761 afs_server_list is accessed with the rcu_read_lock() held from volume->servers, so it needs to be cleaned up correctly. Fix this by using kfree_rcu() instead of kfree(). Fixes: 8a070a964877 ("afs: Detect cell aliases 1 - Cells with root volumes") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Reviewed-by: Marc Dionne --- fs/afs/internal.h | 1 + fs/afs/server_list.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index c9cef3782b4a..a812952be1c9 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -553,6 +553,7 @@ struct afs_server_entry { }; struct afs_server_list { + struct rcu_head rcu; afs_volid_t vids[AFS_MAXTYPES]; /* Volume IDs */ refcount_t usage; unsigned char nr_servers; diff --git a/fs/afs/server_list.c b/fs/afs/server_list.c index ed9056703505..b59896b1de0a 100644 --- a/fs/afs/server_list.c +++ b/fs/afs/server_list.c @@ -17,7 +17,7 @@ void afs_put_serverlist(struct afs_net *net, struct afs_server_list *slist) for (i = 0; i < slist->nr_servers; i++) afs_unuse_server(net, slist->servers[i].server, afs_server_trace_put_slist); - kfree(slist); + kfree_rcu(slist, rcu); } }