From patchwork Fri Jun 23 11:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13290410 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4090C0015E for ; Fri, 23 Jun 2023 11:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 366248D000D; Fri, 23 Jun 2023 07:45:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EFF18D0001; Fri, 23 Jun 2023 07:45:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18F828D000D; Fri, 23 Jun 2023 07:45:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0A8D08D0001 for ; Fri, 23 Jun 2023 07:45:20 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CBB441A0F2F for ; Fri, 23 Jun 2023 11:45:19 +0000 (UTC) X-FDA: 80933831958.16.24AF86B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 00FB14000B for ; Fri, 23 Jun 2023 11:45:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bbfwwU0y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687520718; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZDy9qTqAXsZiyNyw/4xfrjcFbGXml691uHuF37I4PZg=; b=2JbAi3zP1v4A9CDkNusIsz3IiHyVLGKK1ar6Y0rOICM0PRRvhstfumOg6iPxcfmTDG+Xij zmyOlxYnnmb/Kp94W6nVsWBWnfX/IBSlHcHUfxCbvq2LATWMpIeueA6gLPfsQP2dDPOvXt aA+btm4Xbat5Jb4N3HGTccFRZKqZzdw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bbfwwU0y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687520718; a=rsa-sha256; cv=none; b=vGZgeogDsINDI785t/MAXzC9u/8iyPN4c7YeYiD0L5DmDbDSzmFjAIW0PUbDbNBMy083yP opIADi+twxaVK1vGmbmHs7slMbNdadlQmwiUOTS5CUixn761jPxEFB1JffzajlXKziPSKt RGRWkbr14RK7gOPuzvyZ0X3eLcnIsO8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687520717; 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=bbfwwU0yoqBvuxMzsg7B3w1OSfShifjoAHo6wgKoeQVggdSbQjIW5zwSogLtucZvJR88K6 iReUaYByM4O1d2i4sZHF5YLxfUVn9fpU46phLzP/+5T3BK2NtBAYWC1nWsJCyhzzwL9w8n oN7mPZEf7ZS8qZZHzCNQKHUoKGds6Qo= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Stat-Signature: f9omt7616sxcnknwang3wihtak7y1kh9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 00FB14000B X-HE-Tag: 1687520717-670988 X-HE-Meta: U2FsdGVkX19jTaDLoD3ihVKqtyeR7XEujN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SXAwXYJlF0Zix1ktiB5p5RWH/ITnGKIs9cOX/v4W48UMLVCpVwenHxYmy5jJHUNVjSn05TjZ3MSr3km17g6zQpGUnlVKxMamq0EHu3PdUhb+ACVSeLTnETSpgXWBb1vOQLd08XdtRNW6BQ4eqE6XherZz/vMu4ygYgU8kQFECx3z0i4gVTTwefIMiP7C6q6KqY8f3RgClwYAeUFaFFrhf5B3QWmFdnJsTbGGne6LQAN2I6lKQ3V7IHo31cf8e1VpvIqp7HLK7NFGM5eR0fYyMcS/p+ueAt482eoa8nSnXAHkGnMZTsEmEw4aBYTPCbd6UI6uCkY5eDc+lB8tJ51ZugUTvgy3Pq3K0fgMwi46TeW9Qsg7SlD6kCD1YqJZ9V3yCivkjvC1jl+XN+eyKn2USBgUgx2/zKw+04KGIM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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)); }