From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Ferry Toth <ftoth@exalondelft.nl>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: avoid unsafe code pattern in find_pinctrl()
Date: Tue, 17 Oct 2023 17:08:05 +0300 [thread overview]
Message-ID: <ZS6VReT2Md9UNjFu@smile.fi.intel.com> (raw)
In-Reply-To: <CACRpkdbuOn4gKBE-tB4MHQ3mx_ujQZLdPp1hp75ANFgsGb1jQQ@mail.gmail.com>
On Mon, Sep 25, 2023 at 03:30:53PM +0200, Linus Walleij wrote:
> On Wed, Sep 20, 2023 at 8:09 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>
> > The code in find_pinctrl() takes a mutex and traverses a list of pinctrl
> > structures. Later the caller bumps up reference count on the found
> > structure. Such pattern is not safe as pinctrl that was found may get
> > deleted before the caller gets around to increasing the reference count.
> >
> > Fix this by taking the reference count in find_pinctrl(), while it still
> > holds the mutex.
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> After some thinking, applied for fixes and tagged for stable as
> it is a very real problem that can cause random crashes under
> the right circumstances.
Follow the strange and weird bisection [1] this one at least confirmed to be
the culprit by reverting the only one from the v6.6-rc6 based branch.
Long story short, after this commit my user space setup (minimal Buildroot + Busybox)
has become broken in a sense of MMC enumeration. My all scripts were pointed to
mmcblk0 which becomes out of a sudden mmcblk1!
git bisect start
# status: waiting for both good and bad commits
# bad: [58720809f52779dc0f08e53e54b014209d13eebb] Linux 6.6-rc6
git bisect bad 58720809f52779dc0f08e53e54b014209d13eebb
# status: waiting for good commit(s), bad commit known
# good: [2dde18cd1d8fac735875f2e4987f11817cc0bc2c] Linux 6.5
git bisect good 2dde18cd1d8fac735875f2e4987f11817cc0bc2c
# good: [47ca50600efcf994adb62a9a4e75c77d91bd0781] Merge tag 'soc-defconfig-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good 47ca50600efcf994adb62a9a4e75c77d91bd0781
# good: [b89b029377c8c441649c7a6be908386e74ea9420] Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
git bisect good b89b029377c8c441649c7a6be908386e74ea9420
# good: [2a5a4326e58339a26cd1510259e7310b8c0980ff] Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
git bisect good 2a5a4326e58339a26cd1510259e7310b8c0980ff
# good: [85eba5f1759f9eb89273225027254ced57bd18a2] Merge tag 'mm-hotfixes-stable-2023-09-23-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect good 85eba5f1759f9eb89273225027254ced57bd18a2
# good: [b78b18fb8ee19f7a05f20c3abc865b3bfe182884] Merge tag 'erofs-for-6.6-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs
git bisect good b78b18fb8ee19f7a05f20c3abc865b3bfe182884
# bad: [9a5a14948574ee09f339990cab69b4ab997d2f7d] Merge tag 'soc-fixes-6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect bad 9a5a14948574ee09f339990cab69b4ab997d2f7d
# good: [b9ddbb0cde2adcedda26045cc58f31316a492215] Merge tag 'parisc-for-6.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux
git bisect good b9ddbb0cde2adcedda26045cc58f31316a492215
# good: [b711538a40b794ccc83838fb66990a091c56c101] Merge tag 'hyperv-fixes-signed-20231009' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
git bisect good b711538a40b794ccc83838fb66990a091c56c101
# good: [bab19d1b21547046b0a38dde948086f6cbcaefaa] Merge tag 'for-linus-2023101101' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
git bisect good bab19d1b21547046b0a38dde948086f6cbcaefaa
# bad: [82a040a8fa9b4f3845eff73a69a9931a59335902] Merge tag 'pinctrl-v6.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl
git bisect bad 82a040a8fa9b4f3845eff73a69a9931a59335902
# good: [759d1b653f3c7c2249b7fe5f6b218f87a5842822] Merge tag 'for-6.6-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
git bisect good 759d1b653f3c7c2249b7fe5f6b218f87a5842822
# bad: [c153a4edff6ab01370fcac8e46f9c89cca1060c2] pinctrl: avoid unsafe code pattern in find_pinctrl()
git bisect bad c153a4edff6ab01370fcac8e46f9c89cca1060c2
# good: [87d315a34133edcb29c4cadbf196ec6c30dfd47b] pinctrl: nuvoton: wpcm450: fix out of bounds write
git bisect good 87d315a34133edcb29c4cadbf196ec6c30dfd47b
# good: [64061b67335e958e6328bcb5bb2b5490d57f3f59] pinctrl: starfive: jh7110: Add system pm ops to save and restore context
git bisect good 64061b67335e958e6328bcb5bb2b5490d57f3f59
# first bad commit: [c153a4edff6ab01370fcac8e46f9c89cca1060c2] pinctrl: avoid unsafe code pattern in find_pinctrl()
[1]: https://lore.kernel.org/r/20230830102434.xnlh66omhs6ninet@quack3
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-10-17 14:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 18:09 [PATCH] pinctrl: avoid unsafe code pattern in find_pinctrl() Dmitry Torokhov
2023-09-25 13:30 ` Linus Walleij
2023-10-17 14:08 ` Andy Shevchenko [this message]
2023-10-17 14:14 ` Andy Shevchenko
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=ZS6VReT2Md9UNjFu@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=dmitry.torokhov@gmail.com \
--cc=ftoth@exalondelft.nl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.