From owner-svn-src-head@freebsd.org Thu May 30 13:40:52 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9948F15C3453; Thu, 30 May 2019 13:40:52 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3CFD48B292; Thu, 30 May 2019 13:40:52 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1947219CCC; Thu, 30 May 2019 13:40:52 +0000 (UTC) (envelope-from mw@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4UDepZR075260; Thu, 30 May 2019 13:40:51 GMT (envelope-from mw@FreeBSD.org) Received: (from mw@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4UDeplw075259; Thu, 30 May 2019 13:40:51 GMT (envelope-from mw@FreeBSD.org) Message-Id: <201905301340.x4UDeplw075259@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mw set sender to mw@FreeBSD.org using -f From: Marcin Wojtas Date: Thu, 30 May 2019 13:40:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348410 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: mw X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 348410 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3CFD48B292 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 May 2019 13:40:52 -0000 Author: mw Date: Thu May 30 13:40:51 2019 New Revision: 348410 URL: https://svnweb.freebsd.org/changeset/base/348410 Log: Fix Tx offloads for fragmented pkt headers in ENA If the headers of the packets are split into multiple segments of the mbuf chain, the previous version of ena_tx_csum which was assuming, that all segments will lay in the first mbuf, will eventually fail to map the headers properties to meta descriptor. That will cause Tx checksum offload to do not work and was leading to memory corruption. It could even cause the crash of the system. Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc. Modified: head/sys/dev/ena/ena.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Thu May 30 13:39:25 2019 (r348409) +++ head/sys/dev/ena/ena.c Thu May 30 13:40:51 2019 (r348410) @@ -2683,6 +2683,7 @@ ena_tx_csum(struct ena_com_tx_ctx *ena_tx_ctx, struct { struct ena_com_tx_meta *ena_meta; struct ether_vlan_header *eh; + struct mbuf *mbuf_next; u32 mss; bool offload; uint16_t etype; @@ -2690,6 +2691,7 @@ ena_tx_csum(struct ena_com_tx_ctx *ena_tx_ctx, struct struct ip *ip; int iphlen; struct tcphdr *th; + int offset; offload = false; ena_meta = &ena_tx_ctx->ena_meta; @@ -2719,9 +2721,12 @@ ena_tx_csum(struct ena_com_tx_ctx *ena_tx_ctx, struct ehdrlen = ETHER_HDR_LEN; } - ip = (struct ip *)(mbuf->m_data + ehdrlen); + mbuf_next = m_getptr(mbuf, ehdrlen, &offset); + ip = (struct ip *)(mtodo(mbuf_next, offset)); iphlen = ip->ip_hl << 2; - th = (struct tcphdr *)((caddr_t)ip + iphlen); + + mbuf_next = m_getptr(mbuf, iphlen + ehdrlen, &offset); + th = (struct tcphdr *)(mtodo(mbuf_next, offset)); if ((mbuf->m_pkthdr.csum_flags & CSUM_IP) != 0) { ena_tx_ctx->l3_csum_enable = 1;