diff mbox series

uio: fix is_source param for check_copy_size() in copy_to_iter_mcsafe()

Message ID 153617950046.33664.13445188581267552601.stgit@djiang5-desk3.ch.intel.com (mailing list archive)
State Accepted
Commit dfb06cba8c73c0704710b2e3fbe2c35ac66a01b4
Headers show
Series uio: fix is_source param for check_copy_size() in copy_to_iter_mcsafe() | expand

Commit Message

Dave Jiang Sept. 5, 2018, 8:31 p.m. UTC
copy_to_iter_mcsafe() is passing in the is_source parameter as "false"
to check_copy_size(). This is different than what copy_to_iter() does.
Also, the addr parameter passed to check_copy_size() is the source so
therefore we should be passing in "true" instead.

Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()")

Reported-by: Fan Du <fan.du@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
---
 include/linux/uio.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dave Jiang Sept. 6, 2018, 3:45 p.m. UTC | #1
On 09/05/2018 01:31 PM, Dave Jiang wrote:
> copy_to_iter_mcsafe() is passing in the is_source parameter as "false"
> to check_copy_size(). This is different than what copy_to_iter() does.
> Also, the addr parameter passed to check_copy_size() is the source so
> therefore we should be passing in "true" instead.
> 
> Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()")
> 
> Reported-by: Fan Du <fan.du@intel.com>
Slight correction:
Reported-by: Wenwei Tao <wenwei.tww@alibaba-inc.com>

> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  include/linux/uio.h |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/uio.h b/include/linux/uio.h
> index 409c845d4cd3..422b1c01ee0d 100644
> --- a/include/linux/uio.h
> +++ b/include/linux/uio.h
> @@ -172,7 +172,7 @@ size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
>  static __always_inline __must_check
>  size_t copy_to_iter_mcsafe(void *addr, size_t bytes, struct iov_iter *i)
>  {
> -	if (unlikely(!check_copy_size(addr, bytes, false)))
> +	if (unlikely(!check_copy_size(addr, bytes, true)))
>  		return 0;
>  	else
>  		return _copy_to_iter_mcsafe(addr, bytes, i);
>
Greg Kroah-Hartman Sept. 12, 2018, 7:48 a.m. UTC | #2
On Wed, Sep 05, 2018 at 01:31:40PM -0700, Dave Jiang wrote:
> copy_to_iter_mcsafe() is passing in the is_source parameter as "false"
> to check_copy_size(). This is different than what copy_to_iter() does.
> Also, the addr parameter passed to check_copy_size() is the source so
> therefore we should be passing in "true" instead.
> 
> Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()")
> Cc: Fan Du <fan.du@intel.com>
> Reported-by: Wenwei Tao <wenwei.tww@alibaba-inc.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> Cc: stable <stable@vger.kernel.org>
> ---
>  include/linux/uio.h |    2 +-

I am not the maintainer of this file, sorry, please work with the -mm
developers for this.

thanks,

greg k-h
Dan Williams Sept. 12, 2018, 9:51 p.m. UTC | #3
On Wed, Sep 12, 2018 at 12:48 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Sep 05, 2018 at 01:31:40PM -0700, Dave Jiang wrote:
>> copy_to_iter_mcsafe() is passing in the is_source parameter as "false"
>> to check_copy_size(). This is different than what copy_to_iter() does.
>> Also, the addr parameter passed to check_copy_size() is the source so
>> therefore we should be passing in "true" instead.
>>
>> Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()")
>> Cc: Fan Du <fan.du@intel.com>
>> Reported-by: Wenwei Tao <wenwei.tww@alibaba-inc.com>
>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
>> Cc: stable <stable@vger.kernel.org>
>> ---
>>  include/linux/uio.h |    2 +-
>
> I am not the maintainer of this file, sorry, please work with the -mm
> developers for this.

Likely this is get_maintainer.pl's fault:

$ ./scripts/get_maintainer.pl  -f include/linux/uio.h
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (maintainer:USERSPACE I/O (UIO))
linux-kernel@vger.kernel.org (open list)

Maybe a MAINTAINERS update like the following is warranted, because I
don't think -mm developers are right either, Al seems to be authority
on iov_iter apis:

diff --git a/MAINTAINERS b/MAINTAINERS
index d870cb57c887..0018e19b4d8e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15344,13 +15344,18 @@ F:    arch/x86/um/
 F:     fs/hostfs/
 F:     fs/hppfs/

+USERSPACE ACCESS (uaccess, copy_{to,from}_iter)
+M:     Alexander Viro <viro@zeniv.linux.org.uk>
+S:     Maintained
+F:     include/linux/uio*.h
+F:     lib/iov_iter.c
+
 USERSPACE I/O (UIO)
 M:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F:     Documentation/driver-api/uio-howto.rst
 F:     drivers/uio/
-F:     include/linux/uio*.h

 UTIL-LINUX PACKAGE
 M:     Karel Zak <kzak@redhat.com>

---

In any event, the patch in question is a trivial one liner, I feel
confident sending it along to Linus with some other pending fixes.
Greg Kroah-Hartman Sept. 12, 2018, 9:57 p.m. UTC | #4
On Wed, Sep 12, 2018 at 02:51:53PM -0700, Dan Williams wrote:
> On Wed, Sep 12, 2018 at 12:48 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> > On Wed, Sep 05, 2018 at 01:31:40PM -0700, Dave Jiang wrote:
> >> copy_to_iter_mcsafe() is passing in the is_source parameter as "false"
> >> to check_copy_size(). This is different than what copy_to_iter() does.
> >> Also, the addr parameter passed to check_copy_size() is the source so
> >> therefore we should be passing in "true" instead.
> >>
> >> Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()")
> >> Cc: Fan Du <fan.du@intel.com>
> >> Reported-by: Wenwei Tao <wenwei.tww@alibaba-inc.com>
> >> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> >> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> >> Cc: stable <stable@vger.kernel.org>
> >> ---
> >>  include/linux/uio.h |    2 +-
> >
> > I am not the maintainer of this file, sorry, please work with the -mm
> > developers for this.
> 
> Likely this is get_maintainer.pl's fault:
> 
> $ ./scripts/get_maintainer.pl  -f include/linux/uio.h
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> (maintainer:USERSPACE I/O (UIO))
> linux-kernel@vger.kernel.org (open list)
> 
> Maybe a MAINTAINERS update like the following is warranted, because I
> don't think -mm developers are right either, Al seems to be authority
> on iov_iter apis:
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d870cb57c887..0018e19b4d8e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -15344,13 +15344,18 @@ F:    arch/x86/um/
>  F:     fs/hostfs/
>  F:     fs/hppfs/
> 
> +USERSPACE ACCESS (uaccess, copy_{to,from}_iter)
> +M:     Alexander Viro <viro@zeniv.linux.org.uk>
> +S:     Maintained
> +F:     include/linux/uio*.h
> +F:     lib/iov_iter.c
> +
>  USERSPACE I/O (UIO)
>  M:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>  S:     Maintained
>  T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
>  F:     Documentation/driver-api/uio-howto.rst
>  F:     drivers/uio/
> -F:     include/linux/uio*.h

Don't drop that line, uio_driver.h is what it should just say, right?

thanks,

greg k-h
Dan Williams Sept. 12, 2018, 10:02 p.m. UTC | #5
On Wed, Sep 12, 2018 at 2:57 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Sep 12, 2018 at 02:51:53PM -0700, Dan Williams wrote:
>> On Wed, Sep 12, 2018 at 12:48 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> > On Wed, Sep 05, 2018 at 01:31:40PM -0700, Dave Jiang wrote:
>> >> copy_to_iter_mcsafe() is passing in the is_source parameter as "false"
>> >> to check_copy_size(). This is different than what copy_to_iter() does.
>> >> Also, the addr parameter passed to check_copy_size() is the source so
>> >> therefore we should be passing in "true" instead.
>> >>
>> >> Fixes: 8780356ef630 ("x86/asm/memcpy_mcsafe: Define copy_to_iter_mcsafe()")
>> >> Cc: Fan Du <fan.du@intel.com>
>> >> Reported-by: Wenwei Tao <wenwei.tww@alibaba-inc.com>
>> >> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>> >> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
>> >> Cc: stable <stable@vger.kernel.org>
>> >> ---
>> >>  include/linux/uio.h |    2 +-
>> >
>> > I am not the maintainer of this file, sorry, please work with the -mm
>> > developers for this.
>>
>> Likely this is get_maintainer.pl's fault:
>>
>> $ ./scripts/get_maintainer.pl  -f include/linux/uio.h
>> Greg Kroah-Hartman <gregkh@linuxfoundation.org> (maintainer:USERSPACE I/O (UIO))
>> linux-kernel@vger.kernel.org (open list)
>>
>> Maybe a MAINTAINERS update like the following is warranted, because I
>> don't think -mm developers are right either, Al seems to be authority
>> on iov_iter apis:
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index d870cb57c887..0018e19b4d8e 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -15344,13 +15344,18 @@ F:    arch/x86/um/
>>  F:     fs/hostfs/
>>  F:     fs/hppfs/
>>
>> +USERSPACE ACCESS (uaccess, copy_{to,from}_iter)
>> +M:     Alexander Viro <viro@zeniv.linux.org.uk>
>> +S:     Maintained
>> +F:     include/linux/uio*.h
>> +F:     lib/iov_iter.c
>> +
>>  USERSPACE I/O (UIO)
>>  M:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>  S:     Maintained
>>  T:     git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
>>  F:     Documentation/driver-api/uio-howto.rst
>>  F:     drivers/uio/
>> -F:     include/linux/uio*.h
>
> Don't drop that line, uio_driver.h is what it should just say, right?
>

Ah, yep, I missed that. Thanks.
diff mbox series

Patch

diff --git a/include/linux/uio.h b/include/linux/uio.h
index 409c845d4cd3..422b1c01ee0d 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -172,7 +172,7 @@  size_t copy_from_iter_flushcache(void *addr, size_t bytes, struct iov_iter *i)
 static __always_inline __must_check
 size_t copy_to_iter_mcsafe(void *addr, size_t bytes, struct iov_iter *i)
 {
-	if (unlikely(!check_copy_size(addr, bytes, false)))
+	if (unlikely(!check_copy_size(addr, bytes, true)))
 		return 0;
 	else
 		return _copy_to_iter_mcsafe(addr, bytes, i);