Could you give us your compiler version ?
Code is fine, but compiler a bit dumb :(
[PATCH] can: avoids a false warning
At this point optlen == sizeof(sfilter) but some compilers are dumb.
Reported-by: Németh Márton <nm127@freemail.h
Signed-off-by: Eric Dumazet <eric.d...@gmail.com>
---
diff --git a/net/can/raw.c b/net/can/raw.c
index 3a7dffb..da99cf1 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -445,7 +445,7 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
return -EFAULT;
}
} else if (count == 1) {
- if (copy_from_user(&sfilter, optval, optlen))
+ if (copy_from_user(&sfilter, optval, sizeof(sfilter)))
return -EFAULT;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
$ gcc --version
gcc (Debian 4.4.2-9) 4.4.3 20100108 (prerelease)
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Acked-by: Oliver Hartkopp <oli...@hartkopp.net>
Btw. i'm using the same compiler here (Debian Squeeze), and i did not have any
build problems with 2.6.24-rc3 and the following kernels like the currently
running 2.6.34-rc3-00288-gab195c5:
$ cat /proc/version
Linux version 2.6.34-rc3-00288-gab195c5 (hartko@vwagwolkf320) (gcc version
4.4.3 20100108 (prerelease) (Debian 4.4.2-9) ) #70 SMP Tue Apr 6 19:14:52 CEST
2010
So i wonder why Nemeth trapped into this problem ... probably an include file
mix-up?
Regards,
Oliver
> Could you give us your compiler version ?
>
> Code is fine, but compiler a bit dumb :(
Build failures happen all over the kernel with that
USER_COPY_CHECK config option enabled, it's not really
a bug report and I've even told people like Stephen
Rothwell to do their allmodconfig builds on platforms
like sparc64 with this option hard disabled.
> So i wonder why Nemeth trapped into this problem ... probably an include file
> mix-up?
Do you have CONFIG_DEBUG_STRICT_USER_COPY_CHECKS enabled in your
kernel config?
That's the only way you get an actual failure of a build when
the user copy size can't be proven to be in range by the
compiler, otherwise it just warns.
CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
> David Miller wrote:
>> From: Oliver Hartkopp <sock...@hartkopp.net>
>> Date: Sat, 10 Apr 2010 14:36:48 +0200
>>
>>> So i wonder why Nemeth trapped into this problem ... probably an include file
>>> mix-up?
>>
>> Do you have CONFIG_DEBUG_STRICT_USER_COPY_CHECKS enabled in your
>> kernel config?
>
> CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
Just turn that off in your builds, it's for developers who want
to work on correcting those warnings, not you :-)
No, indeed i do not have it set.
# CONFIG_DEBUG_STRICT_USER_COPY_CHECKS is not set
What would be the best approach to fix this build failure then?
By applying the patch thankfully provided by Eric?
Regards,
Oliver
> By applying the patch thankfully provided by Eric?
I'll probably do that, yes.
> [PATCH] can: avoids a false warning
>
> At this point optlen == sizeof(sfilter) but some compilers are dumb.
>
> Reported-by: Németh Márton <nm127@freemail.h
> Signed-off-by: Eric Dumazet <eric.d...@gmail.com>
Applied, thanks Eric.