From patchwork Fri Jun 23 22:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291457 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 5520DEB64DD for ; Fri, 23 Jun 2023 22:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD7358D000E; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D616E8D0001; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDC0B8D000E; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A93928D0001 for ; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E2E5120363 for ; Fri, 23 Jun 2023 22:56:00 +0000 (UTC) X-FDA: 80935522080.22.57CA687 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 920CDC000B for ; Fri, 23 Jun 2023 22:55:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZG3JSP6Z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1687560958; 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=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=qKBQBExe4oenjtgRMdj+rYbRy0m5edn7pLuO1Sg7BQCmozQrWcHocdJZzEj8NgU9uPEJtd H+jbtDjghPoL50NKaIc0jQR0w0sqCGGIbLHKxu4D6d32mC+EHKy+cjLa7Z+l1Z5Dc5f9ee rE4U1ZiKfXbmEy1o35Utx2K/vsTJFjo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZG3JSP6Z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1687560958; a=rsa-sha256; cv=none; b=t8kgQ9vEsmAQXsxGgwsxqcJuoYRVEHPyAwQGpyQNepIf5KQGuI6CEdUopZzCOfsiDNyqI/ XZxS0u+SqIKZRRniki+Ictab0OPI8RHRxAngBiBXTNIAZAOiDrLfsfzsrvb3MYQwJjj0oh PduxcfB+c664F2nMv7Nd7g4XZ7P6+LY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560957; 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=ZG3JSP6ZUeHVqA7r+JNZ0VcHokhKWfxGdkCkFSZ4xohgnS0S479xhNIWGytlgoVsxTZSx5 C5EKOM65Ywe0xhh3ldOT7tZ27CPy3ydNrXCH8rUT2JPosMIh/VheRoSGs+FnXhSvhNtY6y WaPjV4+KY0rTCrXJcxKpz4jTrd1bnDI= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: 920CDC000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5mftsekdt6kfmknt8z3wwxhi4r69bqtc X-HE-Tag: 1687560958-526326 X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fsfiCH6lq5P+BQ1flrjSJfiB5wxmtNTpkgGtCSJjlk4uVRXi1rKiWeNddSA5oos4yxQLHni2jKHGW0hVhGgZQiCUB592WbAzux1wSPu3PyRxBeHmKyiHhLNKwJtvna4fKQwgBBHH890XZYcws/+jUPvX69wO7+j7eIZhkMVe4yE7rRKka1TVwMYtjkKC+a2DSAtMHcwPyO/xvJSlEyVY+wSg77hfuK9pX9f3vWComzVlwzdKVvlmW3uSb1UPt4oUg+8jzXYa7XKyzli3riF3OMEMzk5t1KJX4l9fDA/ArAmkjSHRaJ7ZrM3+o45i+tYiBzdr2VrNjlmsd2YwJjCuBxj2vz6If8W77PN/0Tie1wrGwaF1DgN4WFC7cFlg2xcmBlbhco3hqjP2M9orJ1Ab89jR2kzW3NImoT2auypzJ8Qir8GWxNL6HG7TrJPVJpTamMprJqWrFWo2FSPkZCc/dcjiT5k2I= 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 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)); }