Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73206C43381 for ; Tue, 12 Mar 2019 08:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08A032147C for ; Tue, 12 Mar 2019 08:23:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="yTkNcMHp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbfCLIXD (ORCPT ); Tue, 12 Mar 2019 04:23:03 -0400 Received: from mail-eopbgr00088.outbound.protection.outlook.com ([40.107.0.88]:18817 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726218AbfCLIXC (ORCPT ); Tue, 12 Mar 2019 04:23:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zz0rekIBU5zK6XfUFsGkK+lVVCIwzhhLJV3QXn27eso=; b=yTkNcMHpSV+DaBPDvCwaRZ50a7BIuqh7b2RbQe1Gm/CRwx5b+QInK24NY2WPsHsrIVB/EDDIVqlNvP5opWRCw0n7MT3MsHYg5o/IaG3KR9pn70syhwdrgEI3xvGQxrdF1rFzCo5d0eGX4azKLJDU7yOC/kjcYJrLm2XZg4dA1Z0= Received: from DB7PR04MB4252.eurprd04.prod.outlook.com (52.135.131.26) by DB7PR04MB4905.eurprd04.prod.outlook.com (20.176.234.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Tue, 12 Mar 2019 08:22:57 +0000 Received: from DB7PR04MB4252.eurprd04.prod.outlook.com ([fe80::9ca:d78:c154:25b5]) by DB7PR04MB4252.eurprd04.prod.outlook.com ([fe80::9ca:d78:c154:25b5%4]) with mapi id 15.20.1686.021; Tue, 12 Mar 2019 08:22:57 +0000 From: Vakul Garg To: "netdev@vger.kernel.org" CC: "borisp@mellanox.com" , "aviadye@mellanox.com" , "davejwatson@fb.com" , "davem@davemloft.net" , "doronrk@fb.com" , Vakul Garg Subject: [PATCH net v2] net/tls: Inform user space about send buffer availability Thread-Topic: [PATCH net v2] net/tls: Inform user space about send buffer availability Thread-Index: AQHU2KzM0FVKFG/jdESsqvcXKBPnuA== Date: Tue, 12 Mar 2019 08:22:57 +0000 Message-ID: <20190312082020.7439-1-vakul.garg@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0031.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::17) To DB7PR04MB4252.eurprd04.prod.outlook.com (2603:10a6:5:27::26) authentication-results: spf=none (sender IP is ) smtp.mailfrom=vakul.garg@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.13.6 x-originating-ip: [92.120.1.70] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fba11e66-f461-4782-a608-08d6a6c3ee85 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:DB7PR04MB4905; x-ms-traffictypediagnostic: DB7PR04MB4905: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;DB7PR04MB4905;23:M24TRCVs4PTs5nPG80oYX2xeVURAnSGEu96LoAS?= =?iso-8859-1?Q?Ij8YvDwYrISE/ogp+6QUvR+zaTmbnrr7YcX1/O1wGyqMIIfTTZtl6DOXQ2?= =?iso-8859-1?Q?FkKsM+G8O4W5a9URxNLmG1w+wOZeo1lMaReseonUmA16aT0BeiZAl6eAeO?= =?iso-8859-1?Q?NcmmyRt48AyCWXGNSnSJEl4nrgM4kPvki3RbiRfv6y0OUgOuPjfXe2d+nh?= =?iso-8859-1?Q?zVedqxqFtIlD0EEzVg2gpP/9jzLAntQCphUTfQA6vTYzIQcxgz06UCEEur?= =?iso-8859-1?Q?JQgJ+isXVideW357/1B9Gc2gLCUz4ydaNWvTdr1hEg4pyso9D19NhEVfFE?= =?iso-8859-1?Q?pc38uF1ssO8L4FppfCuoECV/AaC2pAtLyr4lXdod7iRPtWPL4QGYA4jIYH?= =?iso-8859-1?Q?pfdLIEiDjJ7sjL5CyKHkoZW3Bh8xbScrz5ydT8Cfli9c+zcjTfml6zFEJP?= =?iso-8859-1?Q?Sc7tqcaoOxRSVWct00STGxGXJUrjESAtYbxyO1lXsQ1cKmjmG7SrjXNmo2?= =?iso-8859-1?Q?AGVKc2V2PtG5xqT5ws4DF+ZHDHs1F3b+pMTXWBGTqbhnMjnsMZsCD5CSKW?= =?iso-8859-1?Q?TroqmVbBDj4KTqToP5zb+LayxTWp62OZ7YuLMtEDECGJ1zvQ/2n5LMgYaD?= =?iso-8859-1?Q?sxnewS0RyX9aHLyCxO6SUaqiaZqMopUPF1tROiy+8g18YdiRKtasOlm+Le?= =?iso-8859-1?Q?XFQNxHZvNqCtSRo/wqCJSqDWnJEcf9B6EFKdkHQZtlKofQl0hQHodP/GkK?= =?iso-8859-1?Q?bIleXLrerxTrQ8UwX7yiCsss/wafmn0IQKG6V6dRzVxmW4mNpiiXBAqngp?= =?iso-8859-1?Q?+5GNp/7yg24Ebt7l5IbdYjsLn6QahmAwxlCA436vpGx8Vo5pwa/JGetpk2?= =?iso-8859-1?Q?h2uQZ/WeGrdFDWY6vDaldHdqLoZO0J3TOjKxadbyJIVSlonK1ZbNZ0xmYM?= =?iso-8859-1?Q?y0J/GMLHW5UahtZVJkwH0vVY2y1DZRCaXWSl+D2usijJjBe58mZabulaRW?= =?iso-8859-1?Q?aykvIu33hbes7a1fEC0J1aGQVqQTULuTDlATjeq/7eUVT3CP3GTHVFrdmh?= =?iso-8859-1?Q?CTfVjD1zsA0Z391x/9dBnkTo081kD0mirLY0MihYzDf3UJQ5z3MP1oTeDi?= =?iso-8859-1?Q?dN/w/PLoeLEzzD7tBrZCqDRCo6d6ETD594d1Zb4HRXq8DHDRDbPIIHW+Ap?= =?iso-8859-1?Q?caFYPlTmRR9Yk1DBFO3Y2fvtCdxTBy93VGLdVKwZ0KZ/aNVGaGwSDxT4H+?= =?iso-8859-1?Q?4yEmigcd6dg60SzcdJzoXaAfjVLhJZx59S2chH71nU/GwFW50Cq1pcY+rE?= =?iso-8859-1?Q?mQ=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09749A275C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(346002)(376002)(39860400002)(396003)(366004)(199004)(189003)(26005)(256004)(386003)(6506007)(102836004)(99286004)(5660300002)(186003)(52116002)(1076003)(3846002)(486006)(7736002)(8676002)(44832011)(2616005)(1730700003)(305945005)(476003)(6116002)(2501003)(6436002)(5640700003)(6486002)(14454004)(478600001)(53936002)(6512007)(86362001)(105586002)(106356001)(316002)(25786009)(2351001)(81156014)(81166006)(54906003)(66066001)(6916009)(50226002)(71190400001)(68736007)(2906002)(8936002)(36756003)(71200400001)(97736004)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:DB7PR04MB4905;H:DB7PR04MB4252.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: q0UZmBzZZgGbilP7R0bjq1r2fbby7/KnkWNaI/szIwfV5nTqB70V5BUHc5vUrrGKuTAIt9rQQ13ES5Qx/t12b0CrECkgCcDt8sPyOvvTMNMlZZR4SxVZssknASyB+/yJwo1+zFd/OiBDqEBK8Egy2Lvg0xTPwHg2GPkLl4MHDH2U0w5IIOXMRfcJU7S5Kgpw2sxR5VOkMIYDGORrJbrMpaYMQsHwEJ/kB77LZWu4PHxBrLxP80UUiHbnpqInyB4U9wujCiCkxOS1otA4k1X+LV4eUz5oCGjKiZQOSIXzff6ObFF64hHhtFdc31jww883DhF47a4PVrfhLigCfRsBg5RBSnHgdQdCiU058U/ZZRitj6RpXTFfdvxVobi5B3m83uE1KHa2odwa6nWKTy7eU55JGfLpmf9rntIgaxejiCY= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fba11e66-f461-4782-a608-08d6a6c3ee85 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Mar 2019 08:22:57.2915 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4905 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A previous fix ("tls: Fix write space handling") assumed that user space application gets informed about the socket send buffer availability when tls_push_sg() gets called. Inside tls_push_sg(), in case do_tcp_sendpages() returns 0, the function returns without calling ctx->sk_write_space. Further, the new function tls_sw_write_space() did not invoke ctx->sk_write_space. This leads to situation that user space application encounters a lockup always waiting for socket send buffer to become available. Rather than call ctx->sk_write_space from tls_push_sg(), it should be called from tls_write_space. So whenever tcp stack invokes sk->sk_write_space after freeing socket send buffer, we always declare the same to user space by the way of invoking ctx->sk_write_space. Fixes: 7463d3a2db0ef ("tls: Fix write space handling") Signed-off-by: Vakul Garg Reviewed-by: Boris Pismenny --- net/tls/tls_device.c | 3 --- net/tls/tls_main.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 4a1da837a733..135a7ee9db03 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -558,9 +558,6 @@ void tls_device_write_space(struct sock *sk, struct tls= _context *ctx) MSG_DONTWAIT | MSG_NOSIGNAL); sk->sk_allocation =3D sk_allocation; } - - if (!rc) - ctx->sk_write_space(sk); } =20 void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 17e8667917aa..df921a2904b9 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -146,7 +146,6 @@ int tls_push_sg(struct sock *sk, } =20 ctx->in_tcp_sendpages =3D false; - ctx->sk_write_space(sk); =20 return 0; } @@ -228,6 +227,8 @@ static void tls_write_space(struct sock *sk) else #endif tls_sw_write_space(sk, ctx); + + ctx->sk_write_space(sk); } =20 static void tls_ctx_free(struct tls_context *ctx) --=20 2.13.6