From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: gregkh@linuxfoundation.org, davem@davemloft.net,
smohanad@codeaurora.org, jhugo@codeaurora.org,
kvalo@codeaurora.org, hemantk@codeaurora.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, clew@codeaurora.org
Subject: Re: [PATCH 2/3] net: qrtr: Add MHI transport layer
Date: Wed, 1 Apr 2020 13:50:00 +0530 [thread overview]
Message-ID: <20200401082000.GA15627@Mani-XPS-13-9360> (raw)
In-Reply-To: <20200401071023.GD663905@yoga>
On Wed, Apr 01, 2020 at 12:10:23AM -0700, Bjorn Andersson wrote:
> On Tue 31 Mar 23:44 PDT 2020, Manivannan Sadhasivam wrote:
> > diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c
> [..]
> > +static void qcom_mhi_qrtr_ul_callback(struct mhi_device *mhi_dev,
> > + struct mhi_result *mhi_res)
> > +{
> > + struct sk_buff *skb = (struct sk_buff *)mhi_res->buf_addr;
> > +
> > + consume_skb(skb);
> > + if (skb->sk)
> > + sock_put(skb->sk);
>
> Don't you need to do this in opposite order, to avoid a use after free?
>
I thought about it but the socket refcounting postulates in net/sock.h states:
"sk_free is called from any context: process, BH, IRQ. When it is called,
socket has no references from outside -> sk_free may release descendant
resources allocated by the socket, but to the time when it is called, socket
is NOT referenced by any hash tables, lists etc."
Here the sock it still referenced by skb, so I don't exactly know if we can
release the socket using sock_put() before consume_skb(). But on the other hand,
once skb is freed then accessing its member is clearly a use after free issue.
Maybe someone can clarify this?
Thanks,
Mani
> Regards,
> Bjorn
next prev parent reply other threads:[~2020-04-01 8:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 6:44 [PATCH 0/3] MHI bus improvements - Part 2 Manivannan Sadhasivam
2020-04-01 6:44 ` [PATCH 1/3] bus: mhi: core: Add support for MHI suspend and resume Manivannan Sadhasivam
2020-04-01 6:44 ` [PATCH 2/3] net: qrtr: Add MHI transport layer Manivannan Sadhasivam
2020-04-01 7:10 ` Bjorn Andersson
2020-04-01 8:20 ` Manivannan Sadhasivam [this message]
2020-04-01 6:44 ` [PATCH 3/3] net: qrtr: Do not depend on ARCH_QCOM Manivannan Sadhasivam
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=20200401082000.GA15627@Mani-XPS-13-9360 \
--to=manivannan.sadhasivam@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=clew@codeaurora.org \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=hemantk@codeaurora.org \
--cc=jhugo@codeaurora.org \
--cc=kvalo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=smohanad@codeaurora.org \
/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