diff mbox series

[net] net/tls: Fix kernel panic when socket is in tls toe mode

Message ID 20201204210929.7892-1-vinay.yadav@chelsio.com
State Superseded
Headers show
Series [net] net/tls: Fix kernel panic when socket is in tls toe mode | expand

Commit Message

Vinay Kumar Yadav Dec. 4, 2020, 9:09 p.m. UTC
When socket is in tls-toe (TLS_HW_RECORD) and connections
are established in kernel stack, on every connection close
it clears tls context which is created once on socket creation,
causing kernel panic. fix it by not initializing listen in
kernel stack incase of tls-toe, allow listen in only adapter.

Fixes: dd0bed1665d6 ("tls: support for Inline tls record")
Signed-off-by: Rohit Maheshwari <rohitm@chelsio.com>
Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
---
 net/tls/tls_toe.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

kernel test robot Dec. 5, 2020, 6:10 a.m. UTC | #1
Hi Vinay,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net/master]

url:    https://github.com/0day-ci/linux/commits/Vinay-Kumar-Yadav/net-tls-Fix-kernel-panic-when-socket-is-in-tls-toe-mode/20201205-051743
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git bbe2ba04c5a92a49db8a42c850a5a2f6481e47eb
config: x86_64-randconfig-a014-20201204 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project fc7818f5d6906555cebad2c2e7c313a383b9cb82)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/293ac488f7830f7f2a6d8baa08d4c9240e8cbe38
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Vinay-Kumar-Yadav/net-tls-Fix-kernel-panic-when-socket-is-in-tls-toe-mode/20201205-051743
        git checkout 293ac488f7830f7f2a6d8baa08d4c9240e8cbe38
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> net/tls/tls_toe.c:109:4: warning: variable 'err' is uninitialized when used here [-Wuninitialized]

                           err |= dev->hash(dev, sk);
                           ^~~
   net/tls/tls_toe.c:102:9: note: initialize the variable 'err' to silence this warning
           int err;
                  ^
                   = 0
   1 warning generated.

vim +/err +109 net/tls/tls_toe.c

08700dab816847 Jakub Kicinski 2019-10-03   98  
0eb8745e03c9ed Jakub Kicinski 2019-10-03   99  int tls_toe_hash(struct sock *sk)
08700dab816847 Jakub Kicinski 2019-10-03  100  {
08700dab816847 Jakub Kicinski 2019-10-03  101  	struct tls_toe_device *dev;
08700dab816847 Jakub Kicinski 2019-10-03  102  	int err;
08700dab816847 Jakub Kicinski 2019-10-03  103  
08700dab816847 Jakub Kicinski 2019-10-03  104  	spin_lock_bh(&device_spinlock);
08700dab816847 Jakub Kicinski 2019-10-03  105  	list_for_each_entry(dev, &device_list, dev_list) {
08700dab816847 Jakub Kicinski 2019-10-03  106  		if (dev->hash) {
08700dab816847 Jakub Kicinski 2019-10-03  107  			kref_get(&dev->kref);
08700dab816847 Jakub Kicinski 2019-10-03  108  			spin_unlock_bh(&device_spinlock);
08700dab816847 Jakub Kicinski 2019-10-03 @109  			err |= dev->hash(dev, sk);
08700dab816847 Jakub Kicinski 2019-10-03  110  			kref_put(&dev->kref, dev->release);
08700dab816847 Jakub Kicinski 2019-10-03  111  			spin_lock_bh(&device_spinlock);
08700dab816847 Jakub Kicinski 2019-10-03  112  		}
08700dab816847 Jakub Kicinski 2019-10-03  113  	}
08700dab816847 Jakub Kicinski 2019-10-03  114  	spin_unlock_bh(&device_spinlock);
08700dab816847 Jakub Kicinski 2019-10-03  115  
08700dab816847 Jakub Kicinski 2019-10-03  116  	if (err)
0eb8745e03c9ed Jakub Kicinski 2019-10-03  117  		tls_toe_unhash(sk);
08700dab816847 Jakub Kicinski 2019-10-03  118  	return err;
08700dab816847 Jakub Kicinski 2019-10-03  119  }
08700dab816847 Jakub Kicinski 2019-10-03  120  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/net/tls/tls_toe.c b/net/tls/tls_toe.c
index 7e1330f19..f74b647d3 100644
--- a/net/tls/tls_toe.c
+++ b/net/tls/tls_toe.c
@@ -81,7 +81,6 @@  int tls_toe_bypass(struct sock *sk)
 
 void tls_toe_unhash(struct sock *sk)
 {
-	struct tls_context *ctx = tls_get_ctx(sk);
 	struct tls_toe_device *dev;
 
 	spin_lock_bh(&device_spinlock);
@@ -95,16 +94,13 @@  void tls_toe_unhash(struct sock *sk)
 		}
 	}
 	spin_unlock_bh(&device_spinlock);
-	ctx->sk_proto->unhash(sk);
 }
 
 int tls_toe_hash(struct sock *sk)
 {
-	struct tls_context *ctx = tls_get_ctx(sk);
 	struct tls_toe_device *dev;
 	int err;
 
-	err = ctx->sk_proto->hash(sk);
 	spin_lock_bh(&device_spinlock);
 	list_for_each_entry(dev, &device_list, dev_list) {
 		if (dev->hash) {