From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Siddh Raman Pant <code@siddh.me>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Suman Ghosh <sumang@marvell.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+bbe84a4010eeea00982d@syzkaller.appspotmail.com
Subject: Re: [PATCH net-next v6 1/2] nfc: llcp_core: Hold a ref to llcp_local->dev when holding a ref to llcp_local
Date: Mon, 18 Dec 2023 10:39:00 +0100 [thread overview]
Message-ID: <6160aa1e-5f77-4d7d-aafd-e1ac7606bf06@linaro.org> (raw)
In-Reply-To: <0d812b9aae2f16691d373460b06c5f3e098ed2a6.1702816635.git.code@siddh.me>
On 17/12/2023 14:11, Siddh Raman Pant wrote:
> static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
> @@ -959,8 +974,18 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
> }
>
> new_sock = nfc_llcp_sock(new_sk);
> - new_sock->dev = local->dev;
> +
> new_sock->local = nfc_llcp_local_get(local);
> + if (!new_sock->local) {
> + reason = LLCP_DM_REJ;
> + release_sock(&sock->sk);
> + sock_put(&sock->sk);
> + sock_put(&new_sock->sk);
Why is this needed? Which part earlier gets the reference?
> + nfc_llcp_sock_free(new_sock);
This order is still wrong. Unwinding is almost always done in reversed
order, for good reasons. Why do you unwind in other order?
> + goto fail;
> + }
> +
> + new_sock->dev = local->dev;
> new_sock->rw = sock->rw;
> new_sock->miux = sock->miux;
Best regards,
Krzysztof
next prev parent reply other threads:[~2023-12-18 9:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-17 13:11 [PATCH net-next v6 0/2] nfc: Fix UAF during datagram sending caused by missing refcounting Siddh Raman Pant
2023-12-17 13:11 ` [PATCH net-next v6 1/2] nfc: llcp_core: Hold a ref to llcp_local->dev when holding a ref to llcp_local Siddh Raman Pant
2023-12-18 9:39 ` Krzysztof Kozlowski [this message]
2023-12-18 18:55 ` Siddh Raman Pant
2023-12-17 13:11 ` [PATCH net-next v6 2/2] nfc: Do not send datagram if socket state isn't LLCP_BOUND Siddh Raman Pant
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=6160aa1e-5f77-4d7d-aafd-e1ac7606bf06@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=code@siddh.me \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sumang@marvell.com \
--cc=syzbot+bbe84a4010eeea00982d@syzkaller.appspotmail.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
all inboxes | Powered by JetHome®