Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1638920

Re: [PATCH 4.4 10/43] net: cavium: liquidio: Avoid dma_unmap_single on uninitialized ndata

From Ben Hutchings <ben.hutchings@codethink.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 4.4 10/43] net: cavium: liquidio: Avoid dma_unmap_single on uninitialized ndata
Date 2017-05-10 17:40 +0200
Message-ID <tFBSy-2s3-17@gated-at.bofh.it> (permalink)
References <tCr3j-5Nl-3@gated-at.bofh.it> <tCrG3-6ky-55@gated-at.bofh.it>
Organization Codethink Ltd.

Show all headers | View raw


On Mon, 2017-05-01 at 14:27 -0700, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.  If anyone has any objections, please let me know.
> 
> ------------------
> 
> From: Florian Fainelli <f.fainelli@gmail.com>
> 
> commit 8e6ce7ebeb34f0992f56de078c3744fb383657fa upstream.
> 
> The label lio_xmit_failed is used 3 times through liquidio_xmit() but it
> always makes a call to dma_unmap_single() using potentially
> uninitialized variables from "ndata" variable. Out of the 3 gotos, 2 run
> after ndata has been initialized, and had a prior dma_map_single() call.
> 
> Fix this by adding a new error label: lio_xmit_dma_failed which does
> this dma_unmap_single() and then processed with the lio_xmit_failed
> fallthrough.
> 
> Fixes: f21fb3ed364bb ("Add support of Cavium Liquidio ethernet adapters")
> Reported-by: coverity (CID 1309740)
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This is not a complete fix:

> ---
>  drivers/net/ethernet/cavium/liquidio/lio_main.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> @@ -2823,7 +2823,7 @@ static int liquidio_xmit(struct sk_buff
>  		if (!g) {
>  			netif_info(lio, tx_err, lio->netdev,
>  				   "Transmit scatter gather: glist null!\n");
> -			goto lio_xmit_failed;
> +			goto lio_xmit_dma_failed;
>  		}
>  
>  		cmdsetup.s.gather = 1;
[...]

This goto should not have been changed, as no DMA mapping has been
attempted at this point in the function.

This seems to have been fixed upstream by commit 6a885b60dad2 "liquidio:
Introduce new octeon2/3 header".  I leave it to you to work out how it
should be fixed in 4.4-stable.

Ben.

-- 
Ben Hutchings
Software Developer, Codethink Ltd.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/43] 4.4.66-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-01 23:30 +0200
  [PATCH 4.4 07/43] ext4: check if in-inode xattr is corrupted in ext4_expand_extra_isize_ea() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-01 23:30 +0200
  [PATCH 4.4 23/43] l2tp: take reference on sessions being dumped Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-01 23:30 +0200
  [PATCH 4.4 31/43] ip6mr: fix notification device destruction Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-01 23:40 +0200
  [PATCH 4.4 19/43] net: phy: handle state correctly in phy_stop_machine Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-01 23:40 +0200
  [PATCH 4.4 37/43] MIPS: KGDB: Use kernel context for sleeping threads Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-01 23:40 +0200
  [PATCH 4.4 24/43] l2tp: fix PPP pseudo-wire auto-loading Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 02/43] [media] xc2028: unlock on error in xc2028_set_config() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 04/43] clk: sunxi: Add apb0 gates for H3 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 03/43] ARM: OMAP2+: timer: add probe for clocksources Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 13/43] regulator: core: Clear the supply pointer if enabling fails Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 36/43] ALSA: seq: Dont break snd_use_lock_sync() loop by timeout Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 27/43] tcp: clear saved_syn in tcp_disconnect() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 05/43] crypto: testmgr - fix out of bound read in __test_aead() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 21/43] net/packet: fix overflow in check for tp_frame_nr Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 16/43] sparc64: kern_addr_valid regression Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 15/43] xen/x86: dont lose event interrupts Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 08/43] md:raid1: fix a dead loop when read from a WriteMostly disk Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 11/43] net_sched: close another race condition in tcf_mirred_release() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 38/43] MIPS: Avoid BUG warning in arch_check_elf Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 39/43] p9_client_readdir() fix Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 12/43] RDS: Fix the atomicity for congestion map update Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 18/43] net: neigh: guard against NULL solicit() method Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 35/43] ALSA: firewire-lib: fix inappropriate assignment between signed/unsigned type Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 43/43] ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 14/43] usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 17/43] sparc64: Fix kernel panic due to erroneous #ifdef surrounding pmd_write() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 09/43] MIPS: Fix crash registers on non-crashing CPUs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 10/43] net: cavium: liquidio: Avoid dma_unmap_single on uninitialized ndata Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
    Re: [PATCH 4.4 10/43] net: cavium: liquidio: Avoid dma_unmap_single  on uninitialized ndata Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-05-10 17:40 +0200
  [PATCH 4.4 22/43] net/packet: fix overflow in check for tp_reserve Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  [PATCH 4.4 26/43] sctp: listen on the sock only when its state is listening or closed Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-02 00:10 +0200
  Re: [PATCH 4.4 00/43] 4.4.66-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-05-02 16:00 +0200
  Re: [PATCH 4.4 00/43] 4.4.66-stable review Guenter Roeck <linux@roeck-us.net> - 2017-05-02 19:40 +0200

csiph-web