* [PATCH] sefltest/ima: support appended signatures (modsig)
From: Mimi Zohar @ 2019-08-28 12:39 UTC (permalink / raw)
To: linux-integrity
Cc: Dave Young, linuxppc-dev, Mimi Zohar, linux-kernel, Petr Vorel,
linux-kselftest, Jessica Yu, shuah, Thiago Jung Bauermann
Detect and allow appended signatures.
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
.../selftests/kexec/test_kexec_file_load.sh | 38 +++++++++++++++++++---
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kexec/test_kexec_file_load.sh b/tools/testing/selftests/kexec/test_kexec_file_load.sh
index fa7c24e8eefb..2ff600388c30 100755
--- a/tools/testing/selftests/kexec/test_kexec_file_load.sh
+++ b/tools/testing/selftests/kexec/test_kexec_file_load.sh
@@ -37,11 +37,20 @@ is_ima_sig_required()
# sequentially. As a result, a policy rule may be defined, but
# might not necessarily be used. This test assumes if a policy
# rule is specified, that is the intent.
+
+ # First check for appended signature (modsig), then xattr
if [ $ima_read_policy -eq 1 ]; then
check_ima_policy "appraise" "func=KEXEC_KERNEL_CHECK" \
- "appraise_type=imasig"
+ "appraise_type=imasig|modsig"
ret=$?
- [ $ret -eq 1 ] && log_info "IMA signature required";
+ if [ $ret -eq 1 ]; then
+ log_info "IMA or appended(modsig) signature required"
+ else
+ check_ima_policy "appraise" "func=KEXEC_KERNEL_CHECK" \
+ "appraise_type=imasig"
+ ret=$?
+ [ $ret -eq 1 ] && log_info "IMA signature required";
+ fi
fi
return $ret
}
@@ -84,6 +93,22 @@ check_for_imasig()
return $ret
}
+# Return 1 for appended signature (modsig) found and 0 for not found.
+check_for_modsig()
+{
+ local module_sig_string="~Module signature appended~"
+ local sig="$(tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE)"
+ local ret=0
+
+ if [ "$sig" == "$module_sig_string" ]; then
+ ret=1
+ log_info "kexec kernel image modsig signed"
+ else
+ log_info "kexec kernel image not modsig signed"
+ fi
+ return $ret
+}
+
kexec_file_load_test()
{
local succeed_msg="kexec_file_load succeeded"
@@ -98,7 +123,8 @@ kexec_file_load_test()
# In secureboot mode with an architecture specific
# policy, make sure either an IMA or PE signature exists.
if [ $secureboot -eq 1 ] && [ $arch_policy -eq 1 ] && \
- [ $ima_signed -eq 0 ] && [ $pe_signed -eq 0 ]; then
+ [ $ima_signed -eq 0 ] && [ $pe_signed -eq 0 ] \
+ && [ $ima_modsig -eq 0 ]; then
log_fail "$succeed_msg (missing sig)"
fi
@@ -107,7 +133,8 @@ kexec_file_load_test()
log_fail "$succeed_msg (missing PE sig)"
fi
- if [ $ima_sig_required -eq 1 ] && [ $ima_signed -eq 0 ]; then
+ if [ $ima_sig_required -eq 1 ] && [ $ima_signed -eq 0 ] \
+ && [ $ima_modsig -eq 0 ]; then
log_fail "$succeed_msg (missing IMA sig)"
fi
@@ -204,5 +231,8 @@ pe_signed=$?
check_for_imasig
ima_signed=$?
+check_for_modsig
+ima_modsig=$?
+
# Test loading the kernel image via kexec_file_load syscall
kexec_file_load_test
--
2.7.5
^ permalink raw reply related
* Re: [PATCH v2 3/4] powerpc/64: make buildable without CONFIG_COMPAT
From: Christophe Leroy @ 2019-08-28 12:49 UTC (permalink / raw)
To: Michal Suchanek, linuxppc-dev
Cc: David Hildenbrand, Dmitry V. Levin, Max Filippov, Paul Mackerras,
Breno Leitao, Michael Neuling, Firoz Khan, Hari Bathini,
Joel Stanley, Nicholas Piggin, Steven Rostedt, Thomas Gleixner,
Allison Randal, Greg Kroah-Hartman, linux-kernel,
Eric W. Biederman, Andrew Donnellan, linux-fsdevel, Andrew Morton,
Alexander Viro
In-Reply-To: <fbf3f09d2f01e53aceea448ac42578251f424829.1566987936.git.msuchanek@suse.de>
Le 28/08/2019 à 12:30, Michal Suchanek a écrit :
> There are numerous references to 32bit functions in generic and 64bit
> code so ifdef them out.
As far as possible, avoid opting things out with ifdefs. Ref
https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation
See comment below.
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
> v2:
> - fix 32bit ifdef condition in signal.c
> - simplify the compat ifdef condition in vdso.c - 64bit is redundant
> - simplify the compat ifdef condition in callchain.c - 64bit is redundant
> ---
> arch/powerpc/include/asm/syscall.h | 2 ++
> arch/powerpc/kernel/Makefile | 15 ++++++++++++---
> arch/powerpc/kernel/entry_64.S | 2 ++
> arch/powerpc/kernel/signal.c | 5 +++--
> arch/powerpc/kernel/syscall_64.c | 5 +++--
> arch/powerpc/kernel/vdso.c | 4 +++-
> arch/powerpc/perf/callchain.c | 14 ++++++++++----
> 7 files changed, 35 insertions(+), 12 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> index 38d62acfdce7..3ed3b75541a1 100644
> --- a/arch/powerpc/include/asm/syscall.h
> +++ b/arch/powerpc/include/asm/syscall.h
> @@ -16,7 +16,9 @@
>
> /* ftrace syscalls requires exporting the sys_call_table */
> extern const unsigned long sys_call_table[];
> +#ifdef CONFIG_COMPAT
> extern const unsigned long compat_sys_call_table[];
> +#endif
Leaving the declaration should be harmless.
>
> static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
> {
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index 1d646a94d96c..b0db365b83d8 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -44,16 +44,25 @@ CFLAGS_btext.o += -DDISABLE_BRANCH_PROFILING
> endif
>
> obj-y := cputable.o ptrace.o syscalls.o \
> - irq.o align.o signal_32.o pmc.o vdso.o \
> + irq.o align.o pmc.o vdso.o \
> process.o systbl.o idle.o \
> signal.o sysfs.o cacheinfo.o time.o \
> prom.o traps.o setup-common.o \
> udbg.o misc.o io.o misc_$(BITS).o \
> of_platform.o prom_parse.o
> -obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
> - signal_64.o ptrace32.o \
> +ifndef CONFIG_PPC64
> +obj-y += signal_32.o
> +else
> +ifdef CONFIG_COMPAT
> +obj-y += signal_32.o
> +endif
> +endif
> +obj-$(CONFIG_PPC64) += setup_64.o signal_64.o \
> paca.o nvram_64.o firmware.o \
> syscall_64.o
That's still a bit messy. You could have:
obj-y = +=signal_$(BITS).o
obj-$(CONFIG_COMPAT) += signal_32.o
> +ifdef CONFIG_COMPAT
> +obj-$(CONFIG_PPC64) += sys_ppc32.o ptrace32.o
> +endif
AFAIK, CONFIG_COMPAT is only defined when CONFIG_PP64 is defined, so
could be:
obj-$(CONFIG_COMPAT) += sys_ppc32.o ptrace32.o
And could be grouped with the above signal_32.o
> obj-$(CONFIG_VDSO32) += vdso32/
> obj-$(CONFIG_PPC_WATCHDOG) += watchdog.o
> obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> index 2ec825a85f5b..a2dbf216f607 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -51,8 +51,10 @@
> SYS_CALL_TABLE:
> .tc sys_call_table[TC],sys_call_table
>
> +#ifdef CONFIG_COMPAT
> COMPAT_SYS_CALL_TABLE:
> .tc compat_sys_call_table[TC],compat_sys_call_table
> +#endif
Can we avoid this ifdef ?
>
> /* This value is used to mark exception frames on the stack. */
> exception_marker:
> diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
> index 60436432399f..ffd045e9fb57 100644
> --- a/arch/powerpc/kernel/signal.c
> +++ b/arch/powerpc/kernel/signal.c
> @@ -277,14 +277,15 @@ static void do_signal(struct task_struct *tsk)
>
> rseq_signal_deliver(&ksig, tsk->thread.regs);
>
> +#if !defined(CONFIG_PPC64) || defined(CONFIG_COMPAT)
> if (is32) {
> if (ksig.ka.sa.sa_flags & SA_SIGINFO)
> ret = handle_rt_signal32(&ksig, oldset, tsk);
> else
> ret = handle_signal32(&ksig, oldset, tsk);
> - } else {
> + } else
" if only one branch of a conditional statement is a single statement
[...] use braces in both branches"
Ref
https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
> +#endif /* 32bit */
Having an #ifdef in a middle of a if/else is gross.
Check what are the possible values for is32. It will be always true
which CONFIG_PPC32.
If you can make sure it is always false without CONFIG_COMPAT, you are
done. If not, then combine the if(is32) with something involving
IS_ENABLED(CONFIG_COMPAT).
> ret = handle_rt_signal64(&ksig, oldset, tsk);
> - }
>
> tsk->thread.regs->trap = 0;
> signal_setup_done(ret, &ksig, test_thread_flag(TIF_SINGLESTEP));
> diff --git a/arch/powerpc/kernel/syscall_64.c b/arch/powerpc/kernel/syscall_64.c
> index 98ed970796d5..3f48262b512d 100644
> --- a/arch/powerpc/kernel/syscall_64.c
> +++ b/arch/powerpc/kernel/syscall_64.c
> @@ -100,6 +100,7 @@ long system_call_exception(long r3, long r4, long r5, long r6, long r7, long r8,
> /* May be faster to do array_index_nospec? */
> barrier_nospec();
>
> +#ifdef CONFIG_COMPAT
> if (unlikely(ti_flags & _TIF_32BIT)) {
> f = (void *)compat_sys_call_table[r0];
Don't opt out compat_sys_call_table[] declaration in .h file, and use:
if (IS_ENABLED(CONFIG_COMPAT) && unlikely(ti_flags & _TIF_32BIT)) {
>
> @@ -110,9 +111,9 @@ long system_call_exception(long r3, long r4, long r5, long r6, long r7, long r8,
> r7 &= 0x00000000ffffffffULL;
> r8 &= 0x00000000ffffffffULL;
>
> - } else {
> + } else
> +#endif /* CONFIG_COMPAT */
Same comment above braces and #ifdefs in the middle of an if/else
> f = (void *)sys_call_table[r0];
> - }
>
> return f(r3, r4, r5, r6, r7, r8);
> }
> diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
> index d60598113a9f..a991b5d69010 100644
> --- a/arch/powerpc/kernel/vdso.c
> +++ b/arch/powerpc/kernel/vdso.c
> @@ -667,7 +667,7 @@ static void __init vdso_setup_syscall_map(void)
> {
> unsigned int i;
> extern unsigned long *sys_call_table;
> -#ifdef CONFIG_PPC64
> +#ifdef CONFIG_COMPAT
It should be possible to get rid of that #ifdef completely.
> extern unsigned long *compat_sys_call_table;
> #endif
> extern unsigned long sys_ni_syscall;
> @@ -678,9 +678,11 @@ static void __init vdso_setup_syscall_map(void)
> if (sys_call_table[i] != sys_ni_syscall)
> vdso_data->syscall_map_64[i >> 5] |=
> 0x80000000UL >> (i & 0x1f);
> +#ifdef CONFIG_COMPAT
Use if (IS_ENABLED(CONFIG_COMPAT && compat_sys_call_table[i] !=
sys_ni_syscall)
> if (compat_sys_call_table[i] != sys_ni_syscall)
> vdso_data->syscall_map_32[i >> 5] |=
> 0x80000000UL >> (i & 0x1f);
> +#endif /* CONFIG_COMPAT */
> #else /* CONFIG_PPC64 */
> if (sys_call_table[i] != sys_ni_syscall)
> vdso_data->syscall_map_32[i >> 5] |=
> diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
> index c84bbd4298a0..b3dacc8bc98d 100644
> --- a/arch/powerpc/perf/callchain.c
> +++ b/arch/powerpc/perf/callchain.c
> @@ -15,7 +15,7 @@
> #include <asm/sigcontext.h>
> #include <asm/ucontext.h>
> #include <asm/vdso.h>
> -#ifdef CONFIG_PPC64
> +#ifdef CONFIG_COMPAT
> #include "../kernel/ppc32.h"
> #endif
> #include <asm/pte-walk.h>
> @@ -165,6 +165,7 @@ static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret)
> return read_user_stack_slow(ptr, ret, 8);
> }
>
> +#ifdef CONFIG_COMPAT
Unneeded #ifdef
> static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
> {
> if ((unsigned long)ptr > TASK_SIZE - sizeof(unsigned int) ||
> @@ -180,6 +181,7 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
>
> return read_user_stack_slow(ptr, ret, 4);
> }
> +#endif
>
> static inline int valid_user_sp(unsigned long sp, int is_64)
> {
> @@ -341,6 +343,7 @@ static inline int valid_user_sp(unsigned long sp, int is_64)
>
> #endif /* CONFIG_PPC64 */
>
> +#if !defined(CONFIG_PPC64) || defined(CONFIG_COMPAT)
You don't need to opt that out.
> /*
> * Layout for non-RT signal frames
> */
> @@ -482,12 +485,15 @@ static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
> sp = next_sp;
> }
> }
> +#endif /* 32bit */
>
> void
> perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
> {
> - if (current_is_64bit())
> - perf_callchain_user_64(entry, regs);
> - else
> +#if !defined(CONFIG_PPC64) || defined(CONFIG_COMPAT)
> + if (!current_is_64bit())
> perf_callchain_user_32(entry, regs);
> + else
> +#endif
> + perf_callchain_user_64(entry, regs);
Please rewrite using IS_ENABLED() instead of #ifdefs.
Christophe
^ permalink raw reply
* Re: [PATCH] sefltest/ima: support appended signatures (modsig)
From: Petr Vorel @ 2019-08-28 13:01 UTC (permalink / raw)
To: Mimi Zohar
Cc: Dave Young, linuxppc-dev, linux-kernel, linux-kselftest,
Jessica Yu, linux-integrity, shuah, Thiago Jung Bauermann
In-Reply-To: <1566995946-6582-1-git-send-email-zohar@linux.ibm.com>
Hi Mimi,
> Detect and allow appended signatures.
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
^ permalink raw reply
* Re: [PATCH v6 00/12] implement KASLR for powerpc/fsl_booke/32
From: Michael Ellerman @ 2019-08-28 13:01 UTC (permalink / raw)
To: Scott Wood
Cc: wangkefeng.wang, keescook, Jason Yan, kernel-hardening,
linux-kernel, npiggin, jingxiangfeng, diana.craciun, paulus,
zhaohongjiang, thunder.leizhen, fanchengyang, linuxppc-dev,
yebin10
In-Reply-To: <827cc152757906a0ebc04bbe56cdf44683721eb4.camel@buserror.net>
Scott Wood <oss@buserror.net> writes:
> On Tue, 2019-08-27 at 11:33 +1000, Michael Ellerman wrote:
>> Jason Yan <yanaijie@huawei.com> writes:
>> > A polite ping :)
>> >
>> > What else should I do now?
>>
>> That's a good question.
>>
>> Scott, are you still maintaining FSL bits,
>
> Sort of... now that it's become very low volume, it's easy to forget when
> something does show up (or miss it if I'm not CCed). It'd probably help if I
> were to just ack patches instead of thinking "I'll do a pull request for this
> later" when it's just one or two patches per cycle.
Yep, understand. Just sending acks is totally fine if you don't have
enough for a pull request.
cheers
^ permalink raw reply
* [PATCH v4 1/2] powerpc/powernv/opal-msglog: Refactor memcons code
From: Michael Ellerman @ 2019-08-28 13:05 UTC (permalink / raw)
To: linuxppc-dev; +Cc: cclaudio
From: Claudio Carvalho <cclaudio@linux.ibm.com>
This patch refactors the code in opal-msglog that operates on the OPAL
memory console in order to make it cleaner and also allow the reuse of
the new memcons_* functions.
Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
v4: mpe: Rename memcons_load_from_dt() to memcons_init().
Make memcons_init() and memcons_get_size() non-static.
Continue to use opal_msglog_copy() in opal_msglog_read().
---
arch/powerpc/platforms/powernv/opal-msglog.c | 57 +++++++++++++-------
1 file changed, 39 insertions(+), 18 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-msglog.c b/arch/powerpc/platforms/powernv/opal-msglog.c
index dc51d03c6370..d26da19a611f 100644
--- a/arch/powerpc/platforms/powernv/opal-msglog.c
+++ b/arch/powerpc/platforms/powernv/opal-msglog.c
@@ -29,23 +29,23 @@ struct memcons {
static struct memcons *opal_memcons = NULL;
-ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count)
+ssize_t memcons_copy(struct memcons *mc, char *to, loff_t pos, size_t count)
{
const char *conbuf;
ssize_t ret;
size_t first_read = 0;
uint32_t out_pos, avail;
- if (!opal_memcons)
+ if (!mc)
return -ENODEV;
- out_pos = be32_to_cpu(READ_ONCE(opal_memcons->out_pos));
+ out_pos = be32_to_cpu(READ_ONCE(mc->out_pos));
/* Now we've read out_pos, put a barrier in before reading the new
* data it points to in conbuf. */
smp_rmb();
- conbuf = phys_to_virt(be64_to_cpu(opal_memcons->obuf_phys));
+ conbuf = phys_to_virt(be64_to_cpu(mc->obuf_phys));
/* When the buffer has wrapped, read from the out_pos marker to the end
* of the buffer, and then read the remaining data as in the un-wrapped
@@ -53,7 +53,7 @@ ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count)
if (out_pos & MEMCONS_OUT_POS_WRAP) {
out_pos &= MEMCONS_OUT_POS_MASK;
- avail = be32_to_cpu(opal_memcons->obuf_size) - out_pos;
+ avail = be32_to_cpu(mc->obuf_size) - out_pos;
ret = memory_read_from_buffer(to, count, &pos,
conbuf + out_pos, avail);
@@ -71,7 +71,7 @@ ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count)
}
/* Sanity check. The firmware should not do this to us. */
- if (out_pos > be32_to_cpu(opal_memcons->obuf_size)) {
+ if (out_pos > be32_to_cpu(mc->obuf_size)) {
pr_err("OPAL: memory console corruption. Aborting read.\n");
return -EINVAL;
}
@@ -86,6 +86,11 @@ ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count)
return ret;
}
+ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count)
+{
+ return memcons_copy(opal_memcons, to, pos, count);
+}
+
static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj,
struct bin_attribute *bin_attr, char *to,
loff_t pos, size_t count)
@@ -98,32 +103,48 @@ static struct bin_attribute opal_msglog_attr = {
.read = opal_msglog_read
};
-void __init opal_msglog_init(void)
+struct memcons *memcons_init(struct device_node *node, const char *mc_prop_name)
{
u64 mcaddr;
struct memcons *mc;
- if (of_property_read_u64(opal_node, "ibm,opal-memcons", &mcaddr)) {
- pr_warn("OPAL: Property ibm,opal-memcons not found, no message log\n");
- return;
+ if (of_property_read_u64(node, mc_prop_name, &mcaddr)) {
+ pr_warn("%s property not found, no message log\n",
+ mc_prop_name);
+ goto out_err;
}
mc = phys_to_virt(mcaddr);
if (!mc) {
- pr_warn("OPAL: memory console address is invalid\n");
- return;
+ pr_warn("memory console address is invalid\n");
+ goto out_err;
}
if (be64_to_cpu(mc->magic) != MEMCONS_MAGIC) {
- pr_warn("OPAL: memory console version is invalid\n");
- return;
+ pr_warn("memory console version is invalid\n");
+ goto out_err;
}
- /* Report maximum size */
- opal_msglog_attr.size = be32_to_cpu(mc->ibuf_size) +
- be32_to_cpu(mc->obuf_size);
+ return mc;
+
+out_err:
+ return NULL;
+}
+
+u32 memcons_get_size(struct memcons *mc)
+{
+ return be32_to_cpu(mc->ibuf_size) + be32_to_cpu(mc->obuf_size);
+}
+
+void __init opal_msglog_init(void)
+{
+ opal_memcons = memcons_init(opal_node, "ibm,opal-memcons");
+ if (!opal_memcons) {
+ pr_warn("OPAL: memcons failed to load from ibm,opal-memcons\n");
+ return;
+ }
- opal_memcons = mc;
+ opal_msglog_attr.size = memcons_get_size(opal_memcons);
}
void __init opal_msglog_sysfs_init(void)
--
2.21.0
^ permalink raw reply related
* [PATCH v4 2/2] powerpc/powernv: Add ultravisor message log interface
From: Michael Ellerman @ 2019-08-28 13:05 UTC (permalink / raw)
To: linuxppc-dev; +Cc: cclaudio
In-Reply-To: <20190828130521.26764-1-mpe@ellerman.id.au>
From: Claudio Carvalho <cclaudio@linux.ibm.com>
The ultravisor (UV) provides an in-memory console which follows the
OPAL in-memory console structure.
This patch extends the OPAL msglog code to initialize the UV memory
console and provide the "/sys/firmware/ultravisor/msglog" interface
for userspace to view the UV message log.
Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
v4: mpe: Move all the code into ultravisor.c.
Consistently use "uv_" as the prefix not "ultra_".
Use powernv.h for routines that are shared within the platform.
Rather than bloating the kernel with strings for every rare error
case, return error codes from the init routine which can be
seen with initcall_debug.
---
arch/powerpc/platforms/powernv/powernv.h | 5 +++
arch/powerpc/platforms/powernv/ultravisor.c | 45 +++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/powernv.h b/arch/powerpc/platforms/powernv/powernv.h
index fd4a1c5a6369..1aa51c4fa904 100644
--- a/arch/powerpc/platforms/powernv/powernv.h
+++ b/arch/powerpc/platforms/powernv/powernv.h
@@ -30,4 +30,9 @@ extern void opal_event_shutdown(void);
bool cpu_core_split_required(void);
+struct memcons;
+ssize_t memcons_copy(struct memcons *mc, char *to, loff_t pos, size_t count);
+u32 memcons_get_size(struct memcons *mc);
+struct memcons *memcons_init(struct device_node *node, const char *mc_prop_name);
+
#endif /* _POWERNV_H */
diff --git a/arch/powerpc/platforms/powernv/ultravisor.c b/arch/powerpc/platforms/powernv/ultravisor.c
index 02ac57b4bded..e4a00ad06f9d 100644
--- a/arch/powerpc/platforms/powernv/ultravisor.c
+++ b/arch/powerpc/platforms/powernv/ultravisor.c
@@ -8,9 +8,15 @@
#include <linux/init.h>
#include <linux/printk.h>
#include <linux/of_fdt.h>
+#include <linux/of.h>
#include <asm/ultravisor.h>
#include <asm/firmware.h>
+#include <asm/machdep.h>
+
+#include "powernv.h"
+
+static struct kobject *ultravisor_kobj;
int __init early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
int depth, void *data)
@@ -22,3 +28,42 @@ int __init early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
pr_debug("Ultravisor detected!\n");
return 1;
}
+
+static struct memcons *uv_memcons;
+
+static ssize_t uv_msglog_read(struct file *file, struct kobject *kobj,
+ struct bin_attribute *bin_attr, char *to,
+ loff_t pos, size_t count)
+{
+ return memcons_copy(uv_memcons, to, pos, count);
+}
+
+static struct bin_attribute uv_msglog_attr = {
+ .attr = {.name = "msglog", .mode = 0400},
+ .read = uv_msglog_read
+};
+
+static int __init uv_init(void)
+{
+ struct device_node *node;
+
+ if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR))
+ return 0;
+
+ node = of_find_compatible_node(NULL, NULL, "ibm,uv-firmware");
+ if (!node)
+ return -ENODEV;
+
+ uv_memcons = memcons_init(node, "memcons");
+ if (!uv_memcons)
+ return -ENOENT;
+
+ uv_msglog_attr.size = memcons_get_size(uv_memcons);
+
+ ultravisor_kobj = kobject_create_and_add("ultravisor", firmware_kobj);
+ if (!ultravisor_kobj)
+ return -ENOMEM;
+
+ return sysfs_create_bin_file(ultravisor_kobj, &uv_msglog_attr);
+}
+machine_subsys_initcall(powernv, uv_init);
--
2.21.0
^ permalink raw reply related
* Re: [PATCH v2 0/4] Disable compat cruft on ppc64le v2
From: Christophe Leroy @ 2019-08-28 13:08 UTC (permalink / raw)
To: Michal Suchanek, linuxppc-dev
Cc: David Hildenbrand, Dmitry V. Levin, Max Filippov, Paul Mackerras,
Breno Leitao, Michael Neuling, Firoz Khan, Hari Bathini,
Joel Stanley, Nicholas Piggin, Steven Rostedt, Thomas Gleixner,
Allison Randal, Greg Kroah-Hartman, linux-kernel,
Eric W. Biederman, Andrew Donnellan, linux-fsdevel, Andrew Morton,
Alexander Viro
In-Reply-To: <cover.1566987936.git.msuchanek@suse.de>
On 08/28/2019 10:30 AM, Michal Suchanek wrote:
> With endian switch disabled by default the ppc64le compat supports
> ppc32le only which is something next to nobody has binaries for.
>
> Less code means less bugs so drop the compat stuff.
>
> I am not particularly sure about the best way to resolve the llseek
> situation. I don't see anything in the syscal tables making it
> 32bit-only so I suppose it should be available on 64bit as well.
>
> This is tested on ppc64le top of
Really ?
I get a build failure with ppc64_defconfig + LITTLE_ENDIAN :
CC arch/powerpc/kernel/signal.o
arch/powerpc/kernel/signal.c: In function 'do_signal':
arch/powerpc/kernel/signal.c:250:6: error: unused variable 'is32'
[-Werror=unused-variable]
int is32 = is_32bit_task();
^~~~
cc1: all warnings being treated as errors
make[3]: *** [arch/powerpc/kernel/signal.o] Error 1
Christophe
>
> https://patchwork.ozlabs.org/cover/1153556/
>
> Changes in v2: saner CONFIG_COMPAT ifdefs
>
> Thanks
>
> Michal
>
> Michal Suchanek (4):
> fs: always build llseek.
> powerpc: move common register copy functions from signal_32.c to
> signal.c
> powerpc/64: make buildable without CONFIG_COMPAT
> powerpc/64: Disable COMPAT if littleendian.
>
> arch/powerpc/Kconfig | 2 +-
> arch/powerpc/include/asm/syscall.h | 2 +
> arch/powerpc/kernel/Makefile | 15 ++-
> arch/powerpc/kernel/entry_64.S | 2 +
> arch/powerpc/kernel/signal.c | 146 ++++++++++++++++++++++++++++-
> arch/powerpc/kernel/signal_32.c | 140 ---------------------------
> arch/powerpc/kernel/syscall_64.c | 5 +-
> arch/powerpc/kernel/vdso.c | 4 +-
> arch/powerpc/perf/callchain.c | 14 ++-
> fs/read_write.c | 2 -
> 10 files changed, 177 insertions(+), 155 deletions(-)
>
^ permalink raw reply
* Re: [DOC][PATCH] powerpc: Provide initial documentation for PAPR hcalls
From: Michael Ellerman @ 2019-08-28 13:24 UTC (permalink / raw)
To: Laurent Dufour, Vaibhav Jain, linuxppc-dev
Cc: Aneesh Kumar K . V, msuchanek, Oliver O'Halloran,
David Gibson
In-Reply-To: <be5dc005-dfa5-31ad-87e2-54cef8e70508@linux.vnet.ibm.com>
Laurent Dufour <ldufour@linux.vnet.ibm.com> writes:
> Le 27/08/2019 à 17:23, Vaibhav Jain a écrit :
>> This doc patch provides an initial description of the hcall op-codes
>> that are used by Linux kernel running as a guest (LPAR) on top of
>> PowerVM or any other sPAPR compliant hyper-visor (e.g qemu).
>>
>> Apart from documenting the hcalls the doc-patch also provides a
>> rudimentary overview of how hcall ABI, how they are issued with the
>> Linux kernel and how information/control flows between the guest and
>> hypervisor.
>>
>> Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
>
> Hi Vaibhav,
>
> Thanks for documenting this.
>
> Besides my few remarks below, please consider:
>
> Reviewed-by: Laurent Dufour <ldufour@linux.ibm.com>
>
>> ---
>> Change-log:
>>
>> Initial version of this doc-patch was posted and reviewed as part of
>> the patch-series "[PATCH v5 0/4] powerpc/papr_scm: Workaround for
>> failure of drc bind after kexec"
>> https://patchwork.ozlabs.org/patch/1136022/. Changes introduced on top
>> the original patch:
>>
>> * Replaced the of term PHYP with Hypervisor to indicate both
>> PowerVM/Qemu [Laurent]
>> * Emphasized that In/Out arguments to hcalls are in Big-endian format
>> [Laurent]
>> * Fixed minor word repetition, spell issues and grammatical error
>> [Michal, Mpe]
>> * Replaced various variant of term 'hcall' with a single
>> variant. [Mpe]
>> * Changed the documentation format from txt to ReST. [Mpe]
>> * Changed the name of documentation file to papr_hcalls.rst. [Mpe]
>> * Updated the section describing privileged operation by hypervisor
>> to be more accurate [Mpe].
>> * Fixed up mention of register notation used for describing
>> hcalls. [Mpe]
>> * s/NVDimm/NVDIMM [Mpe]
>> * Added section on return values from hcall [Mpe]
>> * Described H_CONTINUE return-value for long running hcalls.
>> ---
>> Documentation/powerpc/papr_hcalls.rst | 200 ++++++++++++++++++++++++++
>> 1 file changed, 200 insertions(+)
>> create mode 100644 Documentation/powerpc/papr_hcalls.rst
>>
>> diff --git a/Documentation/powerpc/papr_hcalls.rst b/Documentation/powerpc/papr_hcalls.rst
>> new file mode 100644
>> index 000000000000..7afc0310de29
>> --- /dev/null
>> +++ b/Documentation/powerpc/papr_hcalls.rst
>> @@ -0,0 +1,200 @@
>> +===========================
>> +Hypercall Op-codes (hcalls)
>> +===========================
>> +
>> +Overview
>> +=========
>> +
>> +Virtualization on 64-bit Power Book3S Platforms is based on the PAPR
>> +specification [1]_ which describes the run-time environment for a guest
>> +operating system and how it should interact with the hypervisor for
>> +privileged operations. Currently there are two PAPR compliant hypervisors:
>> +
>> +- **IBM PowerVM (PHYP)**: IBM's proprietary hypervisor that supports AIX,
>> + IBM-i and Linux as supported guests (termed as Logical Partitions
>> + or LPARS). It supports the full PAPR specification.
>> +
>> +- **Qemu/KVM**: Supports PPC64 linux guests running on a PPC64 linux host.
>> + Though it only implements a subset of PAPR specification called LoPAPR [2]_.
>> +
>> +On PPC64 arch a guest kernel running on top of a PAPR hypervisor is called
>> +a *pSeries guest*. A pseries guest runs in a supervisor mode (HV=0) and must
>> +issue hypercalls to the hypervisor whenever it needs to perform an action
>> +that is hypervisor priviledged [3]_ or for other services managed by the
>> +hypervisor.
>> +
>> +Hence a Hypercall (hcall) is essentially a request by the pSeries guest
>> +asking hypervisor to perform a privileged operation on behalf of the guest. The
>> +guest issues a with necessary input operands. The hypervisor after performing
> ^ hcall ?
>
>> +the privilege operation returns a status code and output operands back to the
>> +guest.
>> +
>> +HCALL ABI
>> +=========
>> +The ABI specification for a hcall between a pSeries guest and PAPR hypervisor
>> +is covered in section 14.5.3 of ref [2]_. Switch to the Hypervisor context is
>> +done via the instruction **HVCS** that expects the Opcode for hcall is set in *r3*
>> +and any in-arguments for the hcall are provided in registers *r4-r12* in
>> +Big-endian byte order.
> Indeed, register valuer are not byte ordered, only values passed through
> buffer in memory are byte ordered.
>
> Should it be explicitly said that Big-endian order is only concerning data
> stored in memory?
> What about something like that:
> "...any in-arguments for the hcall are provided in registers *r4-r12*. If
> values have to be passed through a memory buffer, the data stored in that
> buffer are in Big-endian order."
Yes that would be better.
I guess to be pedantic every structure passed in memory needs to be
defined in PAPR and could have some arbitrary ordering, but in practice
everything is big endian.
cheers
^ permalink raw reply
* Re: [PATCH] powerpc: use the generic dma coherent remap allocator
From: Michael Ellerman @ 2019-08-28 13:34 UTC (permalink / raw)
To: Christoph Hellwig, Benjamin Herrenschmidt, Paul Mackerras; +Cc: linuxppc-dev
In-Reply-To: <20190828061023.GB21592@lst.de>
Christoph Hellwig <hch@lst.de> writes:
> Michael,
>
> do oyu plan to pick this up? Otherwise I'd love to pick it up through
> the dma-mapping tree as that would avoid one trivial conflict with
> another pending patch.
It conflicts a bit with the ioremap changes I already have in next.
And it would be good for it to get some testing on my machines here. So
I guess I'd rather it went via the powerpc tree?
cheers
^ permalink raw reply
* [PATCH] powerpc/booke: Spelling s/date/data/
From: Geert Uytterhoeven @ 2019-08-28 13:34 UTC (permalink / raw)
To: chenhui zhao, Scott Wood, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman
Cc: linuxppc-dev, linux-kernel, Geert Uytterhoeven
Caching dates is never a good idea ;-)
Fixes: e7affb1dba0e9068 ("powerpc/cache: add cache flush operation for various e500")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
arch/powerpc/kernel/cpu_setup_fsl_booke.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 2b4f3ec0acf7d988..1d308780e0d31eb9 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -231,7 +231,7 @@ _GLOBAL(__setup_cpu_e5500)
blr
#endif
-/* flush L1 date cache, it can apply to e500v2, e500mc and e5500 */
+/* flush L1 data cache, it can apply to e500v2, e500mc and e5500 */
_GLOBAL(flush_dcache_L1)
mfmsr r10
wrteei 0
--
2.17.1
^ permalink raw reply related
* [PATCH] powerpc/reg: use ASM_FTR_IFSET() instead of opencoding fixup.
From: Christophe Leroy @ 2019-08-28 13:42 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
mftb() includes a feature fixup for CELL ppc.
Use ASM_FTR_IFSET() macro instead of opencoding the setup
of the fixup sections.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/include/asm/reg.h | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 10caa145f98b..7acce24ace49 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1378,19 +1378,9 @@ static inline void msr_check_and_clear(unsigned long bits)
#define mftb() ({unsigned long rval; \
asm volatile( \
"90: mfspr %0, %2;\n" \
- "97: cmpwi %0,0;\n" \
- " beq- 90b;\n" \
- "99:\n" \
- ".section __ftr_fixup,\"a\"\n" \
- ".align 3\n" \
- "98:\n" \
- " .8byte %1\n" \
- " .8byte %1\n" \
- " .8byte 97b-98b\n" \
- " .8byte 99b-98b\n" \
- " .8byte 0\n" \
- " .8byte 0\n" \
- ".previous" \
+ ASM_FTR_IFSET( \
+ "97: cmpwi %0,0;\n" \
+ " beq- 90b;\n", "", %1) \
: "=r" (rval) \
: "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL) : "cr0"); \
rval;})
--
2.13.3
^ permalink raw reply related
* Re: [PATCH v12 00/11] Appended signatures support for IMA appraisal
From: Mimi Zohar @ 2019-08-28 13:43 UTC (permalink / raw)
To: Jordan Hand, Thiago Jung Bauermann, linux-integrity
Cc: Herbert Xu, linux-doc, Dmitry Kasatkin, David S. Miller,
Jonathan Corbet, linux-kernel, James Morris, David Howells,
AKASHI, Takahiro, linux-security-module, keyrings, linux-crypto,
Jessica Yu, linuxppc-dev, David Woodhouse, Serge E. Hallyn
In-Reply-To: <9682b5d0-1634-2dd0-2cbb-eb1fa8ba7423@linux.microsoft.com>
Hi Jordan,
On Mon, 2019-08-26 at 15:46 -0700, Jordan Hand wrote:
> On 6/27/19 7:19 PM, Thiago Jung Bauermann wrote:
> > On the OpenPOWER platform, secure boot and trusted boot are being
> > implemented using IMA for taking measurements and verifying signatures.
> > Since the kernel image on Power servers is an ELF binary, kernels are
> > signed using the scripts/sign-file tool and thus use the same signature
> > format as signed kernel modules.
> >
> > This patch series adds support in IMA for verifying those signatures.
> > It adds flexibility to OpenPOWER secure boot, because it allows it to boot
> > kernels with the signature appended to them as well as kernels where the
> > signature is stored in the IMA extended attribute.
>
> I know this is pretty late, but I just wanted to let you know that I
> tested this patch set on x86_64 with QEMU.
>
> That is, I enrolled a key to _ima keyring, signed my kernel and modules
> with appended signatures (with scripts/sign-file), set the IMA policy to
> appraise and measure my kernel and modules. Also tested kexec appraisal.
>
> You can add my tested-by if you'd like.
I really appreciate your testing. Based on the recent
Documentation/maintainer/rebasing-and-merging.rst, I'm trying not to
rebase patches already staged in linux-next. Patches are first being
staged in the next-queued-testing branch.
FYI, I just posted a patch that adds IMA appended signature support to
test_kexec_file_load.sh.
thanks,
Mimi
^ permalink raw reply
* Re: [PATCH] powerpc: Avoid clang warnings around setjmp and longjmp
From: Michael Ellerman @ 2019-08-28 13:43 UTC (permalink / raw)
To: Nathan Chancellor, Benjamin Herrenschmidt, Paul Mackerras,
Nick Desaulniers
Cc: clang-built-linux, Nathan Chancellor, linuxppc-dev, linux-kernel,
stable
In-Reply-To: <20190812023214.107817-1-natechancellor@gmail.com>
Nathan Chancellor <natechancellor@gmail.com> writes:
> Commit aea447141c7e ("powerpc: Disable -Wbuiltin-requires-header when
> setjmp is used") disabled -Wbuiltin-requires-header because of a warning
> about the setjmp and longjmp declarations.
>
> r367387 in clang added another diagnostic around this, complaining that
> there is no jmp_buf declaration.
>
> In file included from ../arch/powerpc/xmon/xmon.c:47:
> ../arch/powerpc/include/asm/setjmp.h:10:13: error: declaration of
> built-in function 'setjmp' requires the declaration of the 'jmp_buf'
> type, commonly provided in the header <setjmp.h>.
> [-Werror,-Wincomplete-setjmp-declaration]
> extern long setjmp(long *);
> ^
> ../arch/powerpc/include/asm/setjmp.h:11:13: error: declaration of
> built-in function 'longjmp' requires the declaration of the 'jmp_buf'
> type, commonly provided in the header <setjmp.h>.
> [-Werror,-Wincomplete-setjmp-declaration]
> extern void longjmp(long *, long);
> ^
> 2 errors generated.
>
> Take the same approach as the above commit by disabling the warning for
> the same reason, we provide our own longjmp/setjmp function.
>
> Cc: stable@vger.kernel.org # 4.19+
> Link: https://github.com/ClangBuiltLinux/linux/issues/625
> Link: https://github.com/llvm/llvm-project/commit/3be25e79477db2d31ac46493d97eca8c20592b07
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> It may be worth using -fno-builtin-setjmp and -fno-builtin-longjmp
> instead as it makes it clear to clang that we are not using the builtin
> longjmp and setjmp functions, which I think is why these warnings are
> appearing (at least according to the commit that introduced this waring).
>
> Sample patch:
> https://github.com/ClangBuiltLinux/linux/issues/625#issuecomment-519251372
Couldn't we just add those flags to CFLAGS for the whole kernel? Rather
than making them per-file.
I mean there's no kernel code that wants to use clang's builtin
setjmp/longjmp implementation at all right?
cheers
^ permalink raw reply
* Re: [PATCH v2] powerpc/mm: Implement STRICT_MODULE_RWX
From: Christophe Leroy @ 2019-08-28 13:54 UTC (permalink / raw)
To: Russell Currey, linuxppc-dev; +Cc: kernel-hardening
In-Reply-To: <20190614055013.21014-1-ruscur@russell.cc>
Any plan to getting this applied soon ?
Christophe
Le 14/06/2019 à 07:50, Russell Currey a écrit :
> Strict module RWX is just like strict kernel RWX, but for modules - so
> loadable modules aren't marked both writable and executable at the same
> time. This is handled by the generic code in kernel/module.c, and
> simply requires the architecture to implement the set_memory() set of
> functions, declared with ARCH_HAS_SET_MEMORY.
>
> There's nothing other than these functions required to turn
> ARCH_HAS_STRICT_MODULE_RWX on, so turn that on too.
>
> With STRICT_MODULE_RWX enabled, there are as many W+X pages at runtime
> as there are with CONFIG_MODULES=n (none), so in Russel's testing it works
> well on both Hash and Radix book3s64.
>
> There's a TODO in the code for also applying the page permission changes
> to the backing pages in the linear mapping: this is pretty simple for
> Radix and (seemingly) a lot harder for Hash, so I've left it for now
> since there's still a notable security benefit for the patch as-is.
>
> Technically can be enabled without STRICT_KERNEL_RWX, but
> that doesn't gets you a whole lot, so we should leave it off by default
> until we can get STRICT_KERNEL_RWX to the point where it's enabled by
> default.
>
> Signed-off-by: Russell Currey <ruscur@russell.cc>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> Changes from v1 (sent by Christophe):
> - return if VM_FLUSH_RESET_PERMS is set
>
> arch/powerpc/Kconfig | 2 +
> arch/powerpc/include/asm/set_memory.h | 32 ++++++++++
> arch/powerpc/mm/Makefile | 2 +-
> arch/powerpc/mm/pageattr.c | 85 +++++++++++++++++++++++++++
> 4 files changed, 120 insertions(+), 1 deletion(-)
> create mode 100644 arch/powerpc/include/asm/set_memory.h
> create mode 100644 arch/powerpc/mm/pageattr.c
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 8c1c636308c8..3d98240ce965 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -131,7 +131,9 @@ config PPC
> select ARCH_HAS_PTE_SPECIAL
> select ARCH_HAS_MEMBARRIER_CALLBACKS
> select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64
> + select ARCH_HAS_SET_MEMORY
> select ARCH_HAS_STRICT_KERNEL_RWX if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION)
> + select ARCH_HAS_STRICT_MODULE_RWX if PPC_BOOK3S_64 || PPC32
> select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
> select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64
> select ARCH_HAS_UBSAN_SANITIZE_ALL
> diff --git a/arch/powerpc/include/asm/set_memory.h b/arch/powerpc/include/asm/set_memory.h
> new file mode 100644
> index 000000000000..4b9683f3b3dd
> --- /dev/null
> +++ b/arch/powerpc/include/asm/set_memory.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +#ifndef _ASM_POWERPC_SET_MEMORY_H
> +#define _ASM_POWERPC_SET_MEMORY_H
> +
> +#define SET_MEMORY_RO 1
> +#define SET_MEMORY_RW 2
> +#define SET_MEMORY_NX 3
> +#define SET_MEMORY_X 4
> +
> +int change_memory(unsigned long addr, int numpages, int action);
> +
> +static inline int set_memory_ro(unsigned long addr, int numpages)
> +{
> + return change_memory(addr, numpages, SET_MEMORY_RO);
> +}
> +
> +static inline int set_memory_rw(unsigned long addr, int numpages)
> +{
> + return change_memory(addr, numpages, SET_MEMORY_RW);
> +}
> +
> +static inline int set_memory_nx(unsigned long addr, int numpages)
> +{
> + return change_memory(addr, numpages, SET_MEMORY_NX);
> +}
> +
> +static inline int set_memory_x(unsigned long addr, int numpages)
> +{
> + return change_memory(addr, numpages, SET_MEMORY_X);
> +}
> +
> +#endif
> diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
> index 0f499db315d6..b683d1c311b3 100644
> --- a/arch/powerpc/mm/Makefile
> +++ b/arch/powerpc/mm/Makefile
> @@ -7,7 +7,7 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
>
> obj-y := fault.o mem.o pgtable.o mmap.o \
> init_$(BITS).o pgtable_$(BITS).o \
> - pgtable-frag.o \
> + pgtable-frag.o pageattr.o \
> init-common.o mmu_context.o drmem.o
> obj-$(CONFIG_PPC_MMU_NOHASH) += nohash/
> obj-$(CONFIG_PPC_BOOK3S_32) += book3s32/
> diff --git a/arch/powerpc/mm/pageattr.c b/arch/powerpc/mm/pageattr.c
> new file mode 100644
> index 000000000000..41baf92f632b
> --- /dev/null
> +++ b/arch/powerpc/mm/pageattr.c
> @@ -0,0 +1,85 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +/*
> + * Page attribute and set_memory routines
> + *
> + * Derived from the arm64 implementation.
> + *
> + * Author: Russell Currey <ruscur@russell.cc>
> + *
> + * Copyright 2019, IBM Corporation.
> + *
> + */
> +
> +#include <linux/mm.h>
> +#include <linux/set_memory.h>
> +#include <linux/vmalloc.h>
> +
> +#include <asm/mmu.h>
> +#include <asm/page.h>
> +#include <asm/pgtable.h>
> +
> +static int change_page_ro(pte_t *ptep, pgtable_t token, unsigned long addr, void *data)
> +{
> + set_pte_at(&init_mm, addr, ptep, pte_wrprotect(READ_ONCE(*ptep)));
> + return 0;
> +}
> +
> +static int change_page_rw(pte_t *ptep, pgtable_t token, unsigned long addr, void *data)
> +{
> + set_pte_at(&init_mm, addr, ptep, pte_mkwrite(READ_ONCE(*ptep)));
> + return 0;
> +}
> +
> +static int change_page_nx(pte_t *ptep, pgtable_t token, unsigned long addr, void *data)
> +{
> + set_pte_at(&init_mm, addr, ptep, pte_exprotect(READ_ONCE(*ptep)));
> + return 0;
> +}
> +
> +static int change_page_x(pte_t *ptep, pgtable_t token, unsigned long addr, void *data)
> +{
> + set_pte_at(&init_mm, addr, ptep, pte_mkexec(READ_ONCE(*ptep)));
> + return 0;
> +}
> +
> +int change_memory(unsigned long addr, int numpages, int action)
> +{
> + unsigned long size = numpages * PAGE_SIZE;
> + unsigned long start = ALIGN_DOWN(addr, PAGE_SIZE);
> + unsigned long end = start + size;
> + struct vm_struct *area;
> + int ret;
> +
> + if (!numpages)
> + return 0;
> +
> + // only operate on VM areas for now
> + area = find_vm_area((void *)addr);
> + if (!area || end > (unsigned long)area->addr + area->size ||
> + !(area->flags & VM_ALLOC) || (area->flags & VM_FLUSH_RESET_PERMS))
> + return -EINVAL;
> +
> + // TODO: also apply change to the backing pages in the linear mapping
> +
> + switch (action) {
> + case SET_MEMORY_RO:
> + ret = apply_to_page_range(&init_mm, start, size, change_page_ro, NULL);
> + break;
> + case SET_MEMORY_RW:
> + ret = apply_to_page_range(&init_mm, start, size, change_page_rw, NULL);
> + break;
> + case SET_MEMORY_NX:
> + ret = apply_to_page_range(&init_mm, start, size, change_page_nx, NULL);
> + break;
> + case SET_MEMORY_X:
> + ret = apply_to_page_range(&init_mm, start, size, change_page_x, NULL);
> + break;
> + default:
> + WARN_ON(true);
> + return -EINVAL;
> + }
> +
> + flush_tlb_kernel_range(start, end);
> + return ret;
> +}
>
^ permalink raw reply
* Re: [PATCH] powerpc: use the generic dma coherent remap allocator
From: Christoph Hellwig @ 2019-08-28 14:25 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Paul Mackerras, Christoph Hellwig
In-Reply-To: <87blw9v2ge.fsf@mpe.ellerman.id.au>
On Wed, Aug 28, 2019 at 11:34:09PM +1000, Michael Ellerman wrote:
> Christoph Hellwig <hch@lst.de> writes:
> > Michael,
> >
> > do oyu plan to pick this up? Otherwise I'd love to pick it up through
> > the dma-mapping tree as that would avoid one trivial conflict with
> > another pending patch.
>
> It conflicts a bit with the ioremap changes I already have in next.
>
> And it would be good for it to get some testing on my machines here. So
> I guess I'd rather it went via the powerpc tree?
Sure, feel free to queue it up through the ppc tree. I am about to
queue up a patch to move the dma_atomic_pool_init call to common code,
so as linux-next / Linus fixup we'll have to eventually remove
atomic_pool_init() again.
^ permalink raw reply
* Re: [PATCH v2 3/4] powerpc/64: make buildable without CONFIG_COMPAT
From: Michal Suchánek @ 2019-08-28 14:29 UTC (permalink / raw)
To: Christophe Leroy
Cc: David Hildenbrand, Dmitry V. Levin, Max Filippov, Paul Mackerras,
Breno Leitao, Michael Neuling, Firoz Khan, Hari Bathini,
Joel Stanley, Nicholas Piggin, Steven Rostedt, Thomas Gleixner,
Allison Randal, Greg Kroah-Hartman, linux-kernel,
Eric W. Biederman, Andrew Donnellan, linux-fsdevel, Andrew Morton,
linuxppc-dev, Alexander Viro
In-Reply-To: <fb471a46-5598-1c5c-911f-499b1aad259c@c-s.fr>
On Wed, 28 Aug 2019 14:49:16 +0200
Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> Le 28/08/2019 à 12:30, Michal Suchanek a écrit :
> > There are numerous references to 32bit functions in generic and 64bit
> > code so ifdef them out.
>
> As far as possible, avoid opting things out with ifdefs. Ref
> https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation
>
> See comment below.
>
> >
> > Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> > ---
> > v2:
> > - fix 32bit ifdef condition in signal.c
> > - simplify the compat ifdef condition in vdso.c - 64bit is redundant
> > - simplify the compat ifdef condition in callchain.c - 64bit is redundant
> > ---
> > arch/powerpc/include/asm/syscall.h | 2 ++
> > arch/powerpc/kernel/Makefile | 15 ++++++++++++---
> > arch/powerpc/kernel/entry_64.S | 2 ++
> > arch/powerpc/kernel/signal.c | 5 +++--
> > arch/powerpc/kernel/syscall_64.c | 5 +++--
> > arch/powerpc/kernel/vdso.c | 4 +++-
> > arch/powerpc/perf/callchain.c | 14 ++++++++++----
> > 7 files changed, 35 insertions(+), 12 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> > index 38d62acfdce7..3ed3b75541a1 100644
> > --- a/arch/powerpc/include/asm/syscall.h
> > +++ b/arch/powerpc/include/asm/syscall.h
> > @@ -16,7 +16,9 @@
> >
> > /* ftrace syscalls requires exporting the sys_call_table */
> > extern const unsigned long sys_call_table[];
> > +#ifdef CONFIG_COMPAT
> > extern const unsigned long compat_sys_call_table[];
> > +#endif
>
> Leaving the declaration should be harmless.
Yes, it only allows earlier check that the type is not used.
>
> >
> > static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
> > {
> > diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> > index 1d646a94d96c..b0db365b83d8 100644
> > --- a/arch/powerpc/kernel/Makefile
> > +++ b/arch/powerpc/kernel/Makefile
> > @@ -44,16 +44,25 @@ CFLAGS_btext.o += -DDISABLE_BRANCH_PROFILING
> > endif
> >
> > obj-y := cputable.o ptrace.o syscalls.o \
> > - irq.o align.o signal_32.o pmc.o vdso.o \
> > + irq.o align.o pmc.o vdso.o \
> > process.o systbl.o idle.o \
> > signal.o sysfs.o cacheinfo.o time.o \
> > prom.o traps.o setup-common.o \
> > udbg.o misc.o io.o misc_$(BITS).o \
> > of_platform.o prom_parse.o
> > -obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
> > - signal_64.o ptrace32.o \
> > +ifndef CONFIG_PPC64
> > +obj-y += signal_32.o
> > +else
> > +ifdef CONFIG_COMPAT
> > +obj-y += signal_32.o
> > +endif
> > +endif
> > +obj-$(CONFIG_PPC64) += setup_64.o signal_64.o \
> > paca.o nvram_64.o firmware.o \
> > syscall_64.o
>
> That's still a bit messy. You could have:
>
> obj-y = +=signal_$(BITS).o
> obj-$(CONFIG_COMPAT) += signal_32.o
>
> > +ifdef CONFIG_COMPAT
> > +obj-$(CONFIG_PPC64) += sys_ppc32.o ptrace32.o
> > +endif
>
> AFAIK, CONFIG_COMPAT is only defined when CONFIG_PP64 is defined, so
> could be:
>
> obj-$(CONFIG_COMPAT) += sys_ppc32.o ptrace32.o
>
> And could be grouped with the above signal_32.o
>
Looks better.
>
> > obj-$(CONFIG_VDSO32) += vdso32/
> > obj-$(CONFIG_PPC_WATCHDOG) += watchdog.o
> > obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
> > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> > index 2ec825a85f5b..a2dbf216f607 100644
> > --- a/arch/powerpc/kernel/entry_64.S
> > +++ b/arch/powerpc/kernel/entry_64.S
> > @@ -51,8 +51,10 @@
> > SYS_CALL_TABLE:
> > .tc sys_call_table[TC],sys_call_table
> >
> > +#ifdef CONFIG_COMPAT
> > COMPAT_SYS_CALL_TABLE:
> > .tc compat_sys_call_table[TC],compat_sys_call_table
> > +#endif
>
> Can we avoid this ifdef ?
AFAICT it creates reference to non-existent table otherwise.
>
> >
> > /* This value is used to mark exception frames on the stack. */
> > exception_marker:
> > diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
> > index 60436432399f..ffd045e9fb57 100644
> > --- a/arch/powerpc/kernel/signal.c
> > +++ b/arch/powerpc/kernel/signal.c
> > @@ -277,14 +277,15 @@ static void do_signal(struct task_struct *tsk)
> >
> > rseq_signal_deliver(&ksig, tsk->thread.regs);
> >
> > +#if !defined(CONFIG_PPC64) || defined(CONFIG_COMPAT)
> > if (is32) {
> > if (ksig.ka.sa.sa_flags & SA_SIGINFO)
> > ret = handle_rt_signal32(&ksig, oldset, tsk);
> > else
> > ret = handle_signal32(&ksig, oldset, tsk);
> > - } else {
> > + } else
>
> " if only one branch of a conditional statement is a single statement
> [...] use braces in both branches"
>
> Ref
> https://www.kernel.org/doc/html/latest/process/coding-style.html#placing-braces-and-spaces
>
> > +#endif /* 32bit */
>
> Having an #ifdef in a middle of a if/else is gross.
>
> Check what are the possible values for is32. It will be always true
> which CONFIG_PPC32.
> If you can make sure it is always false without CONFIG_COMPAT, you are
> done. If not, then combine the if(is32) with something involving
> IS_ENABLED(CONFIG_COMPAT).
The value of is32 is not a problem. References to non-existent
functions could be.
...
> > diff --git a/arch/powerpc/perf/callchain.c b/arch/powerpc/perf/callchain.c
> > index c84bbd4298a0..b3dacc8bc98d 100644
> > --- a/arch/powerpc/perf/callchain.c
> > +++ b/arch/powerpc/perf/callchain.c
> > @@ -15,7 +15,7 @@
> > #include <asm/sigcontext.h>
> > #include <asm/ucontext.h>
> > #include <asm/vdso.h>
> > -#ifdef CONFIG_PPC64
> > +#ifdef CONFIG_COMPAT
> > #include "../kernel/ppc32.h"
/srv/kernel/arch/powerpc/perf/../kernel/ppc32.h:50:2: error: unknown type name ‘compat_stack_t’
When required declarations are ifdefed in compat.h
> >
> > static inline int valid_user_sp(unsigned long sp, int is_64)
> > {
> > @@ -341,6 +343,7 @@ static inline int valid_user_sp(unsigned long sp, int is_64)
> >
> > #endif /* CONFIG_PPC64 */
> >
> > +#if !defined(CONFIG_PPC64) || defined(CONFIG_COMPAT)
>
> You don't need to opt that out.
You need to opt out here:
/srv/kernel/arch/powerpc/perf/callchain.c:349:22: error: field ‘sctx’ has incomplete type
struct sigcontext32 sctx;
/srv/kernel/arch/powerpc/perf/callchain.c:359:2: error: unknown type name ‘compat_siginfo_t’
compat_siginfo_t info;
...
>
> > /*
> > * Layout for non-RT signal frames
> > */
> > @@ -482,12 +485,15 @@ static void perf_callchain_user_32(struct perf_callchain_entry_ctx *entry,
> > sp = next_sp;
> > }
> > }
> > +#endif /* 32bit */
> >
> > void
> > perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
> > {
> > - if (current_is_64bit())
> > - perf_callchain_user_64(entry, regs);
> > - else
> > +#if !defined(CONFIG_PPC64) || defined(CONFIG_COMPAT)
> > + if (!current_is_64bit())
> > perf_callchain_user_32(entry, regs);
> > + else
> > +#endif
> > + perf_callchain_user_64(entry, regs);
>
> Please rewrite using IS_ENABLED() instead of #ifdefs.
And ifdef here.
The ifdefs could be potentially reduced in some places, though.
Thanks
Michal
^ permalink raw reply
* Re: [PATCH v2 0/4] Disable compat cruft on ppc64le v2
From: Michal Suchánek @ 2019-08-28 14:37 UTC (permalink / raw)
To: Christophe Leroy
Cc: David Hildenbrand, Dmitry V. Levin, Max Filippov, Paul Mackerras,
Breno Leitao, Michael Neuling, Firoz Khan, Hari Bathini,
Joel Stanley, Nicholas Piggin, Steven Rostedt, Thomas Gleixner,
Allison Randal, Greg Kroah-Hartman, linux-kernel,
Eric W. Biederman, Andrew Donnellan, linux-fsdevel, Andrew Morton,
linuxppc-dev, Alexander Viro
In-Reply-To: <dbc5abde-ea15-be43-1fdb-d16052c19e03@c-s.fr>
On Wed, 28 Aug 2019 13:08:48 +0000
Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> On 08/28/2019 10:30 AM, Michal Suchanek wrote:
> > With endian switch disabled by default the ppc64le compat supports
> > ppc32le only which is something next to nobody has binaries for.
> >
> > Less code means less bugs so drop the compat stuff.
> >
> > I am not particularly sure about the best way to resolve the llseek
> > situation. I don't see anything in the syscal tables making it
> > 32bit-only so I suppose it should be available on 64bit as well.
> >
> > This is tested on ppc64le top of
>
> Really ?
Really. It boots with the unused variable. It might depend on some
config options or gcc features if unused variables are fatal.
Thanks
Michal
^ permalink raw reply
* Re: [PATCH v2 0/4] Disable compat cruft on ppc64le v2
From: Michal Suchánek @ 2019-08-28 14:40 UTC (permalink / raw)
To: Nicholas Piggin
Cc: Michael Neuling, Eric W. Biederman, David Hildenbrand,
Greg Kroah-Hartman, linux-fsdevel, Hari Bathini, linux-kernel,
Steven Rostedt, Dmitry V. Levin, Max Filippov, Paul Mackerras,
Joel Stanley, Andrew Donnellan, Breno Leitao, Firoz Khan,
Thomas Gleixner, linuxppc-dev, Andrew Morton, Allison Randal,
Alexander Viro
In-Reply-To: <1566988993.aiyajovdx0.astroid@bobo.none>
On Wed, 28 Aug 2019 20:57:48 +1000
Nicholas Piggin <npiggin@gmail.com> wrote:
> Michal Suchanek's on August 28, 2019 8:30 pm:
> > With endian switch disabled by default the ppc64le compat supports
> > ppc32le only which is something next to nobody has binaries for.
> >
> > Less code means less bugs so drop the compat stuff.
>
> Interesting patches, thanks for looking into it. I don't know much
> about compat and wrong endian userspaces. I think sys_switch_endian
> is enabled though, it's just a strange fast endian swap thing that
> has been disabled by default.
>
> The first patches look pretty good. Maybe for the last one it could
> become a selectable option?
That sounds good.
>
>
> > I am not particularly sure about the best way to resolve the llseek
> > situation. I don't see anything in the syscal tables making it
> > 32bit-only so I suppose it should be available on 64bit as well.
>
> It's for 32-bit userspace only. Can we just get rid of it, or is
> there some old broken 64-bit BE userspace that tries to call it?
That sounds like a bug in creating these unified syscall tables then.
On architectures that have split tables the 64bit ones do not have
llseek. On architectures with one table the syscall is marked as common.
Thanks
Michal
^ permalink raw reply
* Re: [PATCH] sefltest/ima: support appended signatures (modsig)
From: shuah @ 2019-08-28 14:45 UTC (permalink / raw)
To: Mimi Zohar, linux-integrity
Cc: shuah, Dave Young, linux-kernel, Petr Vorel, linux-kselftest,
Jessica Yu, linuxppc-dev, Thiago Jung Bauermann
In-Reply-To: <1566995946-6582-1-git-send-email-zohar@linux.ibm.com>
Hi Mimi,
On 8/28/19 6:39 AM, Mimi Zohar wrote:
> Detect and allow appended signatures.
>
Can you please add a couple of more sentences on the feature
and what happens without it? I know this is a test for the
feature, however, it will be useful for users and testers to
know more about this test and the feature it is testing.
Also, are there test skip conditions to be concerned about?
Is there a dependency on another tree or would like me to take
this through kselftest tree?
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> ---
> .../selftests/kexec/test_kexec_file_load.sh | 38 +++++++++++++++++++---
> 1 file changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/kexec/test_kexec_file_load.sh b/tools/testing/selftests/kexec/test_kexec_file_load.sh
> index fa7c24e8eefb..2ff600388c30 100755
> --- a/tools/testing/selftests/kexec/test_kexec_file_load.sh
> +++ b/tools/testing/selftests/kexec/test_kexec_file_load.sh
> @@ -37,11 +37,20 @@ is_ima_sig_required()
> # sequentially. As a result, a policy rule may be defined, but
> # might not necessarily be used. This test assumes if a policy
> # rule is specified, that is the intent.
> +
> + # First check for appended signature (modsig), then xattr
> if [ $ima_read_policy -eq 1 ]; then
> check_ima_policy "appraise" "func=KEXEC_KERNEL_CHECK" \
> - "appraise_type=imasig"
> + "appraise_type=imasig|modsig"
> ret=$?
> - [ $ret -eq 1 ] && log_info "IMA signature required";
> + if [ $ret -eq 1 ]; then
> + log_info "IMA or appended(modsig) signature required"
> + else
> + check_ima_policy "appraise" "func=KEXEC_KERNEL_CHECK" \
> + "appraise_type=imasig"
> + ret=$?
> + [ $ret -eq 1 ] && log_info "IMA signature required";
> + fi
> fi
> return $ret
> }
> @@ -84,6 +93,22 @@ check_for_imasig()
> return $ret
> }
>
> +# Return 1 for appended signature (modsig) found and 0 for not found.
> +check_for_modsig()
> +{
> + local module_sig_string="~Module signature appended~"
> + local sig="$(tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE)"
> + local ret=0
> +
> + if [ "$sig" == "$module_sig_string" ]; then
> + ret=1
> + log_info "kexec kernel image modsig signed"
> + else
> + log_info "kexec kernel image not modsig signed"
> + fi
> + return $ret
> +}
> +
> kexec_file_load_test()
> {
> local succeed_msg="kexec_file_load succeeded"
> @@ -98,7 +123,8 @@ kexec_file_load_test()
> # In secureboot mode with an architecture specific
> # policy, make sure either an IMA or PE signature exists.
> if [ $secureboot -eq 1 ] && [ $arch_policy -eq 1 ] && \
> - [ $ima_signed -eq 0 ] && [ $pe_signed -eq 0 ]; then
> + [ $ima_signed -eq 0 ] && [ $pe_signed -eq 0 ] \
> + && [ $ima_modsig -eq 0 ]; then
> log_fail "$succeed_msg (missing sig)"
> fi
>
> @@ -107,7 +133,8 @@ kexec_file_load_test()
> log_fail "$succeed_msg (missing PE sig)"
> fi
>
> - if [ $ima_sig_required -eq 1 ] && [ $ima_signed -eq 0 ]; then
> + if [ $ima_sig_required -eq 1 ] && [ $ima_signed -eq 0 ] \
> + && [ $ima_modsig -eq 0 ]; then
> log_fail "$succeed_msg (missing IMA sig)"
> fi
>
> @@ -204,5 +231,8 @@ pe_signed=$?
> check_for_imasig
> ima_signed=$?
>
> +check_for_modsig
> +ima_modsig=$?
> +
> # Test loading the kernel image via kexec_file_load syscall
> kexec_file_load_test
>
thanks,
-- Shuah
^ permalink raw reply
* [PATCH v1] sefltest/ima: support appended signatures (modsig)
From: Mimi Zohar @ 2019-08-28 15:14 UTC (permalink / raw)
To: linux-integrity
Cc: Dave Young, linuxppc-dev, Mimi Zohar, linux-kernel, Petr Vorel,
linux-kselftest, Jessica Yu, shuah, Thiago Jung Bauermann
In addition to the PE/COFF and IMA xattr signatures, the kexec kernel
image can be signed with an appended signature, using the same
scripts/sign-file tool that is used to sign kernel modules.
This patch adds support for detecting a kernel image signed with an
appended signature and updates the existing test messages
appropriately.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
.../selftests/kexec/test_kexec_file_load.sh | 38 +++++++++++++++++++---
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kexec/test_kexec_file_load.sh b/tools/testing/selftests/kexec/test_kexec_file_load.sh
index fa7c24e8eefb..2ff600388c30 100755
--- a/tools/testing/selftests/kexec/test_kexec_file_load.sh
+++ b/tools/testing/selftests/kexec/test_kexec_file_load.sh
@@ -37,11 +37,20 @@ is_ima_sig_required()
# sequentially. As a result, a policy rule may be defined, but
# might not necessarily be used. This test assumes if a policy
# rule is specified, that is the intent.
+
+ # First check for appended signature (modsig), then xattr
if [ $ima_read_policy -eq 1 ]; then
check_ima_policy "appraise" "func=KEXEC_KERNEL_CHECK" \
- "appraise_type=imasig"
+ "appraise_type=imasig|modsig"
ret=$?
- [ $ret -eq 1 ] && log_info "IMA signature required";
+ if [ $ret -eq 1 ]; then
+ log_info "IMA or appended(modsig) signature required"
+ else
+ check_ima_policy "appraise" "func=KEXEC_KERNEL_CHECK" \
+ "appraise_type=imasig"
+ ret=$?
+ [ $ret -eq 1 ] && log_info "IMA signature required";
+ fi
fi
return $ret
}
@@ -84,6 +93,22 @@ check_for_imasig()
return $ret
}
+# Return 1 for appended signature (modsig) found and 0 for not found.
+check_for_modsig()
+{
+ local module_sig_string="~Module signature appended~"
+ local sig="$(tail --bytes $((${#module_sig_string} + 1)) $KERNEL_IMAGE)"
+ local ret=0
+
+ if [ "$sig" == "$module_sig_string" ]; then
+ ret=1
+ log_info "kexec kernel image modsig signed"
+ else
+ log_info "kexec kernel image not modsig signed"
+ fi
+ return $ret
+}
+
kexec_file_load_test()
{
local succeed_msg="kexec_file_load succeeded"
@@ -98,7 +123,8 @@ kexec_file_load_test()
# In secureboot mode with an architecture specific
# policy, make sure either an IMA or PE signature exists.
if [ $secureboot -eq 1 ] && [ $arch_policy -eq 1 ] && \
- [ $ima_signed -eq 0 ] && [ $pe_signed -eq 0 ]; then
+ [ $ima_signed -eq 0 ] && [ $pe_signed -eq 0 ] \
+ && [ $ima_modsig -eq 0 ]; then
log_fail "$succeed_msg (missing sig)"
fi
@@ -107,7 +133,8 @@ kexec_file_load_test()
log_fail "$succeed_msg (missing PE sig)"
fi
- if [ $ima_sig_required -eq 1 ] && [ $ima_signed -eq 0 ]; then
+ if [ $ima_sig_required -eq 1 ] && [ $ima_signed -eq 0 ] \
+ && [ $ima_modsig -eq 0 ]; then
log_fail "$succeed_msg (missing IMA sig)"
fi
@@ -204,5 +231,8 @@ pe_signed=$?
check_for_imasig
ima_signed=$?
+check_for_modsig
+ima_modsig=$?
+
# Test loading the kernel image via kexec_file_load syscall
kexec_file_load_test
--
2.7.5
^ permalink raw reply related
* Re: [PATCH 1/4] fs: always build llseek.
From: Christoph Hellwig @ 2019-08-28 15:15 UTC (permalink / raw)
To: Michal Suchanek
Cc: Alexander Viro, Michael Neuling, David Hildenbrand,
Steven Rostedt, Greg Kroah-Hartman, linux-fsdevel, Allison Randal,
linux-kernel, Nicholas Piggin, Dmitry V. Levin, Max Filippov,
Paul Mackerras, Joel Stanley, Andrew Donnellan, Breno Leitao,
Firoz Khan, Thomas Gleixner, linuxppc-dev, Andrew Morton,
Hari Bathini, Eric W. Biederman
In-Reply-To: <80b1955b86fb81e4642881d498068b5a540ef029.1566936688.git.msuchanek@suse.de>
On Tue, Aug 27, 2019 at 10:21:06PM +0200, Michal Suchanek wrote:
> 64bit !COMPAT does not build because the llseek syscall is in the tables.
Well, this will bloat thinkgs like 64-bit RISC-V for no good reason.
Please introduce a WANT_LSEEK like symbol that ppc64 can select instead.
^ permalink raw reply
* Re: [PATCH] sefltest/ima: support appended signatures (modsig)
From: Mimi Zohar @ 2019-08-28 15:19 UTC (permalink / raw)
To: shuah, linux-integrity
Cc: Dave Young, linux-kernel, Petr Vorel, linux-kselftest, Jessica Yu,
linuxppc-dev, Thiago Jung Bauermann
In-Reply-To: <2f89d09f-1b69-3d77-6846-01bef7d20f39@kernel.org>
On Wed, 2019-08-28 at 08:45 -0600, shuah wrote:
> Hi Mimi,
>
> On 8/28/19 6:39 AM, Mimi Zohar wrote:
> > Detect and allow appended signatures.
> >
>
> Can you please add a couple of more sentences on the feature
> and what happens without it? I know this is a test for the
> feature, however, it will be useful for users and testers to
> know more about this test and the feature it is testing.
I've updated the patch description as requested.
> Also, are there test skip conditions to be concerned about?
The kexec selftests tests the coordination of the different methods of
verifying the kexec kernel image. As the appended signature support
is part of IMA, there is no new skip conditions.
> Is there a dependency on another tree or would like me to take
> this through kselftest tree?
I would prefer upstreaming this test with the rest of IMA support for
appended signatures.
thanks,
Mimi
^ permalink raw reply
* Re: [linux-next][BUG][driver/scsi/lpfc][10541f] Kernel panics when booting next kernel on my Power 9 box
From: James Smart @ 2019-08-28 15:22 UTC (permalink / raw)
To: Abdul Haleem, linuxppc-dev
Cc: sachinp, Stephen Rothwell, dick.kennedy, Martin K. Petersen,
linux-scsi, linux-kernel, linux-next, dougmill, Brian King,
manvanth
In-Reply-To: <1566968536.23670.9.camel@abdul>
On 8/27/2019 10:02 PM, Abdul Haleem wrote:
> Greetings,
>
> linux-next kernel 5.3.0-rc1 failed to boot with kernel Oops on Power 9
> box
>
> I see a recent changes to lpfc code was from commit
> 10541f03 scsi: lpfc: Update lpfc version to 12.4.0.0
>
> Recent boot logs:
>
> [..snip..]
see https://www.spinics.net/lists/linux-scsi/msg133343.html
It hasn't been tested yet, but appears to be the issue.
-- james
^ permalink raw reply
* Re: [PATCH v2 4/4] powerpc/64: system call implement the bulk of the logic in C
From: Michal Suchánek @ 2019-08-28 15:30 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linuxppc-dev
In-Reply-To: <20190827135548.21457-5-npiggin@gmail.com>
On Tue, 27 Aug 2019 23:55:48 +1000
Nicholas Piggin <npiggin@gmail.com> wrote:
> System call entry and particularly exit code is beyond the limit of what
> is reasonable to implement in asm.
>
> This conversion moves all conditional branches out of the asm code,
> except for the case that all GPRs should be restored at exit.
>
> Null syscall test is about 5% faster after this patch, because the exit
> work is handled under local_irq_disable, and the hard mask and pending
> interrupt replay is handled after that, which avoids games with MSR.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> Changes since v1:
> - Improve changelog
> - Lot of code cleanups, moving helpers out to proper header locations,
> etc (Christophe).
> - Split unnecessary change that affected ppc32 out. I will submit it
> independently (Christophe).
>
> arch/powerpc/include/asm/asm-prototypes.h | 11 -
> .../powerpc/include/asm/book3s/64/kup-radix.h | 12 +-
> arch/powerpc/include/asm/cputime.h | 22 ++
> arch/powerpc/include/asm/ptrace.h | 3 +
> arch/powerpc/include/asm/signal.h | 2 +
> arch/powerpc/include/asm/switch_to.h | 5 +
> arch/powerpc/include/asm/time.h | 3 +
> arch/powerpc/kernel/Makefile | 3 +-
> arch/powerpc/kernel/entry_64.S | 340 +++---------------
> arch/powerpc/kernel/signal.h | 2 -
> arch/powerpc/kernel/syscall_64.c | 177 +++++++++
> 11 files changed, 273 insertions(+), 307 deletions(-)
> create mode 100644 arch/powerpc/kernel/syscall_64.c
>
> diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h
> index ec1c97a8e8cb..f00ef8924a99 100644
> --- a/arch/powerpc/include/asm/asm-prototypes.h
> +++ b/arch/powerpc/include/asm/asm-prototypes.h
> @@ -92,14 +92,6 @@ long sys_switch_endian(void);
> notrace unsigned int __check_irq_replay(void);
> void notrace restore_interrupts(void);
>
> -/* ptrace */
> -long do_syscall_trace_enter(struct pt_regs *regs);
> -void do_syscall_trace_leave(struct pt_regs *regs);
> -
> -/* process */
> -void restore_math(struct pt_regs *regs);
> -void restore_tm_state(struct pt_regs *regs);
> -
> /* prom_init (OpenFirmware) */
> unsigned long __init prom_init(unsigned long r3, unsigned long r4,
> unsigned long pp,
> @@ -110,9 +102,6 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
> void __init early_setup(unsigned long dt_ptr);
> void early_setup_secondary(void);
>
> -/* time */
> -void accumulate_stolen_time(void);
> -
> /* misc runtime */
> extern u64 __bswapdi2(u64);
> extern s64 __lshrdi3(s64, int);
> diff --git a/arch/powerpc/include/asm/book3s/64/kup-radix.h b/arch/powerpc/include/asm/book3s/64/kup-radix.h
> index f254de956d6a..ef2e65ea8a73 100644
> --- a/arch/powerpc/include/asm/book3s/64/kup-radix.h
> +++ b/arch/powerpc/include/asm/book3s/64/kup-radix.h
> @@ -3,6 +3,7 @@
> #define _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
>
> #include <linux/const.h>
> +#include <asm/reg.h>
>
> #define AMR_KUAP_BLOCK_READ UL(0x4000000000000000)
> #define AMR_KUAP_BLOCK_WRITE UL(0x8000000000000000)
> @@ -56,7 +57,16 @@
>
> #ifdef CONFIG_PPC_KUAP
>
> -#include <asm/reg.h>
> +#include <asm/mmu.h>
> +#include <asm/ptrace.h>
> +
> +static inline void kuap_check_amr(void)
> +{
> +#ifdef CONFIG_PPC_KUAP_DEBUG
> + if (mmu_has_feature(MMU_FTR_RADIX_KUAP))
> + WARN_ON_ONCE(mfspr(SPRN_AMR) != AMR_KUAP_BLOCKED);
> +#endif
> +}
>
> /*
> * We support individually allowing read or write, but we don't support nesting
> diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
> index 2431b4ada2fa..f3aa9db1a3cc 100644
> --- a/arch/powerpc/include/asm/cputime.h
> +++ b/arch/powerpc/include/asm/cputime.h
> @@ -60,6 +60,28 @@ static inline void arch_vtime_task_switch(struct task_struct *prev)
> }
> #endif
>
> +static inline void account_cpu_user_entry(void)
> +{
> + unsigned long tb = mftb();
> +
> + get_accounting(current)->utime += (tb - get_accounting(current)->starttime_user);
> + get_accounting(current)->starttime = tb;
> +}
> +static inline void account_cpu_user_exit(void)
> +{
> + unsigned long tb = mftb();
> +
> + get_accounting(current)->stime += (tb - get_accounting(current)->starttime);
> + get_accounting(current)->starttime_user = tb;
> +}
> +
> #endif /* __KERNEL__ */
> +#else /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
> +static inline void account_cpu_user_entry(void)
> +{
> +}
> +static inline void account_cpu_user_exit(void)
> +{
> +}
> #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
> #endif /* __POWERPC_CPUTIME_H */
> diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
> index feee1b21bbd5..af363086403a 100644
> --- a/arch/powerpc/include/asm/ptrace.h
> +++ b/arch/powerpc/include/asm/ptrace.h
> @@ -138,6 +138,9 @@ extern unsigned long profile_pc(struct pt_regs *regs);
> #define profile_pc(regs) instruction_pointer(regs)
> #endif
>
> +long do_syscall_trace_enter(struct pt_regs *regs);
> +void do_syscall_trace_leave(struct pt_regs *regs);
> +
> #define kernel_stack_pointer(regs) ((regs)->gpr[1])
> static inline int is_syscall_success(struct pt_regs *regs)
> {
> diff --git a/arch/powerpc/include/asm/signal.h b/arch/powerpc/include/asm/signal.h
> index 0803ca8b9149..0113be8dcb59 100644
> --- a/arch/powerpc/include/asm/signal.h
> +++ b/arch/powerpc/include/asm/signal.h
> @@ -6,4 +6,6 @@
> #include <uapi/asm/signal.h>
> #include <uapi/asm/ptrace.h>
>
> +void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags);
> +
/srv/kernel/arch/powerpc/include/asm/signal.h:9:30: warning: ‘struct pt_regs’ declared inside parameter list will not be visible outside of this definition or declaration
void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags);
uapi/asm/ptrace.h defines user_pt_regs and asm/ptrace.h pt_regs.
I am not really sure which you wanted.
Thanks
Michal
^ permalink raw reply
* Re: [PATCH v1] sefltest/ima: support appended signatures (modsig)
From: shuah @ 2019-08-28 15:53 UTC (permalink / raw)
To: Mimi Zohar, linux-integrity
Cc: shuah, Dave Young, linux-kernel, Petr Vorel, linux-kselftest,
Jessica Yu, linuxppc-dev, Thiago Jung Bauermann
In-Reply-To: <1567005240-12912-1-git-send-email-zohar@linux.ibm.com>
On 8/28/19 9:14 AM, Mimi Zohar wrote:
> In addition to the PE/COFF and IMA xattr signatures, the kexec kernel
> image can be signed with an appended signature, using the same
> scripts/sign-file tool that is used to sign kernel modules.
>
> This patch adds support for detecting a kernel image signed with an
> appended signature and updates the existing test messages
> appropriately.
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> ---
Thanks Mimi. This commit log looks good. My Ack for the patch
to go through the IMA tree.
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
thanks,
-- Shuah
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox