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: 13291561 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 aib29ajc246.phx1.oracleemaildelivery.com (aib29ajc246.phx1.oracleemaildelivery.com [192.29.103.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BBE6EB64D7 for ; Sat, 24 Jun 2023 02:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=XDZBSDyaA5pNR+c5xW+GGwShNBm8PqZnPMlCfNPaSGg=; b=isOG4/rAti46Mu5ymzvZTPSEEyjKPCc4IyIPRJ0fvX27g2KoSvd4p8pn0ZCBoMfscSFOg0//gBIs eVHnS2RJsGQ/s4/LMsPWxLhwzckw1wgg3iMEmJBM4y4haRCpuZWUWw9p2PNySS0PUZXh/pa5l/LR XeWEfzqS7DjK20iee8S8D5cgMj7slKwDXisj18mlaYwLhzkT30F9GSCTMiD8vSl/96DS//9CzXJZ hXM2rvHeyNLBwR3qoYubj0pBqsY2EnhF8+dZ3rDykFWeiYDspzsBU5bWQhXGAMGUu0qJW0/ub0fS Q7J7kaoshCsGEgqCVbq3uqnw5TgTWvvRWfz4VA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=XDZBSDyaA5pNR+c5xW+GGwShNBm8PqZnPMlCfNPaSGg=; b=IIpr6uqrdISpFhcYkusG9ac9oHDKHXo44+ILU43cqDRn2M7mk30ZnoSpntSBcbPgHxLZ2mPHY3x3 l3/477GocQgwMbHHCHk+9YI+NPT0vou4RUOeD0x9RhgVrG8146DjTwtHTbAao+vxS1ZPVwhpLVgt kvyga0pwT7ti05B7mIfhVhe7Zq6tXiOwT+9T6f4Px4JJ+BY7vbSAgvPgp7T0ir2+qAobWqL19AKs q5Wl9itAkrLfqyWqd/Z0TIPs5DyrwjyJwl7Tek57c7w6bZp5spkBY4rrAQoxMp92P5ongwaO/xGa u1n6NVgB0JAUyzA7kCngZXeGK5Mg355zmUwALg== Received: by omta-ad1-fd3-101-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20230523 64bit (built May 23 2023)) with ESMTPS id <0RWQ00PBBLE56VA0@omta-ad1-fd3-101-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 24 Jun 2023 02:54:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560958; 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=I17uaVHxXDtllpyiVTtomGBUje2R31diHr4ASrXBHE1lWemlpfvHQPmHZu9/M+v1JGLqIE 1BWwoDFaQEbRLY++z1KaSfdE6cqHMjOCk8QC/56j5i7QKrzhqD9ULGVns9KoyvZQPCH/T2 H9TDQiYtygX9zNFfJAbMtITVCQGT/wk= To: netdev@vger.kernel.org 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-Source-IP: 170.10.129.124 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10750 signatures=596816 Cc: Jens Axboe , Willem de Bruijn , Kurt Hackel , David Ahern , linux-kernel@vger.kernel.org, Alexander Duyck , David Howells , linux-mm@kvack.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH net-next v5 13/16] ocfs2: Fix use of slab data with sendpage X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: David Howells via Ocfs2-devel Reply-to: David Howells Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-MC-Unique: scLXM6p0PSyn60UPmGbLlg-1 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:107.21.15.141 ip4:108.177.8.0/21 ip4:128.17.0.0/20 ip4:128.17.128.0/20 ip4:128.17.192.0/20 ip4:128.17.64.0/20 ip4:128.245.0.0/20 ip4:128.245.64.0/20 ip4:13.110.208.0/21 ip4:13.110.216.0/22 ip4:13.110.224.0/20 ip4:13.111.0.0/16 ip4:136.147.128.0/20 ip4:136.147.176.0/20 ip4:148.105.8.0/21 ip4:149.72.0.0/16 ip4:159.183.0.0/16 include:spf1.redhat.com -all X-Proofpoint-SPF-VenPass: Allowed X-ServerName: us-smtp-delivery-124.mimecast.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:107.21.15.141 ip4:108.177.8.0/21 ip4:128.17.0.0/20 ip4:128.17.128.0/20 ip4:128.17.192.0/20 ip4:128.17.64.0/20 ip4:128.245.0.0/20 ip4:128.245.64.0/20 ip4:13.110.208.0/21 ip4:13.110.216.0/22 ip4:13.110.224.0/20 ip4:13.111.0.0/16 ip4:136.147.128.0/20 ip4:136.147.176.0/20 ip4:148.105.8.0/21 ip4:149.72.0.0/16 ip4:159.183.0.0/16 include:spf1.redhat.com -all X-Proofpoint-Spam-Reason: safe X-Spam: OrgSafeList X-SpamRule: orgsafelist X-Proofpoint-ORIG-GUID: g2PiXrbgUOuJm93GH_msFnXuR-zdpk3E X-Proofpoint-GUID: g2PiXrbgUOuJm93GH_msFnXuR-zdpk3E Reporting-Meta: AAECKOCf44dwwvi5NidQGRQsmWgUdyEA0ayd9rXbwOhMQlklARYb3srYUIKUfHyE ddBAi47jQreF4jrm6Tut77dcZAPDBM4d3q04+c5xiblm8V/uH/lNQy+dw9TJf/Pc yQgIuFPj1W1BLZx2Qhlca8+pVGwJNbr/54EHT1pQjB2asHHen3lqr9MtWaH4GZcf 2G1krK7T71oMoCvSABcBo2TzpBnvPrqmKfaSQmIYqThvjcn6K8hHQ2Fx1wqYXw0H tnR3BZTluNsE/MjgGDq/zB89i2mAgTSNmT50jnSnvjTMsAwWHnZ/PAry7oSTUWqb z98TT6SNfcu4jre/lTvOc9NeMjTt8rOfHMaNJbV6m7rrjzKgVE1JkfFGPeisluLT zxOfmpJTBLmKdV27GZcAs0xx/7LelBmN4UVGGl6nhklSDIXu5dFTG5KH53lwNed9 bYRdM6EyWIzRbjPGDkfq85M21YnEG9rIQIjUQR4OMrvIU1tDMtgQQjYWZ3pn+g5X TY1ogta/AKJSANQP9oNDliQw2tQcSibbRNVIePc6614= 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)); } From patchwork Fri Jun 23 22:55:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291562 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 aib29ajc253.phx1.oracleemaildelivery.com (aib29ajc253.phx1.oracleemaildelivery.com [192.29.103.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E83F8EB64D7 for ; Sat, 24 Jun 2023 02:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=KD9Ijz+Ucabdxp6nn4YEuNBWGy2LSUisnwNqArTBiXU=; b=xgqXG70EtP9WvsqNaoV4KVzeBcrXN1n1aMPD0D6VmAnuV474kptdcvR5RBOfxahcABbAMpe7XWnD AH1rG72vyRxyVJdkedno5ZlDXH9TyWB9Ejxb3gPblgmHhNQO4StP/OELjQ5mdNPFXEDUMUaKlGBC +J4koOV+AQr12Bxb33gi3X/B8vp6yejtLGpUrObQd340GDSRkN2TTo3Phkk7r+OgHmY1OU6u7AIp DglGhQUo7UfRHeWueSdar7AMuFEr+4FpNs6V6wGk+4KQdT9Ne+Ad3MX1DAj40c2ABKkN8Hja5ZEi 9McMXuIB7QmW0lvMd2pitpO428v+RIju0K9aGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=KD9Ijz+Ucabdxp6nn4YEuNBWGy2LSUisnwNqArTBiXU=; b=Hm8U28B5L934SNnIDmCVsmIeC4RIgF/nhy9WiZkrmJbWO4SZ3DBMUx0ETeNe1tfPDI+YQaUyxAM7 pSPIgaqelk77FK/+vED5GwSHGTI/TbUIbnOvTSp8rurhUjfFELuqjdquhnHGtf1rXMnctx4ontTh coTHaJGAoXNCAQjZOXzZJJF275TeOGB0OsVTfxiqHqWOCe6iWvA+rndwaq+lO5vSk4TnOl4OAP29 2k6E3NDSyFM+FRgr9Vpwxf5pnCCbtzmiyMhQ45WsXRWKtJtC18mEOBJACepymgqSgLlq2/Y1itmF 35k5PH6NEnoKPCG9R78W7llu3vhxin/7neyVGQ== Received: by omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20230523 64bit (built May 23 2023)) with ESMTPS id <0RWQ00LJ7LEDZ420@omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sat, 24 Jun 2023 02:54:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560964; 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=6qW7QONKdXKQCe18ckz4PBDuqjad2A9AyVw+035R3zM=; b=Vv7dLA8hBk4btvpRclhRoEBG8PXnqHicj0Xf+7dXTneuHG7L71yUSHGziivVNDuyKKZLyx T4m8GhqVN4Oh3QEu/QD7Nh0vpY3shvjK/cfAbgGdjkw5RaF0YRP7S4Uzcn3O6I2JqCyJUd NtbL9WwI4nB4jAwNY+nu4NntWvM8d2E= To: netdev@vger.kernel.org Date: Fri, 23 Jun 2023 23:55:11 +0100 Message-id: <20230623225513.2732256-15-dhowells@redhat.com> In-reply-to: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-version: 1.0 X-Source-IP: 170.10.133.124 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10750 signatures=596816 Cc: Jens Axboe , Willem de Bruijn , David Ahern , linux-kernel@vger.kernel.org, Alexander Duyck , David Howells , linux-mm@kvack.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH net-next v5 14/16] ocfs2: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: David Howells via Ocfs2-devel Reply-to: David Howells Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-MC-Unique: a9340YSgPS-PNmqg9L7xcg-1 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:107.21.15.141 ip4:108.177.8.0/21 ip4:128.17.0.0/20 ip4:128.17.128.0/20 ip4:128.17.192.0/20 ip4:128.17.64.0/20 ip4:128.245.0.0/20 ip4:128.245.64.0/20 ip4:13.110.208.0/21 ip4:13.110.216.0/22 ip4:13.110.224.0/20 ip4:13.111.0.0/16 ip4:136.147.128.0/20 ip4:136.147.176.0/20 ip4:148.105.8.0/21 ip4:149.72.0.0/16 ip4:159.183.0.0/16 include:spf1.redhat.com -all X-Proofpoint-SPF-VenPass: Allowed X-ServerName: us-smtp-delivery-124.mimecast.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:107.21.15.141 ip4:108.177.8.0/21 ip4:128.17.0.0/20 ip4:128.17.128.0/20 ip4:128.17.192.0/20 ip4:128.17.64.0/20 ip4:128.245.0.0/20 ip4:128.245.64.0/20 ip4:13.110.208.0/21 ip4:13.110.216.0/22 ip4:13.110.224.0/20 ip4:13.111.0.0/16 ip4:136.147.128.0/20 ip4:136.147.176.0/20 ip4:148.105.8.0/21 ip4:149.72.0.0/16 ip4:159.183.0.0/16 include:spf1.redhat.com -all X-Proofpoint-Spam-Reason: safe X-Spam: OrgSafeList X-SpamRule: orgsafelist X-Proofpoint-GUID: V_4EjNe4R4Hox3XfJahfjlW4Q2Wrg3Fm X-Proofpoint-ORIG-GUID: V_4EjNe4R4Hox3XfJahfjlW4Q2Wrg3Fm Reporting-Meta: AAECKOCf44dwwvi5NidQGRQsmWgUdyEA0ayd9rXbwOhMQlklARYb3srYUIKUfHyE ddBAi47jQreF4jrm6Tu377dcZAPDBM4d3q03IfjR4yacod4qmJVkQU9J0pKD1F2z 8ydToHCAroA1QHrT3hcf/WJgngeHRCL5m5/ln96NanQHuKWfOSaVEv6yPHwKpa1+ k/BtpFriXsH7d29Kf2R1LE7dwha7s/V27GPjmOyRVdrLuuf9hpVMdeKcK3A/SUZ7 VluR3vUbxCQb+2GdUrAs4I9Bv1+EZL5VzZmaNtidVjadr43R/xLaUNbr/FNybc7M 0xnxP0ekXOPrW65pQasi/OfO9uq26aqucmZjH2Kdjz+FtxAeBq37K1Yy4d5akNc2 6AwoWW+RdWevpsb8drJ5x9PDwps2TmHSgslCtBbRCMNah5d2191EqEhdqzuRAp7H kpULgnU6UAXYvo1P9mhwWZ9RvM8FggCfyPyS5+w+WKozf4JCHGF/DBqXjNJNnbmM qJLJOKuHsE0bTLKy58ScuDgJw2bNDVfOZDlG3UHyrFpN Switch ocfs2 from using sendpage() to using sendmsg() + MSG_SPLICE_PAGES so that sendpage can be phased out. 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 --- Notes: ver #4) - Use folio_alloc() for o2net_hand, o2net_keep_req and o2net_keep_resp. ver #2) - Wrap lines at 80. fs/ocfs2/cluster/tcp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 929a1133bc18..960080753d3b 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -930,19 +930,22 @@ static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, } static void o2net_sendpage(struct o2net_sock_container *sc, - void *kmalloced_virt, - size_t size) + void *virt, size_t size) { struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + struct msghdr msg = {}; + struct bio_vec bv; ssize_t ret; + bvec_set_virt(&bv, virt, size); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, size); + while (1) { + msg.msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES; mutex_lock(&sc->sc_send_lock); - ret = sc->sc_sock->ops->sendpage(sc->sc_sock, - virt_to_page(kmalloced_virt), - offset_in_page(kmalloced_virt), - size, MSG_DONTWAIT); + ret = sock_sendmsg(sc->sc_sock, &msg); mutex_unlock(&sc->sc_send_lock); + if (ret == size) break; if (ret == (ssize_t)-EAGAIN) {