Re: [PATCH] genwqe: Take R/W permissions into account when dealing with memory pages

From: Greg KH
Date: Sat Oct 21 2017 - 03:51:48 EST


On Fri, Oct 20, 2017 at 05:27:49PM -0200, Guilherme G. Piccoli wrote:
> Currently we assume userspace pages are always writable when doing
> memory pinning. This is not true, specially since userspace applications
> may allocate their memory the way they want, we have no control over it.
> If a read-only page is set for pinning, currently the driver fails due
> to get_user_pages_fast() refusing to map read-only pages as writable.
>
> This patch changes this behavior, by taking the permission flags of the
> pages into account in both pinning/unpinning process, as well as in the
> DMA data copy-back to userpace (which we shouldn't try to do blindly,
> since it will fail in case of read-only-pages).
>
> Signed-off-by: Frank Haverkamp <haver@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@xxxxxxxxxxxxxxxxxx>
> ---
>
> Arnd/Greg, we found this bug recently, although not critical,
> it's really a boring issue affecting driver functionality.
> If it's possible to take this patch still on v4.14, we'd be
> really thankful!
> But we know it's late, so if not possible, v4.15 is cool.

Is this a regression? It seems like it's just a "fix something that has
always been broken but no one has noticed yet" type of thing, right?

thanks,

greg k-h