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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <672FAA6F-5DA7-4AA7-A049-96DF82CEEA18@fb.com>
Date:   Fri, 25 Oct 2019 19:11:21 +0000
From:   Vijay Khemka <vijaykhemka@...com>
To:     Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        "David S. Miller" <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "openbmc@...ts.ozlabs.org" <openbmc@...ts.ozlabs.org>,
        Joel Stanley <joel@....id.au>,
        "linux-aspeed@...ts.ozlabs.org" <linux-aspeed@...ts.ozlabs.org>
Subject: Re: [PATCH] net: ethernet: ftgmac100: Fix DMA coherency issue with SW
 checksum

Looks good to me. And I have tested it. It works perfectly fine.

Reviewed-by: Vijay Khemka <vijaykhemka@...com>
Tested-by: Vijay Khemka <vijaykhemka@...com>

On 10/24/19, 7:47 PM, "Benjamin Herrenschmidt" <benh@...nel.crashing.org> wrote:

    We are calling the checksum helper after the dma_map_single()
    call to map the packet. This is incorrect as the checksumming
    code will touch the packet from the CPU. This means the cache
    won't be properly flushes (or the bounce buffering will leave
    us with the unmodified packet to DMA).
    
    This moves the calculation of the checksum & vlan tags to
    before the DMA mapping.
    
    This also has the side effect of fixing another bug: If the
    checksum helper fails, we goto "drop" to drop the packet, which
    will not unmap the DMA mapping.
    
    Signed-off-by: Benjamin Herrenschmidt <benh@...nel.crashing.org>
    Fixes: 05690d633f30 ftgmac100: Upgrade to NETIF_F_HW_CSUM
    CC: stable@...r.kernel.org [v4.12+]
    ---
     drivers/net/ethernet/faraday/ftgmac100.c | 25 ++++++++++++------------
     1 file changed, 12 insertions(+), 13 deletions(-)
    
    diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
    index 9b7af94a40bb..96e9565f1e08 100644
    --- a/drivers/net/ethernet/faraday/ftgmac100.c
    +++ b/drivers/net/ethernet/faraday/ftgmac100.c
    @@ -727,6 +727,18 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
     	 */
     	nfrags = skb_shinfo(skb)->nr_frags;
     
    +	/* Setup HW checksumming */
    +	csum_vlan = 0;
    +	if (skb->ip_summed == CHECKSUM_PARTIAL &&
    +	    !ftgmac100_prep_tx_csum(skb, &csum_vlan))
    +		goto drop;
    +
    +	/* Add VLAN tag */
    +	if (skb_vlan_tag_present(skb)) {
    +		csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
    +		csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
    +	}
    +
     	/* Get header len */
     	len = skb_headlen(skb);
     
    @@ -753,19 +765,6 @@ static netdev_tx_t ftgmac100_hard_start_xmit(struct sk_buff *skb,
     	if (nfrags == 0)
     		f_ctl_stat |= FTGMAC100_TXDES0_LTS;
     	txdes->txdes3 = cpu_to_le32(map);
    -
    -	/* Setup HW checksumming */
    -	csum_vlan = 0;
    -	if (skb->ip_summed == CHECKSUM_PARTIAL &&
    -	    !ftgmac100_prep_tx_csum(skb, &csum_vlan))
    -		goto drop;
    -
    -	/* Add VLAN tag */
    -	if (skb_vlan_tag_present(skb)) {
    -		csum_vlan |= FTGMAC100_TXDES1_INS_VLANTAG;
    -		csum_vlan |= skb_vlan_tag_get(skb) & 0xffff;
    -	}
    -
     	txdes->txdes1 = cpu_to_le32(csum_vlan);
     
     	/* Next descriptor */
    
    
    

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ