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]
Date:   Thu, 23 Jun 2022 11:42:43 +0200
From:   Paolo Abeni <pabeni@...hat.com>
To:     Hangyu Hua <hbh25y@...il.com>, krzysztof.kozlowski@...aro.org,
        sameo@...ux.intel.com, christophe.ricard@...il.com
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nfc: st21nfca: fix possible double free in
 st21nfca_im_recv_dep_res_cb()

On Wed, 2022-06-22 at 14:51 +0800, Hangyu Hua wrote:
> nfc_tm_data_received will free skb internally when it fails. There is no
> need to free skb in st21nfca_im_recv_dep_res_cb again.
> 
> Fix this by setting skb to NULL when nfc_tm_data_received fails.
> 
> Fixes: 1892bf844ea0 ("NFC: st21nfca: Adding P2P support to st21nfca in Initiator & Target mode")
> Signed-off-by: Hangyu Hua <hbh25y@...il.com>
> ---
>  drivers/nfc/st21nfca/dep.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nfc/st21nfca/dep.c b/drivers/nfc/st21nfca/dep.c
> index 1ec651e31064..07ac5688011c 100644
> --- a/drivers/nfc/st21nfca/dep.c
> +++ b/drivers/nfc/st21nfca/dep.c
> @@ -594,7 +594,8 @@ static void st21nfca_im_recv_dep_res_cb(void *context, struct sk_buff *skb,
>  			    ST21NFCA_NFC_DEP_PFB_PNI(dep_res->pfb + 1);
>  			size++;
>  			skb_pull(skb, size);
> -			nfc_tm_data_received(info->hdev->ndev, skb);
> +			if (nfc_tm_data_received(info->hdev->ndev, skb))
> +				skb = NULL;

Note that 'skb' not used (nor freed) by this function after this point:
the next 'break' statement refears to the inner switch, and land to the
execution flow to the 'return' statement a few lines below.
kfree_skb(skb) is never reached.

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ