From patchwork Mon Aug 17 15:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266265 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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 4B059C433E5 for ; Mon, 17 Aug 2020 18:06:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 271A82072E for ; Mon, 17 Aug 2020 18:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597687578; bh=sEXgLNETWRnYr2UqSnDJpMZ7mhrKfcrWV3ANRgsVbAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ggzda0q9dQAmeGhNtnJ8JZzEsv7WoMp010zeZestb/7yYdzG9YXVRWf/3oPt8Keyl iUUVHzeqwg5xP+FQI1kJfXPigeUhR5bx7r1ieFbb/VgmsRb2Yice3u+khfbclEiLWh Rgv6RxRNWMZNcLBF6ACdL7VZID1nJ6jeEr9DvrGc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388491AbgHQSGQ (ORCPT ); Mon, 17 Aug 2020 14:06:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:58952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388283AbgHQQIy (ORCPT ); Mon, 17 Aug 2020 12:08:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A81AD20888; Mon, 17 Aug 2020 16:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680533; bh=sEXgLNETWRnYr2UqSnDJpMZ7mhrKfcrWV3ANRgsVbAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ff6Hzxl4TzF5Fpa1MrFayNWC9l2asMi1Y4cSIKFI1LmCHq15GVfFcu4MqvknKysmv tFJdUYToSAGP2YCsWqX49hIkPI2VXiJztgYgtSJD6OMJKN2bEl76YnLBoKBshOkwjy uID4XqtA+1xnEYttIX/5BemyhonIAvUS0rumhfQ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ira Weiny , Jakub Kicinski , "David S. Miller" Subject: [PATCH 5.4 223/270] net/tls: Fix kmap usage Date: Mon, 17 Aug 2020 17:17:04 +0200 Message-Id: <20200817143806.877325542@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ira Weiny [ Upstream commit b06c19d9f827f6743122795570bfc0c72db482b0 ] When MSG_OOB is specified to tls_device_sendpage() the mapped page is never unmapped. Hold off mapping the page until after the flags are checked and the page is actually needed. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Ira Weiny Reviewed-by: Jakub Kicinski Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tls/tls_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -549,7 +549,7 @@ int tls_device_sendpage(struct sock *sk, { struct tls_context *tls_ctx = tls_get_ctx(sk); struct iov_iter msg_iter; - char *kaddr = kmap(page); + char *kaddr; struct kvec iov; int rc; @@ -564,6 +564,7 @@ int tls_device_sendpage(struct sock *sk, goto out; } + kaddr = kmap(page); iov.iov_base = kaddr + offset; iov.iov_len = size; iov_iter_kvec(&msg_iter, WRITE, &iov, 1, size);