Re: [PATCH] testsuite fix: timezone: failing due to permissions in cross testing

2019-01-09 Thread Florian Weimer
* Joseph Myers:

> On Tue, 18 Dec 2018, Florian Weimer wrote:
>
>> There are also some xtests that require root privileges, such as
>> nptl/tst-setuid1.  Building and testing as root is supported (but
>
> That looks like it ought to become a test using user namespaces (and so 
> not an xtest).

Can an unprivileged user namespace really be used to get a working
setuid?  The setup code in support_become_root/setup_uid_gid_mapping
does not provide that.

Thanks,
Florian

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 02/14] arc: define syscall_get_arch()

2019-01-09 Thread Dmitry V. Levin
syscall_get_arch() is required to be implemented on all architectures
in addition to already implemented syscall_get_nr(),
syscall_get_arguments(), syscall_get_error(), and
syscall_get_return_value() functions in order to extend the generic
ptrace API with PTRACE_GET_SYSCALL_INFO request.

Acked-by: Vineet Gupta 
Acked-by: Paul Moore 
Cc: Elvira Khabirova 
Cc: Eugene Syromyatnikov 
Cc: Alexey Brodkin 
Cc: Oleg Nesterov 
Cc: Andy Lutomirski 
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-au...@redhat.com
Signed-off-by: Dmitry V. Levin 
---
 arch/arc/include/asm/syscall.h | 11 +++
 include/uapi/linux/audit.h |  4 
 2 files changed, 15 insertions(+)

diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index 29de09804306..c7fc4c0c3bcb 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -9,6 +9,7 @@
 #ifndef _ASM_ARC_SYSCALL_H
 #define _ASM_ARC_SYSCALL_H  1
 
+#include 
 #include 
 #include 
 #include 
@@ -68,4 +69,14 @@ syscall_get_arguments(struct task_struct *task, struct 
pt_regs *regs,
}
 }
 
+static inline int
+syscall_get_arch(void)
+{
+   return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
+   ? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+   ? AUDIT_ARCH_ARCOMPACTBE : AUDIT_ARCH_ARCOMPACT)
+   : (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+   ? AUDIT_ARCH_ARCV2BE : AUDIT_ARCH_ARCV2);
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 36a7e3f18e69..41d8fa80ebad 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -375,6 +375,10 @@ enum {
 
 #define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ALPHA   (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACT   (EM_ARCOMPACT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACTBE (EM_ARCOMPACT)
+#define AUDIT_ARCH_ARCV2   (EM_ARCV2|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCV2BE (EM_ARCV2)
 #define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB   (EM_ARM)
 #define AUDIT_ARCH_CRIS(EM_CRIS|__AUDIT_ARCH_LE)
-- 
ldv

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 01/14] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h

2019-01-09 Thread Dmitry V. Levin
These should never have been defined in the arch tree to begin with, and
now uapi/linux/audit.h header is going to use EM_ARCOMPACT and EM_ARCV2
in order to define AUDIT_ARCH_ARCOMPACT and AUDIT_ARCH_ARCV2 which are
needed to implement syscall_get_arch() which in turn is required to
extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Acked-by: Vineet Gupta 
Acked-by: Paul Moore 
Cc: Elvira Khabirova 
Cc: Eugene Syromyatnikov 
Cc: Alexey Brodkin 
Cc: Oleg Nesterov 
Cc: Andy Lutomirski 
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-au...@redhat.com
Signed-off-by: Dmitry V. Levin 
---
 arch/arc/include/asm/elf.h  | 6 +-
 include/uapi/linux/elf-em.h | 2 ++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
index aa2d6da9d187..2b80c184c9c8 100644
--- a/arch/arc/include/asm/elf.h
+++ b/arch/arc/include/asm/elf.h
@@ -10,13 +10,9 @@
 #define __ASM_ARC_ELF_H
 
 #include 
+#include 
 #include 
 
-/* These ELF defines belong to uapi but libc elf.h already defines them */
-#define EM_ARCOMPACT   93
-
-#define EM_ARCV2   195 /* ARCv2 Cores */
-
 #define EM_ARC_INUSE   (IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \
EM_ARCOMPACT : EM_ARCV2)
 
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 0c3000faedba..081675ed89cb 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -34,6 +34,7 @@
 #define EM_M32R88  /* Renesas M32R */
 #define EM_MN10300 89  /* Panasonic/MEI MN10300, AM33 */
 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
+#define EM_ARCOMPACT   93  /* ARCompact processor */
 #define EM_XTENSA  94  /* Tensilica Xtensa Architecture */
 #define EM_BLACKFIN 106 /* ADI Blackfin Processor */
 #define EM_ALTERA_NIOS2113 /* Altera Nios II soft-core processor */
@@ -42,6 +43,7 @@
 #define EM_TILEPRO 188 /* Tilera TILEPro */
 #define EM_MICROBLAZE  189 /* Xilinx MicroBlaze */
 #define EM_TILEGX  191 /* Tilera TILE-Gx */
+#define EM_ARCV2   195 /* ARCv2 Cores */
 #define EM_RISCV   243 /* RISC-V */
 #define EM_BPF 247 /* Linux BPF - in-kernel virtual machine */
 #define EM_CSKY252 /* C-SKY */
-- 
ldv

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 14/14] syscall_get_arch: add "struct task_struct *" argument

2019-01-09 Thread Dmitry V. Levin
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going
to be called from ptrace_request() along with syscall_get_nr(),
syscall_get_arguments(), syscall_get_error(), and
syscall_get_return_value() functions with a tracee as their argument.

The primary intent is that the triple (audit_arch, syscall_nr, arg1..arg6)
should describe what system call is being called and what its arguments
are.

Reverts: 5e937a9ae913 ("syscall_get_arch: remove useless function arguments")
Reverts: 1002d94d3076 ("syscall.h: fix doc text for syscall_get_arch()")
Reviewed-by: Andy Lutomirski  # for x86
Reviewed-by: Palmer Dabbelt 
Acked-by: Paul Moore 
Acked-by: Paul Burton  # MIPS parts
Acked-by: Michael Ellerman  (powerpc)
Acked-by: Kees Cook  # seccomp parts
Acked-by: Mark Salter  # for the c6x bit
Cc: Elvira Khabirova 
Cc: Eugene Syromyatnikov 
Cc: Oleg Nesterov 
Cc: x...@kernel.org
Cc: linux-al...@vger.kernel.org
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-c6x-...@linux-c6x.org
Cc: uclinux-h8-de...@lists.sourceforge.jp
Cc: linux-hexa...@vger.kernel.org
Cc: linux-i...@vger.kernel.org
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-m...@vger.kernel.org
Cc: nios2-...@lists.rocketboards.org
Cc: openr...@lists.librecores.org
Cc: linux-par...@vger.kernel.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-ri...@lists.infradead.org
Cc: linux-s...@vger.kernel.org
Cc: linux...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: linux...@lists.infradead.org
Cc: linux-xte...@linux-xtensa.org
Cc: linux-a...@vger.kernel.org
Cc: linux-au...@redhat.com
Signed-off-by: Dmitry V. Levin 
---
 arch/alpha/include/asm/syscall.h  |  2 +-
 arch/arc/include/asm/syscall.h|  2 +-
 arch/arm/include/asm/syscall.h|  2 +-
 arch/arm64/include/asm/syscall.h  |  4 ++--
 arch/c6x/include/asm/syscall.h|  2 +-
 arch/csky/include/asm/syscall.h   |  2 +-
 arch/h8300/include/asm/syscall.h  |  2 +-
 arch/hexagon/include/asm/syscall.h|  2 +-
 arch/ia64/include/asm/syscall.h   |  2 +-
 arch/m68k/include/asm/syscall.h   |  2 +-
 arch/microblaze/include/asm/syscall.h |  2 +-
 arch/mips/include/asm/syscall.h   |  6 +++---
 arch/mips/kernel/ptrace.c |  2 +-
 arch/nds32/include/asm/syscall.h  |  2 +-
 arch/nios2/include/asm/syscall.h  |  2 +-
 arch/openrisc/include/asm/syscall.h   |  2 +-
 arch/parisc/include/asm/syscall.h |  4 ++--
 arch/powerpc/include/asm/syscall.h| 10 --
 arch/riscv/include/asm/syscall.h  |  2 +-
 arch/s390/include/asm/syscall.h   |  4 ++--
 arch/sh/include/asm/syscall_32.h  |  2 +-
 arch/sh/include/asm/syscall_64.h  |  2 +-
 arch/sparc/include/asm/syscall.h  |  5 +++--
 arch/unicore32/include/asm/syscall.h  |  2 +-
 arch/x86/include/asm/syscall.h|  8 +---
 arch/x86/um/asm/syscall.h |  2 +-
 arch/xtensa/include/asm/syscall.h |  2 +-
 include/asm-generic/syscall.h |  5 +++--
 kernel/auditsc.c  |  4 ++--
 kernel/seccomp.c  |  4 ++--
 30 files changed, 52 insertions(+), 42 deletions(-)

diff --git a/arch/alpha/include/asm/syscall.h b/arch/alpha/include/asm/syscall.h
index d73a6fcb519c..11c688c1d7ec 100644
--- a/arch/alpha/include/asm/syscall.h
+++ b/arch/alpha/include/asm/syscall.h
@@ -4,7 +4,7 @@
 
 #include 
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
return AUDIT_ARCH_ALPHA;
 }
diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index c7fc4c0c3bcb..caf2697ef5b7 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -70,7 +70,7 @@ syscall_get_arguments(struct task_struct *task, struct 
pt_regs *regs,
 }
 
 static inline int
-syscall_get_arch(void)
+syscall_get_arch(struct task_struct *task)
 {
return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
index 06dea6bce293..3940ceac0bdc 100644
--- a/arch/arm/include/asm/syscall.h
+++ b/arch/arm/include/asm/syscall.h
@@ -104,7 +104,7 @@ static inline void syscall_set_arguments(struct task_struct 
*task,
memcpy(®s->ARM_r0 + i, args, n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
/* ARM tasks don't change audit architectures on the fly. */
return AUDIT_ARCH_ARM;
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index ad8be16a39c9..1870df03f774 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -117,9 +117,9 @@ static inline void syscall_set_arguments(struct task_struct 
*task,
  * We don't care about endianness (__AUDIT_ARCH_LE bit) here because
  * AArch64 has the same system calls both on little- and

Re: [PATCH] ARC: show detaled ActionPoint configuration in mumbojumbo

2019-01-09 Thread Vineet Gupta
On 12/28/18 8:44 AM, Eugeniy Paltsev wrote:
> Add information about ActionPointis number and supported set
> of targets (minimum / full).
> 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  arch/arc/include/asm/arcregs.h |  8 +++
>  arch/arc/kernel/setup.c| 53 
> ++
>  2 files changed, 56 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
> index 49bfbd879caa..aa673e27add5 100644
> --- a/arch/arc/include/asm/arcregs.h
> +++ b/arch/arc/include/asm/arcregs.h
> @@ -216,6 +216,14 @@ struct bcr_fp_arcv2 {
>  #endif
>  };
>  


> +
>  #include 
>  
>  struct bcr_bpu_arcompact {
> diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
> index b2cae79a25d7..c8d67f9cd40d 100644
> --- a/arch/arc/kernel/setup.c
> +++ b/arch/arc/kernel/setup.c
> @@ -115,6 +115,47 @@ static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu)
>   }
>  }
>  
> +static bool actionpoints_exists(void)
> +{
> + struct bcr_actionpoint bcr;
> +
> + READ_BCR(ARC_REG_AP_BCR, bcr);
> + return !!bcr.ver;
> +}

Lets try to follow the existing coding convention of this file. I don't see much
value of this helper.

> +
> +static const char *actionpoints_configuration(void)
> +{
> + struct bcr_actionpoint bcr;
> +
> + READ_BCR(ARC_REG_AP_BCR, bcr);
> + switch (bcr.type) {
> + case 0x0:
> + return "2, full";
> + case 0x1:
> + return "4, full";
> + case 0x2:
> + return "8, full";
> + case 0x4:
> + return "2, minimum";
> + case 0x5:
> + return "4, minimum";
> + case 0x6:
> + return "8, minimum";
> +
> + default:
> + return "unknown";
> + }

This might sound pedantic, but this is adding 8 unique string to rodata. Again
following the convention we could fine grain the bcr into 2 bitfields: full, num
etc. And decode them just as we do for mmu/cache bcrs.

> +}
> +
> +static int actionpoints_mumbojumbo(char *buf, int len)
> +{
> + if (!actionpoints_exists())
> + return 0;
> +
> + return scnprintf(buf, len, "ActionPoint (%s set)",
> +  actionpoints_configuration());
> +}
> +
>  static void read_arc_build_cfg_regs(void)
>  {
>   struct bcr_timer timer;
> @@ -206,8 +247,7 @@ static void read_arc_build_cfg_regs(void)
>   }
>   }
>  
> - READ_BCR(ARC_REG_AP_BCR, bcr);
> - cpu->extn.ap = bcr.ver ? 1 : 0;
> + cpu->extn.ap = actionpoints_exists();
>  
>   READ_BCR(ARC_REG_SMART_BCR, bcr);
>   cpu->extn.smart = bcr.ver ? 1 : 0;
> @@ -332,12 +372,15 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, 
> int len)
>  IS_AVAIL1(cpu->extn.fpu_sp, "SP "),
>  IS_AVAIL1(cpu->extn.fpu_dp, "DP "));
>  
> - if (cpu->extn.debug)
> - n += scnprintf(buf + n, len - n, "DEBUG\t\t: %s%s%s\n",
> -IS_AVAIL1(cpu->extn.ap, "ActionPoint "),
> + if (cpu->extn.debug) {
> + n += scnprintf(buf + n, len - n, "DEBUG\t\t: %s%s",
>  IS_AVAIL1(cpu->extn.smart, "smaRT "),
>  IS_AVAIL1(cpu->extn.rtt, "RTT "));
>  
> + n += actionpoints_mumbojumbo(buf + n, len - n);
> + n += scnprintf(buf + n, len - n, "\n");
> + }
> +
>   if (cpu->dccm.sz || cpu->iccm.sz)
>   n += scnprintf(buf + n, len - n, "Extn [CCM]\t: DCCM @ %x, %d 
> KB / ICCM: @ %x, %d KB\n",
>  cpu->dccm.base_addr, TO_KB(cpu->dccm.sz),
> 

How does below look like ?

->
diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h
index 9f10d32ee1bd..f1b86cef0905 100644
--- a/arch/arc/include/asm/arcregs.h
+++ b/arch/arc/include/asm/arcregs.h
@@ -216,6 +216,14 @@ struct bcr_fp_arcv2 {
 #endif
 };

+struct bcr_actionpoint {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+   unsigned int pad:21, min:1, num:2, ver:8;
+#else
+   unsigned int ver:8, num:2, min:1, pad:21;
+#endif
+};
+
 #include 

 struct bcr_bpu_arcompact {
@@ -302,7 +310,7 @@ struct cpuinfo_arc {
struct {
unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, 
swape:1, pad1:2,
 fpu_sp:1, fpu_dp:1, dual:1, dual_enb:1, pad2:4,
-debug:1, ap:1, smart:1, rtt:1, pad3:4,
+ap_num:4, ap_full:1, smart:1, rtt:1, pad3:1,
 timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
} extn;
struct bcr_mpy extn_mpy;
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index 926e1bc1cd7f..b4c1db2811af 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -122,6 +122,7 @@ static void read_arc_build_cfg_regs(void)
struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
const struct id_to_str *tbl;
struct bcr_isa_

Re: [PATCH] ARC: show detaled ActionPoint configuration in mumbojumbo

2019-01-09 Thread Vineet Gupta
On 1/9/19 9:35 AM, Vineet Gupta wrote:
> + cpu->extn.ap_full = !ap.min;

This needs to be

 +  cpu->extn.ap_full = !!ap.min;

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

2019-01-09 Thread Vineet Gupta
On 12/21/18 4:05 AM, Adhemerval Zanella wrote:
>> Thing is ARC signal return depends on a restorer. Meaning !SA_RESTORER 
>> doesn't
>> effectively exist (between libc and kernel). We currently honor user provided
>> value, instead we could simply overwrite it with default_rt_restorer and on 
>> the
>> way out, zero it out to avoid leaking the glibc guts to curious users.
>>
> Yes, this is what I suggest ARC should do.

So I was able to

(1) switch ARC to __sigset_t [2] vs. [128]

(2) create a generic patch to breakout struct sigaction into 
bits/sigaction-arch.h
(3) update generic __libc_sigaction to avoid itemized copy if sa_mask, sa_flags 
et
al offsets matched for struct kernel_signal and struct sigaction
(4) create arc/bits/sigaction-arch.h

However it turned out to be futile as the passthru won't work anyways :-(
@act in sigaction(sig, act, oact) is a const and can't be modified in place for
sticking in sa_restorer for kernel, thus needs to be copied over anyways.

This means we have [1] but have to drop [2-4]. Oh well !

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc