Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2673902pxb; Mon, 19 Apr 2021 10:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCGS6znshbdpFxHpqCxExxHPNGbVERyCorB/5IrxpnqBk1GS/Uo+VFQdkMga8Mg+K1Xzbt X-Received: by 2002:a17:906:154f:: with SMTP id c15mr23500307ejd.142.1618855059945; Mon, 19 Apr 2021 10:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618855059; cv=none; d=google.com; s=arc-20160816; b=YShv1uu7FvL1amtv73BKZ3wQSoZdlC/pDbIfZYa5AU78WtGuOigVOdlpkF90fayikC 6k10lKCIFBJ7T74hznyC7rZhnR0OleZuTx2E8jNbVBl5KfzpOawBDGmx1JHHL8w5JKc0 +Xtz7HYbYd5wX1M1nP3Iv9GSgMtbz69vQ1kefdu0M2RQFxftQWVFKf9IdXbIV2mQf+jM 1KP6GIxfAxUIHYX6sF50e6FDJ+HlaMYl/zf/tWliKVAR6rFu/9bXwhQr2HEG8xgFOnzt 3RNr5Y/bHXcZRN1K+TC05gAnGai/O2xqF5bZMufFuQMdu+rRPAv+88Jz3ziyRVvB6036 Yd1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U74CKknBIs+PdD89EdJ9n2I3SP5rG2uhn6DQivkkucA=; b=IxuDGdgHzUN3yPKuVBXfcnq56Mr45PeFe79b3Er24Qe/ZCychEyYi5T5slGFtZC811 LLgIoOV3lEHYi+2RjI1oKL8Ughl59zsw7jdxqLQTgCVfMWkiQk8W0kx/kM7ZoGZfgvPy orPbjtMPsFgpaPI5n24wCiPs98CRHwFmpcNCCtP5u2lN6yhYhSyC4yEu12AOtnleqKvI rBu5IBf+aV+9KfPas7bRqI0V2bQ66JRV1mvQyCfQppPoBBieqIYZXJPMEVRyIjreLlyr oSj/OBnsxg5LxVubBERPM/j+/qg5QNrUYJoUdRIX700rbbPYlL4y+OqEfF+mj9dkWQ+H I70g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r7L2aIsC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si12113238eje.57.2021.04.19.10.57.15; Mon, 19 Apr 2021 10:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r7L2aIsC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240784AbhDSNbH (ORCPT + 99 others); Mon, 19 Apr 2021 09:31:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:59636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241181AbhDSNVq (ORCPT ); Mon, 19 Apr 2021 09:21:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11C7B61400; Mon, 19 Apr 2021 13:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838280; bh=/Z6OCQUFL7u5EhYaxMUNJuVhH7l50zWkWy04jj07uMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r7L2aIsCk0EaIZMWkmhKhWl8udihSSydYOxXj0w4viZDylpVjnym56Vfu1F0ENMD7 VzCDizJBq66LuAxY2HtNla+UolVRxIo2zfbXWtCJ8W/PdKp10nyJP5Ojpu1fdZ4k9T YHrEngD0hvR1C1ZGlS9btXzTSmeC70k4EeDsi/EM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinay Kumar Yadav , Rohit Maheshwari , "David S. Miller" Subject: [PATCH 5.10 081/103] ch_ktls: Fix kernel panic Date: Mon, 19 Apr 2021 15:06:32 +0200 Message-Id: <20210419130530.582556602@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinay Kumar Yadav commit 1a73e427b824133940c2dd95ebe26b6dce1cbf10 upstream. Taking page refcount is not ideal and causes kernel panic sometimes. It's better to take tx_ctx lock for the complete skb transmit, to avoid page cleanup if ACK received in middle. Fixes: 5a4b9fe7fece ("cxgb4/chcr: complete record tx handling") Signed-off-by: Vinay Kumar Yadav Signed-off-by: Rohit Maheshwari Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c | 24 ++-------- 1 file changed, 5 insertions(+), 19 deletions(-) --- a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c @@ -2015,12 +2015,11 @@ static int chcr_ktls_xmit(struct sk_buff * we will send the complete record again. */ + spin_lock_irqsave(&tx_ctx->base.lock, flags); + do { - int i; cxgb4_reclaim_completed_tx(adap, &q->q, true); - /* lock taken */ - spin_lock_irqsave(&tx_ctx->base.lock, flags); /* fetch the tls record */ record = tls_get_record(&tx_ctx->base, tcp_seq, &tx_info->record_no); @@ -2079,11 +2078,11 @@ static int chcr_ktls_xmit(struct sk_buff tls_end_offset, skb_offset, 0); - spin_unlock_irqrestore(&tx_ctx->base.lock, flags); if (ret) { /* free the refcount taken earlier */ if (tls_end_offset < data_len) dev_kfree_skb_any(skb); + spin_unlock_irqrestore(&tx_ctx->base.lock, flags); goto out; } @@ -2093,16 +2092,6 @@ static int chcr_ktls_xmit(struct sk_buff continue; } - /* increase page reference count of the record, so that there - * won't be any chance of page free in middle if in case stack - * receives ACK and try to delete the record. - */ - for (i = 0; i < record->num_frags; i++) - __skb_frag_ref(&record->frags[i]); - /* lock cleared */ - spin_unlock_irqrestore(&tx_ctx->base.lock, flags); - - /* if a tls record is finishing in this SKB */ if (tls_end_offset <= data_len) { ret = chcr_end_part_handler(tx_info, skb, record, @@ -2127,13 +2116,9 @@ static int chcr_ktls_xmit(struct sk_buff data_len = 0; } - /* clear the frag ref count which increased locally before */ - for (i = 0; i < record->num_frags; i++) { - /* clear the frag ref count */ - __skb_frag_unref(&record->frags[i]); - } /* if any failure, come out from the loop. */ if (ret) { + spin_unlock_irqrestore(&tx_ctx->base.lock, flags); if (th->fin) dev_kfree_skb_any(skb); @@ -2148,6 +2133,7 @@ static int chcr_ktls_xmit(struct sk_buff } while (data_len > 0); + spin_unlock_irqrestore(&tx_ctx->base.lock, flags); atomic64_inc(&port_stats->ktls_tx_encrypted_packets); atomic64_add(skb_data_len, &port_stats->ktls_tx_encrypted_bytes);