Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4560045pja; Thu, 21 Nov 2019 21:52:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwTEIgHjSOfz/YdSgUTf3dCyHxSnjk34o/o6mhBht6+mzwELrpmA6exnE1+k45LcsD5GZ4i X-Received: by 2002:a17:906:c296:: with SMTP id r22mr3132311ejz.156.1574401953582; Thu, 21 Nov 2019 21:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574401953; cv=none; d=google.com; s=arc-20160816; b=dV8/s8XTmZ9vsBrM9Vl/MuSMihoLuHuq5gt1PC/OAE6TpGUp9NUeHG+W++uaEcdCgG LId7YXljBIy7y/eYyWCZhCl5bPC4XiNtbyUXbsFsiJ/avX/Bku93Txnw2Hn/WEGeixYx w+ayjjs6no1I66GicAqUVgus38CA3BbQFDu8grLNsYEpdBQAxgrgqcwHUguCSnsHoTY9 /nVqG6kcN9t++DvEv/1n4utsSOPvT/aMiZP5fWu5ak2mPu/E/WisAsvgojg+Kjapk6fs eaMNiJIt4oiDWxPyuB9rLxrj9MO1DWS+XUd3uzWki7FFshPxHZFqzf4Tu6ZY1Ibcf1ZY x/Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BYrb8kRnSqglYlDa3P5vlZrbDcE3jE9g3cKrJmjeUqI=; b=slnTIQs6qymYRo3hYfEok2cjVBeCbXax/ueU6niNxWMtDyW6yNDnJMaVjnyqNBjTOG A6QeoamzePydMIgCx6jxG4VVtJG4XhBUS3Vcp+Vdah75mNDLhyvTm/PniZfWqe+wty0M hsMvixCR0otFBtc5CgY1AQgypeTrJQA58Z6lYppFtDFs0qIm1MRy7eZi9prr2PTcOvQm SlzzrJKwtWHawhQJgu5Z6jd/NRP4IWxJ+WHvYdVqUGrq4R9wwF3oIRCphHe8CGnpQcrU B9DUXKlsIVCc0eeB51eI/RMEU9R9CvkIcyt97AB37g38bCtAr8/rgS+OHgv26hhlEXGU bCCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oUcPcbQf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si3342451ejy.239.2019.11.21.21.52.09; Thu, 21 Nov 2019 21:52:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oUcPcbQf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727683AbfKVFuZ (ORCPT + 99 others); Fri, 22 Nov 2019 00:50:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:54912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbfKVFuY (ORCPT ); Fri, 22 Nov 2019 00:50:24 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABAC82070E; Fri, 22 Nov 2019 05:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401823; bh=t2V8Sq0VvaON+weVpHvFiteFpdcQUZGqb6wrVV0MoQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oUcPcbQfjDTw+ucwaoPXjZ/epAlMPPNxLCDer6ppngcgCk9uh89XsQMmARrlGOpbD 7FcQYJhD8aIdyZDS4bXMscoT2G2TRp0c4rsszuPc74XrOHAQj4sfGx5AKZEKHLKzma /nDvHjSdw5ZVALP4cu7EaWnDj0LNZ5XmJMYpRlC4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Atul Gupta , "David S . Miller" , Sasha Levin , linux-crypto@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 066/219] crypto/chelsio/chtls: listen fails with multiadapt Date: Fri, 22 Nov 2019 00:46:38 -0500 Message-Id: <20191122054911.1750-59-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Atul Gupta [ Upstream commit 6422ccc5fbefbd219f3fab133f698e58f5aa44eb ] listen fails when more than one tls capable device is registered. tls_hw_hash is called for each dev which loops again for each cdev_list causing listen failure. Hence call chtls_listen_start/stop for specific device than loop over all devices. Signed-off-by: Atul Gupta Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/crypto/chelsio/chtls/chtls.h | 5 +++ drivers/crypto/chelsio/chtls/chtls_main.c | 50 ++++++++++++++--------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/chelsio/chtls/chtls.h b/drivers/crypto/chelsio/chtls/chtls.h index 7725b6ee14efb..fcb6747ed29ea 100644 --- a/drivers/crypto/chelsio/chtls/chtls.h +++ b/drivers/crypto/chelsio/chtls/chtls.h @@ -153,6 +153,11 @@ struct chtls_dev { unsigned int cdev_state; }; +struct chtls_listen { + struct chtls_dev *cdev; + struct sock *sk; +}; + struct chtls_hws { struct sk_buff_head sk_recv_queue; u8 txqid; diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c index f59b044ebd255..2bf084afe9b58 100644 --- a/drivers/crypto/chelsio/chtls/chtls_main.c +++ b/drivers/crypto/chelsio/chtls/chtls_main.c @@ -55,24 +55,19 @@ static void unregister_listen_notifier(struct notifier_block *nb) static int listen_notify_handler(struct notifier_block *this, unsigned long event, void *data) { - struct chtls_dev *cdev; - struct sock *sk; - int ret; + struct chtls_listen *clisten; + int ret = NOTIFY_DONE; - sk = data; - ret = NOTIFY_DONE; + clisten = (struct chtls_listen *)data; switch (event) { case CHTLS_LISTEN_START: + ret = chtls_listen_start(clisten->cdev, clisten->sk); + kfree(clisten); + break; case CHTLS_LISTEN_STOP: - mutex_lock(&cdev_list_lock); - list_for_each_entry(cdev, &cdev_list, list) { - if (event == CHTLS_LISTEN_START) - ret = chtls_listen_start(cdev, sk); - else - chtls_listen_stop(cdev, sk); - } - mutex_unlock(&cdev_list_lock); + chtls_listen_stop(clisten->cdev, clisten->sk); + kfree(clisten); break; } return ret; @@ -90,8 +85,9 @@ static int listen_backlog_rcv(struct sock *sk, struct sk_buff *skb) return 0; } -static int chtls_start_listen(struct sock *sk) +static int chtls_start_listen(struct chtls_dev *cdev, struct sock *sk) { + struct chtls_listen *clisten; int err; if (sk->sk_protocol != IPPROTO_TCP) @@ -102,21 +98,33 @@ static int chtls_start_listen(struct sock *sk) return -EADDRNOTAVAIL; sk->sk_backlog_rcv = listen_backlog_rcv; + clisten = kmalloc(sizeof(*clisten), GFP_KERNEL); + if (!clisten) + return -ENOMEM; + clisten->cdev = cdev; + clisten->sk = sk; mutex_lock(¬ify_mutex); err = raw_notifier_call_chain(&listen_notify_list, - CHTLS_LISTEN_START, sk); + CHTLS_LISTEN_START, clisten); mutex_unlock(¬ify_mutex); return err; } -static void chtls_stop_listen(struct sock *sk) +static void chtls_stop_listen(struct chtls_dev *cdev, struct sock *sk) { + struct chtls_listen *clisten; + if (sk->sk_protocol != IPPROTO_TCP) return; + clisten = kmalloc(sizeof(*clisten), GFP_KERNEL); + if (!clisten) + return; + clisten->cdev = cdev; + clisten->sk = sk; mutex_lock(¬ify_mutex); raw_notifier_call_chain(&listen_notify_list, - CHTLS_LISTEN_STOP, sk); + CHTLS_LISTEN_STOP, clisten); mutex_unlock(¬ify_mutex); } @@ -138,15 +146,19 @@ static int chtls_inline_feature(struct tls_device *dev) static int chtls_create_hash(struct tls_device *dev, struct sock *sk) { + struct chtls_dev *cdev = to_chtls_dev(dev); + if (sk->sk_state == TCP_LISTEN) - return chtls_start_listen(sk); + return chtls_start_listen(cdev, sk); return 0; } static void chtls_destroy_hash(struct tls_device *dev, struct sock *sk) { + struct chtls_dev *cdev = to_chtls_dev(dev); + if (sk->sk_state == TCP_LISTEN) - chtls_stop_listen(sk); + chtls_stop_listen(cdev, sk); } static void chtls_register_dev(struct chtls_dev *cdev) -- 2.20.1