From patchwork Tue Mar 20 17:53:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Watson X-Patchwork-Id: 10297679 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 75CB360386 for ; Tue, 20 Mar 2018 17:55:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6267E2654B for ; Tue, 20 Mar 2018 17:55:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56D1D28581; Tue, 20 Mar 2018 17:55:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDEDE2654B for ; Tue, 20 Mar 2018 17:55:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751475AbeCTRzS (ORCPT ); Tue, 20 Mar 2018 13:55:18 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:51314 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751390AbeCTRzR (ORCPT ); Tue, 20 Mar 2018 13:55:17 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2KHnxXh011918; Tue, 20 Mar 2018 10:54:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=8yAshlpbhDZax1ivTJAvypAooEiTRDh8HRdh5FWV65k=; b=P1/3C5UOjydVQ54Lb4SBiCDQXKgi7fBRd6eNRjklp8jMyF5k133zqYfFqncLcBljcuGL H3ttch1BtW4IjweEMHYdX1URy+6+VIrmNGmqVQHtalrumv98gFZzJgXGCHeitjyseBc/ fgTb4h+Wm1S7JWDI6IsSPklacxqGFc8nprw= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2gu70eg0xt-3 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 20 Mar 2018 10:54:24 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.31) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 20 Mar 2018 13:54:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8yAshlpbhDZax1ivTJAvypAooEiTRDh8HRdh5FWV65k=; b=iwnblrem+yvkyN246nubXQlPdlBftalqn9X7RPJZ3Pl429SvY7uj0X3u2FlMQAytdZ4RZO3wYkSJPZjbZmebdA7AEo31xopDdHq3Q3du/1F4GVUSlmxQ1V5yJdacenEFI03AXFExeFGenAOzPX+gbPlY7oErOT4HFDUa+J+XXgU= Received: from localhost (2620:10d:c090:180::1:828d) by MWHPR15MB1135.namprd15.prod.outlook.com (2603:10b6:320:22::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Tue, 20 Mar 2018 17:54:02 +0000 Date: Tue, 20 Mar 2018 10:53:59 -0700 From: Dave Watson To: "David S. Miller" , Tom Herbert , Alexei Starovoitov , , , , CC: Atul Gupta , Vakul Garg , Hannes Frederic Sowa , Steffen Klassert , John Fastabend , Daniel Borkmann Subject: [PATCH net-next 3/6] tls: Pass error code explicitly to tls_err_abort Message-ID: <20180320175359.GA23863@davejwatson-mba.local> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) X-Originating-IP: [2620:10d:c090:180::1:828d] X-ClientProxiedBy: CY4PR18CA0035.namprd18.prod.outlook.com (2603:10b6:903:9a::21) To MWHPR15MB1135.namprd15.prod.outlook.com (2603:10b6:320:22::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b12b1817-2933-4a5a-7290-08d58e8b9140 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:MWHPR15MB1135; X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1135; 3:FHkAGNTi5nwYLHRZ6xEwtZahZpLUxE1W/zj9b72mXRsDAf1L/Cztc/GmuBXxYZQcVCzi77qXcGnR1uRprdxfhZb2avnZfBWIkd5db80ORdtZd6EiOBwCRapP+5MXGpXvW7X2CgRejbjL/Q3ZpkDbL02iUmtXWW0azVxvndATfGV8r/sBzbUOgYfkaj5C5tZTx9ZQ3DLjfDN4b1gGMDTZDd5IetE30AfATvMpNMZ6qlUDMJaVBr8Tr42oCkHLFEBn; 25:DDRw9x4K01TUQBoj19A8aDiFFPaSZGIjwFAGWBJK4UOK+xsLnyOLTGt7FV2Ofv7P1u5+H3MlSCsHzh0QGfa6HVxeqYXb82MNdmeVUfxpozllU2PIs0TCAvwwKzRyCHsL9jIVE8R1romL9B9VtyGmPyJ5W2O1edPKazzYERY6WHiBa/YC9NRhBs0UiuVLxbAfnBBxANXNmOY6aINqsybWwqXgAwetvvoTvSC5X36ojBZ/+KBpPh+C5sIhFyadYLHBBGFviivQRt176IQqp6qlk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ADA/1mlz9kWLvBUz+tjcxk2eU8X7AV4cUwKA/cX7X+3R89SY2EqRlckZNsjF7ApD3HJBGMnasEGcz0vn8cER4zREFOA/j/OYMX2dZFJgyHWMPUagZwd577mdoWc2pz4VtZFMJ1aRx/Os2N+661VISPLNyADHLVMhovcKR2eqWKDxF4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(266576461109395); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(11241501184)(944501313)(52105095)(3002001)(10201501046)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:MWHPR15MB1135; BCL:0; PCL:0; RULEID:; SRVR:MWHPR15MB1135; X-Forefront-PRVS: 061725F016 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(366004)(396003)(39860400002)(346002)(376002)(39380400002)(199004)(189003)(575784001)(81156014)(52116002)(316002)(97736004)(52396003)(76176011)(6496006)(81166006)(8936002)(47776003)(106356001)(76506005)(33896004)(59450400001)(8676002)(105586002)(50466002)(68736007)(33656002)(386003)(98436002)(46003)(16586007)(6486002)(53936002)(2906002)(16526019)(2950100002)(186003)(6666003)(9686003)(58126008)(54906003)(110136005)(8656006)(5660300001)(1076002)(86362001)(4326008)(39060400002)(305945005)(7736002)(478600001)(25786009)(23726003)(6116002)(7416002)(18370500001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR15MB1135; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR15MB1135; 23:YrHKffeN0/XDfZSgwoTO2AHaLDwszwBAQ8hjhtWyg?= =?us-ascii?Q?+dyWzSUbJM/G4R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H/dz8mjkXkHTbusFeu5jbuJZp6oveF2j1zugVQ0DInGSlg=; 5:5AobQdSUpNqyjXjIkhY8oj4SENMRBdkzjo+isAbgL3ST+F0HjWJnkWfD7WK4nJib/ujsieewYgHTu4S6U4SpJJ69AESH8EY556z+w+su5wcwZfztLtIGaNRB1aPS5GOCbylNZFFeflwdpx4JnzGirPT6lP6rm0nKQ5+BzvbBPlA=; 24:Mipf4MQZygBzJMf2CE/vx22NtIKm7Zc2TILSnzmn76yf36wvsxZw6u96wTvoPhGcLLaoOpXui8xRLno4EymTnrdaFVM6DRDGqTR60rF3PwE=; 7:xOy5R/dqGrMtRV8t5zcevf9K84IyTWZf8gThGfhJq8bOZ/2Vr2sk2TkIj8fW9q5S3bxHRYWNzLiBlucabUJj/HDHJHJ7rzX3cSCXjmHlxHKvwrnekVt5jTUlyWLVdkXsLCnC15nl0XED5rP4IUt3eVi8yzeA39M6hKdBSBy5wvjAZkNdsFyucLdoSgtk7yLPt9ohd3IKhre3NUftNkrLfUqFlOC9SXVvWOxLru1bWLZPooAQGmOADN7BeSx3+jb9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR15MB1135; 20:VuiLlQ0PVVWVZ1R020vEXSgjyZvPtitY/gtfofmiVf4rylP6PHgE0lX7prGY+9PypVSZbb1JxxOlBlaBwkD7iAqffWqmuRrN9Yvq6VpCjgC/wSxDXQIxoHHI/ZGKfyPZpjLETpHKAJQ9mH2aiTg/GnbjYNnNVwl5GLtYxnTjzE0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2018 17:54:02.9592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b12b1817-2933-4a5a-7290-08d58e8b9140 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1135 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-20_06:, , signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Pass EBADMSG explicitly to tls_err_abort. Receive path will pass additional codes - EMSGSIZE if framing is larger than max TLS record size, EINVAL if TLS version mismatch. Signed-off-by: Dave Watson --- include/net/tls.h | 6 +++--- net/tls/tls_sw.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 019e52d..6b44875 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -174,9 +174,9 @@ static inline bool tls_is_pending_open_record(struct tls_context *tls_ctx) return tls_ctx->pending_open_record_frags; } -static inline void tls_err_abort(struct sock *sk) +static inline void tls_err_abort(struct sock *sk, int err) { - sk->sk_err = EBADMSG; + sk->sk_err = err; sk->sk_error_report(sk); } @@ -197,7 +197,7 @@ static inline void tls_advance_record_sn(struct sock *sk, struct cipher_context *ctx) { if (tls_bigint_increment(ctx->rec_seq, ctx->rec_seq_size)) - tls_err_abort(sk); + tls_err_abort(sk, EBADMSG); tls_bigint_increment(ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, ctx->iv_size); } diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index dd4441d..6a0a669 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -269,7 +269,7 @@ static int tls_push_record(struct sock *sk, int flags, /* Only pass through MSG_DONTWAIT and MSG_NOSIGNAL flags */ rc = tls_push_sg(sk, tls_ctx, ctx->sg_encrypted_data, 0, flags); if (rc < 0 && rc != -EAGAIN) - tls_err_abort(sk); + tls_err_abort(sk, EBADMSG); tls_advance_record_sn(sk, &tls_ctx->tx); return rc;