From: Matthew Wilcox <willy@infradead.org>
To: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexander Egorenkov <egorenar@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>, Baoquan He <bhe@redhat.com>,
Christoph Hellwig <hch@lst.de>, Vasily Gorbik <gor@linux.ibm.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH v3 2/3] s390/crash: use static swap buffer for copy_to_user_real()
Date: Mon, 18 Jul 2022 17:02:06 +0100 [thread overview]
Message-ID: <YtWD/u2cIafi+vsf@casper.infradead.org> (raw)
In-Reply-To: <YtVzj5W5xr/UwjLT@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com>
On Mon, Jul 18, 2022 at 04:51:59PM +0200, Alexander Gordeev wrote:
> On Mon, Jul 18, 2022 at 02:48:21PM +0100, Matthew Wilcox wrote:
> > On Mon, Jul 18, 2022 at 03:32:40PM +0200, Alexander Gordeev wrote:
> > > +++ b/arch/s390/kernel/crash_dump.c
> > > @@ -53,6 +53,7 @@ struct save_area {
> > > };
> > >
> > > static LIST_HEAD(dump_save_areas);
> >
> > I'd suggest you need a mutex here so that simultaneous calls to
> > copy_to_user_real() don't corrupt each others data.
>
> We stop all (but one) CPUs before calling into the capture kernel -
> one that calls these functions. Similarily to racy hsa_buf[] access
> from memcpy_hsa_iter() this should not hit.
Could you show me how that works when two processes read from
/proc/vmcore at the same time?
> As you noticed last time, it is a pre-existing race and I was
> actually going to address it in a separate fix - if the problem
> really exists.
>
> > > +static char memcpy_real_buf[PAGE_SIZE];
> > >
> > > /*
> > > * Allocate a save area
> > > @@ -179,23 +180,18 @@ int copy_oldmem_kernel(void *dst, unsigned long src, size_t count)
> > > static int copy_to_user_real(void __user *dest, unsigned long src, unsigned long count)
> > > {
> > > int offs = 0, size, rc;
> > > - char *buf;
> > >
> > > - buf = (char *)__get_free_page(GFP_KERNEL);
> > > - if (!buf)
> > > - return -ENOMEM;
> > > rc = -EFAULT;
> > > while (offs < count) {
> > > size = min(PAGE_SIZE, count - offs);
> > > - if (memcpy_real(buf, src + offs, size))
> > > + if (memcpy_real(memcpy_real_buf, src + offs, size))
> > > goto out;
> > > - if (copy_to_user(dest + offs, buf, size))
> > > + if (copy_to_user(dest + offs, memcpy_real_buf, size))
> > > goto out;
> > > offs += size;
> > > }
> > > rc = 0;
> > > out:
> > > - free_page((unsigned long)buf);
> > > return rc;
> > > }
>
> Thanks!
next prev parent reply other threads:[~2022-07-18 16:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 13:32 [PATCH v3 0/3] s390/crash: support multi-segment iterators Alexander Gordeev
2022-07-18 13:32 ` [PATCH v3 1/3] s390/crash: move copy_to_user_real() to crash_dump.c Alexander Gordeev
2022-07-18 13:32 ` [PATCH v3 2/3] s390/crash: use static swap buffer for copy_to_user_real() Alexander Gordeev
2022-07-18 13:48 ` Matthew Wilcox
2022-07-18 14:51 ` Alexander Gordeev
2022-07-18 16:02 ` Matthew Wilcox [this message]
2022-07-18 13:32 ` [PATCH v3 3/3] s390/crash: support multi-segment iterators Alexander Gordeev
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=YtWD/u2cIafi+vsf@casper.infradead.org \
--to=willy@infradead.org \
--cc=agordeev@linux.ibm.com \
--cc=bhe@redhat.com \
--cc=egorenar@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--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