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: <YiAOxRWZBHWDTpAs@pop-os.localdomain>
Date:   Wed, 2 Mar 2022 16:41:41 -0800
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Wang Yufen <wangyufen@...wei.com>
Cc:     john.fastabend@...il.com, daniel@...earbox.net,
        jakub@...udflare.com, lmb@...udflare.com, davem@...emloft.net,
        edumazet@...gle.com, yoshfuji@...ux-ipv6.org, dsahern@...nel.org,
        kuba@...nel.org, ast@...nel.org, andrii@...nel.org, kafai@...com,
        songliubraving@...com, yhs@...com, kpsingh@...nel.org,
        netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 1/4] bpf, sockmap: Fix memleak in
 sk_psock_queue_msg

On Wed, Mar 02, 2022 at 10:27:52AM +0800, Wang Yufen wrote:
> diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
> index fdb5375f0562..c5a2d6f50f25 100644
> --- a/include/linux/skmsg.h
> +++ b/include/linux/skmsg.h
> @@ -304,21 +304,16 @@ static inline void sock_drop(struct sock *sk, struct sk_buff *skb)
>  	kfree_skb(skb);
>  }
>  
> -static inline void drop_sk_msg(struct sk_psock *psock, struct sk_msg *msg)
> -{
> -	if (msg->skb)
> -		sock_drop(psock->sk, msg->skb);
> -	kfree(msg);
> -}
> -
>  static inline void sk_psock_queue_msg(struct sk_psock *psock,
>  				      struct sk_msg *msg)
>  {
>  	spin_lock_bh(&psock->ingress_lock);
>  	if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED))
>  		list_add_tail(&msg->list, &psock->ingress_msg);
> -	else
> -		drop_sk_msg(psock, msg);
> +	else {
> +		sk_msg_free(psock->sk, msg);

__sk_msg_free() calls sk_msg_init() at the end.

> +		kfree(msg);

Now you free it, hence the above sk_msg_init() is completely
unnecessary.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ