Message ID | 20201111004440.8783-1-ansuelsmth@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64: fix missing include in asm uaccess.h | expand |
On Wed, Nov 11, 2020 at 01:44:38AM +0100, Ansuel Smith wrote: > Fix a compilation error as PF_KTHREAD is defined in linux/sched.h and > this is missing. > > Fixes: df325e05a682 ("arm64: Validate tagged addresses in access_ok() > called from kernel threads") > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> > --- > arch/arm64/include/asm/uaccess.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index 991dd5f031e4..51a4f63f464a 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -7,6 +7,8 @@ > #ifndef __ASM_UACCESS_H > #define __ASM_UACCESS_H > > +#include <linux/sched.h> > + > #include <asm/alternative.h> > #include <asm/kernel-pgtable.h> > #include <asm/sysreg.h> NAK. The real bug is in arch/arm64/include/asm/asm-prototypes.h - it has no business pulling asm/uaccess.h Just include linux/uaccess.h instead.
On Wed, Nov 11, 2020 at 12:58:26AM +0000, Al Viro wrote: > On Wed, Nov 11, 2020 at 01:44:38AM +0100, Ansuel Smith wrote: > > Fix a compilation error as PF_KTHREAD is defined in linux/sched.h and > > this is missing. > > > > Fixes: df325e05a682 ("arm64: Validate tagged addresses in access_ok() > > called from kernel threads") > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> > > --- > > arch/arm64/include/asm/uaccess.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > > index 991dd5f031e4..51a4f63f464a 100644 > > --- a/arch/arm64/include/asm/uaccess.h > > +++ b/arch/arm64/include/asm/uaccess.h > > @@ -7,6 +7,8 @@ > > #ifndef __ASM_UACCESS_H > > #define __ASM_UACCESS_H > > > > +#include <linux/sched.h> > > + > > #include <asm/alternative.h> > > #include <asm/kernel-pgtable.h> > > #include <asm/sysreg.h> > > NAK. The real bug is in arch/arm64/include/asm/asm-prototypes.h - > it has no business pulling asm/uaccess.h > > Just include linux/uaccess.h instead. BTW, $ grep -n uaccess.h `find -name asm-prototypes.h` ./arch/alpha/include/asm/asm-prototypes.h:7:#include <linux/uaccess.h> ./arch/arm64/include/asm/asm-prototypes.h:18:#include <asm/uaccess.h> ./arch/ia64/include/asm/asm-prototypes.h:12:#include <linux/uaccess.h> ./arch/mips/include/asm/asm-prototypes.h:6:#include <linux/uaccess.h> ./arch/powerpc/include/asm/asm-prototypes.h:14:#include <linux/uaccess.h> ./arch/sparc/include/asm/asm-prototypes.h:9:#include <linux/uaccess.h> ./arch/x86/include/asm/asm-prototypes.h:3:#include <linux/uaccess.h> Spot the irregularity... While we are at it, $ git grep -n -w '#.*include.*asm/uaccess.h' arch/arm64/include/asm/asm-prototypes.h:18:#include <asm/uaccess.h> arch/nds32/math-emu/fpuemu.c:5:#include <asm/uaccess.h> arch/powerpc/kvm/book3s_xive_native.c:15:#include <asm/uaccess.h> arch/powerpc/mm/book3s64/radix_pgtable.c:30:#include <asm/uaccess.h> drivers/s390/net/ctcm_mpc.c:50:#include <linux/uaccess.h> /* instead of <asm/uaccess.h> ok ? */ include/linux/uaccess.h:11:#include <asm/uaccess.h> The last one is the only such include that should exist; drivers/s390 one is obviously a false positive. And IMO the right thing to do is to replace the remaining arch/* instances with includes of linux/uaccess.h. All of those are asking for trouble; any change moving e.g. a common variant of some primitive into linux/uaccess.h might end up breaking those.
> On Wed, Nov 11, 2020 at 12:58:26AM +0000, Al Viro wrote: > > On Wed, Nov 11, 2020 at 01:44:38AM +0100, Ansuel Smith wrote: > > > Fix a compilation error as PF_KTHREAD is defined in linux/sched.h and > > > this is missing. > > > > > > Fixes: df325e05a682 ("arm64: Validate tagged addresses in access_ok() > > > called from kernel threads") > > > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> > > > --- > > > arch/arm64/include/asm/uaccess.h | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/arch/arm64/include/asm/uaccess.h > b/arch/arm64/include/asm/uaccess.h > > > index 991dd5f031e4..51a4f63f464a 100644 > > > --- a/arch/arm64/include/asm/uaccess.h > > > +++ b/arch/arm64/include/asm/uaccess.h > > > @@ -7,6 +7,8 @@ > > > #ifndef __ASM_UACCESS_H > > > #define __ASM_UACCESS_H > > > > > > +#include <linux/sched.h> > > > + > > > #include <asm/alternative.h> > > > #include <asm/kernel-pgtable.h> > > > #include <asm/sysreg.h> > > > > NAK. The real bug is in arch/arm64/include/asm/asm-prototypes.h - > > it has no business pulling asm/uaccess.h > > > > Just include linux/uaccess.h instead. > > BTW, > $ grep -n uaccess.h `find -name asm-prototypes.h` > ./arch/alpha/include/asm/asm-prototypes.h:7:#include <linux/uaccess.h> > ./arch/arm64/include/asm/asm-prototypes.h:18:#include <asm/uaccess.h> > ./arch/ia64/include/asm/asm-prototypes.h:12:#include <linux/uaccess.h> > ./arch/mips/include/asm/asm-prototypes.h:6:#include <linux/uaccess.h> > ./arch/powerpc/include/asm/asm-prototypes.h:14:#include <linux/uaccess.h> > ./arch/sparc/include/asm/asm-prototypes.h:9:#include <linux/uaccess.h> > ./arch/x86/include/asm/asm-prototypes.h:3:#include <linux/uaccess.h> > > Spot the irregularity... > > While we are at it, > $ git grep -n -w '#.*include.*asm/uaccess.h' > arch/arm64/include/asm/asm-prototypes.h:18:#include <asm/uaccess.h> > arch/nds32/math-emu/fpuemu.c:5:#include <asm/uaccess.h> > arch/powerpc/kvm/book3s_xive_native.c:15:#include <asm/uaccess.h> > arch/powerpc/mm/book3s64/radix_pgtable.c:30:#include <asm/uaccess.h> > drivers/s390/net/ctcm_mpc.c:50:#include <linux/uaccess.h> /* instead of > <asm/uaccess.h> ok ? */ > include/linux/uaccess.h:11:#include <asm/uaccess.h> > > The last one is the only such include that should exist; drivers/s390 one > is obviously a false positive. And IMO the right thing to do is to > replace the remaining arch/* instances with includes of linux/uaccess.h. > > All of those are asking for trouble; any change moving e.g. a common > variant of some primitive into linux/uaccess.h might end up breaking > those. Thx for the quick response. I found this error while working on a qcom driver that use this include. I can confirm that by using linux/uaccess.h the problem is solved.
On Wed, 11 Nov 2020 02:19:48 +0100 <ansuelsmth@gmail.com> wrote: > > <asm/uaccess.h> ok ? */ > > include/linux/uaccess.h:11:#include <asm/uaccess.h> > > > > The last one is the only such include that should exist; drivers/s390 one > > is obviously a false positive. And IMO the right thing to do is to > > replace the remaining arch/* instances with includes of linux/uaccess.h. > > > > All of those are asking for trouble; any change moving e.g. a common > > variant of some primitive into linux/uaccess.h might end up breaking > > those. > > Thx for the quick response. I found this error while working on a qcom > driver that > use this include. I can confirm that by using linux/uaccess.h the problem is > solved. Thanks, all. I queued up the below for sending to Linus Real Soon Now. Please note that I added the cc:stable, because the offending df325e05a6 ("arm64: Validate tagged addresses in access_ok() called from kernel threads") had a cc:stable. From: Ansuel Smith <ansuelsmth@gmail.com> Subject: arm64: fix missing include in asm/uaccess.h Fix a compilation error as PF_KTHREAD is defined in linux/sched.h and this is missing. [viro@zeniv.linux.org.uk: use linux/uaccess.h] Link: https://lkml.kernel.org/r/20201111005826.GY3576660@ZenIV.linux.org.uk Link: https://lkml.kernel.org/r/20201111004440.8783-1-ansuelsmth@gmail.com Fixes: df325e05a682 ("arm64: Validate tagged addresses in access_ok() called from kernel threads") Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> Cc: Will Deacon <will@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Pavel Tatashin <pasha.tatashin@soleen.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- arch/arm64/include/asm/uaccess.h | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/arm64/include/asm/uaccess.h~arm64-fix-missing-include-in-asm-uaccessh +++ a/arch/arm64/include/asm/uaccess.h @@ -7,6 +7,8 @@ #ifndef __ASM_UACCESS_H #define __ASM_UACCESS_H +#include <linux/uaccess.h> + #include <asm/alternative.h> #include <asm/kernel-pgtable.h> #include <asm/sysreg.h>
On Thu, Nov 12, 2020 at 04:48:09PM -0800, Andrew Morton wrote: > [viro@zeniv.linux.org.uk: use linux/uaccess.h] > Link: https://lkml.kernel.org/r/20201111005826.GY3576660@ZenIV.linux.org.uk > Link: https://lkml.kernel.org/r/20201111004440.8783-1-ansuelsmth@gmail.com > Fixes: df325e05a682 ("arm64: Validate tagged addresses in access_ok() called from kernel threads") > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> > Cc: Will Deacon <will@kernel.org> > Cc: Catalin Marinas <catalin.marinas@arm.com> > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: Pavel Tatashin <pasha.tatashin@soleen.com> > Cc: <stable@vger.kernel.org> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org> > --- > > arch/arm64/include/asm/uaccess.h | 2 ++ > 1 file changed, 2 insertions(+) > > --- a/arch/arm64/include/asm/uaccess.h~arm64-fix-missing-include-in-asm-uaccessh > +++ a/arch/arm64/include/asm/uaccess.h > @@ -7,6 +7,8 @@ > #ifndef __ASM_UACCESS_H > #define __ASM_UACCESS_H > > +#include <linux/uaccess.h> > + > #include <asm/alternative.h> > #include <asm/kernel-pgtable.h> > #include <asm/sysreg.h> Huh? You are creating a loop for no reason whatsoever. Again, * asm/uaccess.h should be included only by linux/uaccess.h * asm/uaccess.h should NOT, NOT, NOT! include linux/uaccess.h * any place other than linux/uaccess.h that includes asm/uaccess.h, should include linux/uaccess.h instead (assuming it really needs either of those). The last one applies to arch/arm64/include/asm-prototypes.h - the include of asm/uaccess.h there should be replaced with include of linux/uaccess.h. diff --git a/arch/arm64/include/asm/asm-prototypes.h b/arch/arm64/include/asm/asm-prototypes.h index 1c9a3a0c5fa5..80077350dbc5 100644 --- a/arch/arm64/include/asm/asm-prototypes.h +++ b/arch/arm64/include/asm/asm-prototypes.h @@ -15,7 +15,7 @@ #include <asm/ftrace.h> #include <asm/page.h> #include <asm/string.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm-generic/asm-prototypes.h> diff --git a/arch/nds32/math-emu/fpuemu.c b/arch/nds32/math-emu/fpuemu.c index 46558a15c0dc..6fabf75c19b3 100644 --- a/arch/nds32/math-emu/fpuemu.c +++ b/arch/nds32/math-emu/fpuemu.c @@ -2,7 +2,7 @@ // Copyright (C) 2005-2018 Andes Technology Corporation #include <asm/bitfield.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/sfp-machine.h> #include <asm/fpuemu.h> #include <asm/nds32_fpu_inst.h> diff --git a/arch/powerpc/kvm/book3s_xive_native.c b/arch/powerpc/kvm/book3s_xive_native.c index d0c2db0e07fa..3a4468cd21b9 100644 --- a/arch/powerpc/kvm/book3s_xive_native.c +++ b/arch/powerpc/kvm/book3s_xive_native.c @@ -12,7 +12,7 @@ #include <linux/spinlock.h> #include <linux/delay.h> #include <linux/file.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/kvm_book3s.h> #include <asm/kvm_ppc.h> #include <asm/hvcall.h> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c index 3adcf730f478..93aaeaf24151 100644 --- a/arch/powerpc/mm/book3s64/radix_pgtable.c +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c @@ -27,7 +27,7 @@ #include <asm/sections.h> #include <asm/smp.h> #include <asm/trace.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/ultravisor.h> #include <trace/events/thp.h> diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index 85a1a4533cbe..88b74ddd88f0 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c @@ -47,7 +47,7 @@ #include <asm/ccwdev.h> #include <asm/ccwgroup.h> #include <linux/bitops.h> /* instead of <asm/bitops.h> ok ? */ -#include <linux/uaccess.h> /* instead of <asm/uaccess.h> ok ? */ +#include <linux/uaccess.h> #include <linux/wait.h> #include <linux/moduleparam.h> #include <asm/idals.h> diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index c7c6e8b8344d..3743957e207f 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -8,6 +8,11 @@ #include <linux/sched.h> #include <linux/thread_info.h> +/* + * NOTE: This is the one and only place that has any business trying + * to include asm/uaccess.h; if you see such include anywhere else, + * kill it. + */ #include <asm/uaccess.h> #ifdef CONFIG_SET_FS
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 991dd5f031e4..51a4f63f464a 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -7,6 +7,8 @@ #ifndef __ASM_UACCESS_H #define __ASM_UACCESS_H +#include <linux/sched.h> + #include <asm/alternative.h> #include <asm/kernel-pgtable.h> #include <asm/sysreg.h>
Fix a compilation error as PF_KTHREAD is defined in linux/sched.h and this is missing. Fixes: df325e05a682 ("arm64: Validate tagged addresses in access_ok() called from kernel threads") Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> --- arch/arm64/include/asm/uaccess.h | 2 ++ 1 file changed, 2 insertions(+)