lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230630032653.26426-1-qiang.zhang1211@gmail.com>
Date:   Fri, 30 Jun 2023 11:26:53 +0800
From:   Zqiang <qiang.zhang1211@...il.com>
To:     davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, qiang.zhang1211@...il.com
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] net: Destroy previously created kthreads after failing to set napi threaded mode

When setting 1 to enable napi threaded mode, will traverse dev->napi_list
and create kthread for napi->thread, if creation fails, the dev->threaded
will be set to false and we will clear NAPI_STATE_THREADED bit for all
napi->state in dev->napi_list, even if some napi that has successfully
created the kthread before. as a result, for successfully created napi
kthread, they will never be used.

This commit therefore destroy previously created napi->thread if setting
napi threaded mode fails.

Signed-off-by: Zqiang <qiang.zhang1211@...il.com>
---
 net/core/dev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 69a3e544676c..9929f0567150 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6317,10 +6317,13 @@ int dev_set_threaded(struct net_device *dev, bool threaded)
 	 * This should not cause hiccups/stalls to the live traffic.
 	 */
 	list_for_each_entry(napi, &dev->napi_list, dev_list) {
-		if (threaded)
+		if (threaded) {
 			set_bit(NAPI_STATE_THREADED, &napi->state);
-		else
+		} else {
 			clear_bit(NAPI_STATE_THREADED, &napi->state);
+			if (napi->thread)
+				kthread_stop(napi->thread);
+		}
 	}
 
 	return err;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ