From: Ioan Nicu <ioan.nicu.ext@nokia.com>
To: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Barry Wood <barry.wood@idt.com>,
Matt Porter <mporter@kernel.crashing.org>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Al Viro <viro@zeniv.linux.org.uk>,
Logan Gunthorpe <logang@deltatee.com>,
Chris Wilson <chris@chris-wilson.co.uk>,
Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
Frank Kunz <frank.kunz@nokia.com>,
Alexander Sverdlin <alexander.sverdlin@nokia.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rapidio: fix rio_dma_transfer error handling
Date: Fri, 13 Apr 2018 09:09:18 +0200 [thread overview]
Message-ID: <20180413070917.GA2794@nokia.com> (raw)
In-Reply-To: <d77db0b1-2cca-c0f6-987d-32ffb45cb16f@gmail.com>
Hi,
On Thu, Apr 12, 2018 at 07:44:01PM -0400, Alexandre Bounine wrote:
>
> On 2018-04-12 05:28 PM, Andrew Morton wrote:
> > On Thu, 12 Apr 2018 17:06:05 +0200 Ioan Nicu <ioan.nicu.ext@nokia.com> wrote:
> >
> > > Some of the mport_dma_req structure members were initialized late
> > > inside the do_dma_request() function, just before submitting the
> > > request to the dma engine. But we have some error branches before
> > > that. In case of such an error, the code would return on the error
> > > path and trigger the calling of dma_req_free() with a req structure
> > > which is not completely initialized. This causes a NULL pointer
> > > dereference in dma_req_free().
> > >
> > > This patch fixes these error branches by making sure that all
> > > necessary mport_dma_req structure members are initialized in
> > > rio_dma_transfer() immediately after the request structure gets
> > > allocated.
> >
> > This sounds like something which someone has actually triggered in a
> > real-world situation. So I added a cc:stable. Please let me know if
> > that was inappropriate.
> >
> > And please remember to always include all information regarding
> > end-user impact when fixing bugs.
> >
> This bug fix is applicable to versions starting from v4.6
Actually, this is something I broke with my previous patch where I added a
kref to the mport_dma_req structure. Before this patch, all the error paths
were doing kfree(req) instead of kref_put(&req->refcount, dma_req_free).
Now that dma_req_free() is called, it dereferences req->dmach, which is
initialized late in do_dma_request(), so dma_req_free() could be called
with a NULL req->dmach in some cases.
Sorry if I did not make this clear enough in the description.
Regards,
Ioan
next prev parent reply other threads:[~2018-04-13 7:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 15:06 [PATCH] rapidio: fix rio_dma_transfer error handling Ioan Nicu
2018-04-12 15:08 ` Alexander Sverdlin
2018-04-12 18:47 ` Alexandre Bounine
2018-04-12 21:28 ` Andrew Morton
2018-04-12 23:44 ` Alexandre Bounine
2018-04-13 7:09 ` Ioan Nicu [this message]
2018-04-13 21:16 ` Andrew Morton
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=20180413070917.GA2794@nokia.com \
--to=ioan.nicu.ext@nokia.com \
--cc=akpm@linux-foundation.org \
--cc=alex.bou9@gmail.com \
--cc=alexander.sverdlin@nokia.com \
--cc=barry.wood@idt.com \
--cc=chris@chris-wilson.co.uk \
--cc=christophe.jaillet@wanadoo.fr \
--cc=frank.kunz@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=mporter@kernel.crashing.org \
--cc=tvrtko.ursulin@intel.com \
--cc=viro@zeniv.linux.org.uk \
/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