From: Mateusz Guzik <mguzik@redhat.com>
To: Robert Foss <robert.foss@collabora.com>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>,
corbet@lwn.net, akpm@linux-foundation.org, vbabka@suse.cz,
mhocko@suse.com, koct9i@gmail.com, hughd@google.com,
n-horiguchi@ah.jp.nec.com, minchan@kernel.org,
john.stultz@linaro.org, ross.zwisler@linux.intel.com,
jmarchan@redhat.com, hannes@cmpxchg.org, mingo@kernel.org,
keescook@chromium.org, viro@zeniv.linux.org.uk,
gorcunov@openvz.org, mnfhuang@gmail.com, adobriyan@gmail.com,
calvinowens@fb.com, jdanis@google.com, jann@thejh.net,
sonnyrao@chromium.org, kirill.shutemov@linux.intel.com,
ldufour@linux.vnet.ibm.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, Ben Zhang <benzh@chromium.org>,
Bryan Freed <bfreed@chromium.org>,
Filipe Brandenburger <filbranden@chromium.org>,
Michal Hocko <mhocko@kernel.org>,
linux-api@vger.kernel.org
Subject: Re: [PACTH v4 1/3] mm, proc: Implement /proc/<pid>/totmaps
Date: Wed, 31 Aug 2016 19:04:16 +0200 [thread overview]
Message-ID: <20160831170415.pc2hlvb7fevpichy@mguzik> (raw)
In-Reply-To: <030a5655-bdc2-94a2-ee52-d6ea7be19a31@collabora.com>
On Wed, Aug 31, 2016 at 12:36:26PM -0400, Robert Foss wrote:
> On 2016-08-31 05:45 AM, Jacek Anaszewski wrote:
> > > +static void *m_totmaps_start(struct seq_file *p, loff_t *pos)
> > > +{
> > > + return NULL + (*pos == 0);
> > > +}
> > > +
> > > +static void *m_totmaps_next(struct seq_file *p, void *v, loff_t *pos)
> > > +{
> > > + ++*pos;
> > > + return NULL;
> > > +}
> > > +
> >
> > When reading totmaps of kernel processes the following NULL pointer
> > dereference occurs:
> >
> > Unable to handle kernel NULL pointer dereference at virtual address
> > 00000044
> > [<c06c01f4>] (down_read) from [<c022a154>] (totmaps_proc_show+0x2c/0x1e8)
> > [<c022a154>] (totmaps_proc_show) from [<c01fe564>] (seq_read+0x1c8/0x4b8)
> > [<c01fe564>] (seq_read) from [<c01dc850>] (__vfs_read+0x2c/0x110)
> > [<c01dc850>] (__vfs_read) from [<c01ddca0>] (vfs_read+0x8c/0x110)
> > [<c01ddca0>] (vfs_read) from [<c01ddd64>] (SyS_read+0x40/0x8c)
> > [<c01ddd64>] (SyS_read) from [<c0107900>] (ret_fast_syscall+0x0/0x3c)
> >
> > It seems that some protection is needed for such processes, so that
> > totmaps would return empty string then, like in case of smaps.
> >
>
> Thanks for the testing Jacek!
>
> I had a look around the corresponding smaps code, but I'm not seeing any
> checks, do you know where that check actually is made?
>
See m_start in f/sproc/task_mmu.c. It not only check for non-null mm,
but also tries to bump ->mm_users and only then proceeds to walk the mm.
--
Mateusz Guzik
next prev parent reply other threads:[~2016-08-31 17:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-16 22:33 [PACTH v4 0/3] Implement /proc/<pid>/totmaps robert.foss
2016-08-16 22:33 ` [PACTH v4 1/3] mm, proc: " robert.foss
2016-08-31 9:45 ` Jacek Anaszewski
2016-08-31 16:36 ` Robert Foss
2016-08-31 17:04 ` Mateusz Guzik [this message]
2016-09-01 23:42 ` Robert Foss
2016-08-16 22:33 ` [PACTH v4 2/3] Documentation/filesystems: Fixed typo robert.foss
2016-08-16 22:33 ` [PACTH v4 3/3] Documentation/filesystems: Added /proc/PID/totmaps documentation robert.foss
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=20160831170415.pc2hlvb7fevpichy@mguzik \
--to=mguzik@redhat.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benzh@chromium.org \
--cc=bfreed@chromium.org \
--cc=calvinowens@fb.com \
--cc=corbet@lwn.net \
--cc=filbranden@chromium.org \
--cc=gorcunov@openvz.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=j.anaszewski@samsung.com \
--cc=jann@thejh.net \
--cc=jdanis@google.com \
--cc=jmarchan@redhat.com \
--cc=john.stultz@linaro.org \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=koct9i@gmail.com \
--cc=ldufour@linux.vnet.ibm.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=mingo@kernel.org \
--cc=mnfhuang@gmail.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=robert.foss@collabora.com \
--cc=ross.zwisler@linux.intel.com \
--cc=sonnyrao@chromium.org \
--cc=vbabka@suse.cz \
--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;
as well as URLs for NNTP newsgroup(s).