From nobody Mon Feb 9 13:01:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA5A4C001DC for ; Fri, 23 Jun 2023 11:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbjFWLq2 (ORCPT ); Fri, 23 Jun 2023 07:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjFWLqH (ORCPT ); Fri, 23 Jun 2023 07:46:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A84FE26A5 for ; Fri, 23 Jun 2023 04:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687520718; 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=ZDy9qTqAXsZiyNyw/4xfrjcFbGXml691uHuF37I4PZg=; b=Ik6AFcb0x0VdlCQ/jSWOJJLyC/pKRyswrjtOKk2P13057yuU5lI9nQCjX5G29GURFbi0px 9WvGY76FZ83jrV+ZgI7mNEve8/uoNruOJ/lZXo5xA0kDrhuUrA7Ct7nguNsr1LqZzr7z2r Q5P8iUpseumkdSLwxzV9MwUxk85f99o= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-y_gjQWLAObqQcPZDkV39dQ-1; Fri, 23 Jun 2023 07:45:15 -0400 X-MC-Unique: y_gjQWLAObqQcPZDkV39dQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D14C63804A43; Fri, 23 Jun 2023 11:45:13 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED36015230A0; Fri, 23 Jun 2023 11:45:11 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH net-next v4 12/15] ocfs2: Fix use of slab data with sendpage Date: Fri, 23 Jun 2023 12:44:22 +0100 Message-ID: <20230623114425.2150536-13-dhowells@redhat.com> In-Reply-To: <20230623114425.2150536-1-dhowells@redhat.com> References: <20230623114425.2150536-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ocfs2 uses kzalloc() to allocate buffers for for o2net_hand, o2net_keep_req and o2net_keep_resp and then passes these to sendpage. This isn't really allowed as the lifetime of slab objects is not controlled by page ref - though in this case it will probably work. sendmsg() with MSG_SPLICE_PAGES will, however, print a warning and give an error. Fix it to use folio_alloc() instead to allocate a buffer for the handshake message, keepalive request and reply messages. Fixes: 98211489d414 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem") Signed-off-by: David Howells cc: Mark Fasheh cc: Joel Becker cc: Joseph Qi cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: ocfs2-devel@oss.oracle.com cc: netdev@vger.kernel.org --- fs/ocfs2/cluster/tcp.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index aecbd712a00c..929a1133bc18 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -2087,18 +2087,24 @@ void o2net_stop_listening(struct o2nm_node *node) =20 int o2net_init(void) { + struct folio *folio; + void *p; unsigned long i; =20 o2quo_init(); - o2net_debugfs_init(); =20 - o2net_hand =3D kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); - o2net_keep_req =3D kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - o2net_keep_resp =3D kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) + folio =3D folio_alloc(GFP_KERNEL | __GFP_ZERO, 0); + if (!folio) goto out; =20 + p =3D folio_address(folio); + o2net_hand =3D p; + p +=3D sizeof(struct o2net_handshake); + o2net_keep_req =3D p; + p +=3D sizeof(struct o2net_msg); + o2net_keep_resp =3D p; + o2net_hand->protocol_version =3D cpu_to_be64(O2NET_PROTOCOL_VERSION); o2net_hand->connector_id =3D cpu_to_be64(1); =20 @@ -2124,9 +2130,6 @@ int o2net_init(void) return 0; =20 out: - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); o2quo_exit(); return -ENOMEM; @@ -2135,8 +2138,6 @@ int o2net_init(void) void o2net_exit(void) { o2quo_exit(); - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); + folio_put(virt_to_folio(o2net_hand)); }