Skip to content

Commit de7f60f

Browse files
linuswRussell King (Oracle)
authored and
Russell King (Oracle)
committed
ARM: 9357/2: Reduce the number of #ifdef CONFIG_CPU_SW_DOMAIN_PAN
This is a clean-up patch aimed at reducing the number of checks on CONFIG_CPU_SW_DOMAIN_PAN, together with some empty lines for better clarity once the CONFIG_CPU_TTBR0_PAN is introduced. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Kees Cook <keescook@chromium.org> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
1 parent 66abdd3 commit de7f60f

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

arch/arm/include/asm/uaccess-asm.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
#endif
4040
.endm
4141

42-
.macro uaccess_disable, tmp, isb=1
4342
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
43+
44+
.macro uaccess_disable, tmp, isb=1
4445
/*
4546
* Whenever we re-enter userspace, the domains should always be
4647
* set appropriately.
@@ -50,11 +51,9 @@
5051
.if \isb
5152
instr_sync
5253
.endif
53-
#endif
5454
.endm
5555

5656
.macro uaccess_enable, tmp, isb=1
57-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
5857
/*
5958
* Whenever we re-enter userspace, the domains should always be
6059
* set appropriately.
@@ -64,9 +63,18 @@
6463
.if \isb
6564
instr_sync
6665
.endif
67-
#endif
6866
.endm
6967

68+
#else
69+
70+
.macro uaccess_disable, tmp, isb=1
71+
.endm
72+
73+
.macro uaccess_enable, tmp, isb=1
74+
.endm
75+
76+
#endif
77+
7078
#if defined(CONFIG_CPU_SW_DOMAIN_PAN) || defined(CONFIG_CPU_USE_DOMAINS)
7179
#define DACR(x...) x
7280
#else

arch/arm/include/asm/uaccess.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,38 @@
2424
* perform such accesses (eg, via list poison values) which could then
2525
* be exploited for priviledge escalation.
2626
*/
27+
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
28+
2729
static __always_inline unsigned int uaccess_save_and_enable(void)
2830
{
29-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
3031
unsigned int old_domain = get_domain();
3132

3233
/* Set the current domain access to permit user accesses */
3334
set_domain((old_domain & ~domain_mask(DOMAIN_USER)) |
3435
domain_val(DOMAIN_USER, DOMAIN_CLIENT));
3536

3637
return old_domain;
37-
#else
38-
return 0;
39-
#endif
4038
}
4139

4240
static __always_inline void uaccess_restore(unsigned int flags)
4341
{
44-
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
4542
/* Restore the user access mask */
4643
set_domain(flags);
47-
#endif
4844
}
4945

46+
#else
47+
48+
static inline unsigned int uaccess_save_and_enable(void)
49+
{
50+
return 0;
51+
}
52+
53+
static inline void uaccess_restore(unsigned int flags)
54+
{
55+
}
56+
57+
#endif
58+
5059
/*
5160
* These two are intentionally not defined anywhere - if the kernel
5261
* code generates any references to them, that's a bug.

0 commit comments

Comments
 (0)