netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, Cong Wang <cong.wang@bytedance.com>,
	syzbot+9fc084a4348493ef65d2@syzkaller.appspotmail.com,
	syzbot+e696806ef96cdd2d87cd@syzkaller.appspotmail.com,
	Tom Herbert <tom@herbertland.com>
Subject: Re: [Patch net] kcm: get rid of unnecessary cleanup
Date: Tue, 23 Aug 2022 16:39:30 -0700	[thread overview]
Message-ID: <20220823163930.033b1330@kernel.org> (raw)
In-Reply-To: <20220822040628.177649-1-xiyou.wangcong@gmail.com>

On Sun, 21 Aug 2022 21:06:28 -0700 Cong Wang wrote:
> From: Cong Wang <cong.wang@bytedance.com>
> 
> strp_init() is called just a few lines above this csk->sk_user_data
> check, it also initializes strp->work etc., therefore, it is
> unnecessary to call strp_done() to cancel the freshly initialized
> work.
> 
> This also makes a lockdep warning reported by syzbot go away.
> 
> Reported-and-tested-by: syzbot+9fc084a4348493ef65d2@syzkaller.appspotmail.com
> Reported-by: syzbot+e696806ef96cdd2d87cd@syzkaller.appspotmail.com
> Fixes: e5571240236c ("kcm: Check if sk_user_data already set in kcm_attach")
> Fixes: dff8baa26117 ("kcm: Call strp_stop before strp_done in kcm_attach")
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Tom Herbert <tom@herbertland.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> ---
>  net/kcm/kcmsock.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
> index 71899e5a5a11..661c40cdab3e 100644
> --- a/net/kcm/kcmsock.c
> +++ b/net/kcm/kcmsock.c
> @@ -1425,8 +1425,6 @@ static int kcm_attach(struct socket *sock, struct socket *csock,
>  	 */
>  	if (csk->sk_user_data) {
>  		write_unlock_bh(&csk->sk_callback_lock);
> -		strp_stop(&psock->strp);
> -		strp_done(&psock->strp);
>  		kmem_cache_free(kcm_psockp, psock);
>  		err = -EALREADY;
>  		goto out;

Looks correct, but if strp_init() ever grows code which needs 
to be unwound in strp_done() we'd risk a leak. This seems to
have been Tom's intent.

Could we perhaps reorder the sk_user_data check vs the strp_init() call?
sock_map already calls strp_init() under the callback lock so we'd not
be introducing any new lock ordering.

      reply	other threads:[~2022-08-23 23:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22  4:06 [Patch net] kcm: get rid of unnecessary cleanup Cong Wang
2022-08-23 23:39 ` Jakub Kicinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220823163930.033b1330@kernel.org \
    --to=kuba@kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+9fc084a4348493ef65d2@syzkaller.appspotmail.com \
    --cc=syzbot+e696806ef96cdd2d87cd@syzkaller.appspotmail.com \
    --cc=tom@herbertland.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).