Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12355406rwd; Fri, 23 Jun 2023 05:10:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5yrRBn1jh/PRsSqI6uLvfnHrj3LHhynZugQBmkldka8YG5hyNIzDDBaB6Bk3XZFo3zu2Az X-Received: by 2002:a05:6a00:2405:b0:641:d9b:a444 with SMTP id z5-20020a056a00240500b006410d9ba444mr21446640pfh.31.1687522217485; Fri, 23 Jun 2023 05:10:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687522217; cv=none; d=google.com; s=arc-20160816; b=cok/+Z0Li30eTLK97RtxQfw4OaMGOg2PLe4V1I7Q1E1GeIQdlP/TIpC+0qJA4Ge8Pz ThN6+wQ9C7a1XFc8Jbh5T0mULvCACJGN92KCX9twM1xB5bKTQJCbPzY4NElSh5D7j7Tg UPn6OqXThRc3FJY+wjsgKI0U6nzng5sNOuSc2jBbsqOhWTfKDvC0DcJvQuxdfH3swGPt 4iVj0XznIKkw431ktdBj/SP6XdTRPeNtMyWkRlG0VS7ZlBiyt6YJGST+60Mx2WNdNPzs ilDQ7nabAQMtF0zKc/pMMeUVhFH65ibQZv3QC4Jbk0u/RxD7T5i7/nin7OahnQtHRXPY zOzg== 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=ZDy9qTqAXsZiyNyw/4xfrjcFbGXml691uHuF37I4PZg=; b=r+/PuxPDMd7Aav6pRiC/VGYYzzSrktpHNatFO/dfVNmhgGndB3Qpb1b4GdVhoQ9Nw1 sVPQlJWonjcnCHbkuaC6zGoONeFjDiLhY5tRBRX4s21kcSw+rCDFQz6+KON9IosjVDSs W3K83/seY9RboLwrOjS6PluvMgqCpq7QG+ex3vQK4RfoCOh/KW1bEM457zunwae4jEXY nIRDSXJyswoqeeKyNPMmh7LSpy46vS2kwU3mcr5qgHra0Ub/abtCxWjeHU8dnIzFxSH8 tQ6YlE9sWGN7tSD+mU/vRXTGE3nb+gq8yxDnmlFmY2YEHkJZ6ySQ6JPpZumCk9UMn7uU 7vwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ik6AFcb0; 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 k6-20020a636f06000000b0053f228ce43csi8658367pgc.547.2023.06.23.05.09.52; Fri, 23 Jun 2023 05:10:17 -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=Ik6AFcb0; 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 S231608AbjFWLq1 (ORCPT + 99 others); Fri, 23 Jun 2023 07:46:27 -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: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=unavailable 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 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) 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)); }