Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13101568rwd; Fri, 23 Jun 2023 15:59:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4L7jxHBMiGs+3NWubWBdd7aRv3M/+XGV/KJbo2hPbWxbvYPfZ88h+xMM/aDq8jh5TfMAZj X-Received: by 2002:a05:6358:5114:b0:12f:158e:ed88 with SMTP id 20-20020a056358511400b0012f158eed88mr16499443rwi.22.1687561146354; Fri, 23 Jun 2023 15:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687561146; cv=none; d=google.com; s=arc-20160816; b=bK2Z61gTz3XUiRZUaLGI7iWupvAIxH6/dFMbWt6o/JQ3J7jQT2oSYrv08sVp3a8OgG ++TMZTA2AyG1XoW4n+n8UrGrlPHxAV+UZ+pq6yMr6IdKYSXaqaLbAD40I1LcEEw9Dd+r FY87y1mzsfm3FILTGtQljgTWsUmMURrXcfnPVbWQ0Yfpqfubzk8miWWSn5kN/QDEYWyv SJcVQWfg1lFz7+5gtGLDiEhaw9bIbVBL2uG+hs/l3LDlnHCazk3IMEnY9GRonMEgcLLa yFXP8G3Zlz3uvTGQ5i0YencJBXC0oeu6O7DqKOJna00mJXuda0Si2GqNTBy8Eb+te7Cx zEVA== 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=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; fh=q9d7vhv8O+MK6oeyRakeXy3w0eUTm3mJMfxE2V8iGTY=; b=zu6D9C3Pwtmq3UYY+l7rVNc2HeCqd2vSBa+jSlG38vXs45CtUJNEgc8NImsy9UhawN wHogVqrbyV0O3wjBb2cRcSDEEfgreSQPcqwcJMlaTzJ/THNMx5pigL5igVRfH2z3tQBs GGyOUxUTl2vGxIlUygUdXOi2hr32iY/HOD5CBgdlmyk7nXiT6DMwSlE9Df6qzTrYTPyO UqxAS91GTWAWsc/IEMI1xbvZbhBJYAwii8uCxBzdtP8iTYorxI2GnJII9QTlGabhpCPT V53yx4JF0x45/wG1tcUOhQM/svysWMvB8dB7/Q63aQn+cTgMsu2XsNYpuz5+9zQEXhw1 zSmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SoAGJ6iN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb23-20020a056a004c9700b0063b8f0a6f51si171237pfb.117.2023.06.23.15.58.54; Fri, 23 Jun 2023 15:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SoAGJ6iN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232818AbjFWW6B (ORCPT + 99 others); Fri, 23 Jun 2023 18:58:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231937AbjFWW5j (ORCPT ); Fri, 23 Jun 2023 18:57:39 -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 BA49F2950 for ; Fri, 23 Jun 2023 15:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560959; 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=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=SoAGJ6iNifHJfs/vJ19Vf949dH2tPMJ8fhyx1C1r0ncPFVfDayzDgojBigXS+z+2CMkQdj kwgGqIHPzr1HyV2vbJfCElD0mBoa2sfN0z7W+IeqgBp63Z+7i2FXLBmFlaYf3MRjISsYjO NIO6IHfwSUSxvYyUPk/sOB7QuVTOhLw= 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-91-scLXM6p0PSyn60UPmGbLlg-1; Fri, 23 Jun 2023 18:55:54 -0400 X-MC-Unique: scLXM6p0PSyn60UPmGbLlg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCC862A2AD53; Fri, 23 Jun 2023 22:55:53 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8918B40C2063; Fri, 23 Jun 2023 22:55:51 +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 , Kurt Hackel , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH net-next v5 13/16] ocfs2: Fix use of slab data with sendpage Date: Fri, 23 Jun 2023 23:55:10 +0100 Message-ID: <20230623225513.2732256-14-dhowells@redhat.com> In-Reply-To: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ocfs2 uses kzalloc() to allocate buffers 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: Kurt Hackel 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) int o2net_init(void) { + struct folio *folio; + void *p; unsigned long i; o2quo_init(); - o2net_debugfs_init(); - o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); - o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) + folio = folio_alloc(GFP_KERNEL | __GFP_ZERO, 0); + if (!folio) goto out; + p = folio_address(folio); + o2net_hand = p; + p += sizeof(struct o2net_handshake); + o2net_keep_req = p; + p += sizeof(struct o2net_msg); + o2net_keep_resp = p; + o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); o2net_hand->connector_id = cpu_to_be64(1); @@ -2124,9 +2130,6 @@ int o2net_init(void) return 0; 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)); }