In PCuABI, we need compat_ptr() to create a valid capability from an
arbitrary compat pointer, to enable uaccess to the underlying
memory. However, if the compat pointer is clearly an invalid
address, it is preferable to return a null-derived (invalid)
capability. This is especially true when the address is null: we
clearly want to return the null capability in that case.
This should be a non-functional change (uaccess would fail anyway
due to the absence of underlying mapping), but it avoids some
confusion when debugging compat64 handling (and reduces the creation
of capabilities).
Signed-off-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
---
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/null_c…
arch/arm64/include/asm/compat.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h
index 4556bed1704f..acf5487985b5 100644
--- a/arch/arm64/include/asm/compat.h
+++ b/arch/arm64/include/asm/compat.h
@@ -93,7 +93,9 @@ static inline void __user *compat_ptr(compat_uptr_t uptr)
* TODO [Morello] - this should be done using the current user DDC, not
* the root user capability.
*/
- return (void __user *)cheri_address_set(cheri_user_root_allperms_cap, uptr);
+ return likely(uptr >= PAGE_SIZE && uptr < TASK_SIZE_MAX) ?
+ (void __user *)cheri_address_set(cheri_user_root_allperms_cap, uptr) :
+ as_user_ptr(uptr);
}
#define compat_ptr(uptr) compat_ptr(uptr)
#endif
--
2.43.0
Hi,
This is a small series adding various firmware-related options to the
Morello defconfig. These options work out of the box in PCuABI (no
build or runtime issue).
Patch 1 is useful to inspect the EFI configuration on a live system, and
is used by tools like bootctl (systemd-boot).
Patch 2 enables the DPU to be successfully probed when using the
firmware-provided device tree (part of upstream TF-A), as it relies on
the DPU clock being provided by SCMI. This should be useful for
controlling other functionalities as well (e.g. power management).
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/defcon…
Thanks,
Kevin
Kevin Brodsky (2):
arm64: morello: Enable EFIVAR_FS in defconfig
arm64: morello: Enable SCMI in defconfig
arch/arm64/configs/morello_transitional_pcuabi_defconfig | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--
2.43.0
These definitions were needed to build arch/arm64/kernel/ptrace.c
with CONFIG_COMPAT64 a long time ago, before "arm64: ptrace: Support
compat64". This is not the case any more, however since
"fs/compat_binfmt_elf: Align compat64 with compat32" we do need to
define compat_elf_gregset_t to keep linux/elfcore-compat.h happy.
This is the correct approach and there is no plan to change it, so
let's remove the outdated TODO.
Signed-off-by: Kevin Brodsky <kevin.brodsky(a)arm.com>
---
arch/arm64/include/asm/elf.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index b54070e80867..63f6f50599e6 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -209,11 +209,6 @@ extern int purecap_setup_additional_pages(struct linux_binprm *bprm,
#define compat_elf_check_arch(x) ((x)->e_machine == EM_AARCH64 && \
!((x)->e_flags & EF_AARCH64_CHERI_PURECAP))
-/*
- * TODO [PCuABI]: Redefine below macros and typedefs to let ptrace pick them
- * and build. These redefinitions are not permanent and might not be required if
- * the ptrace is modified for complete COMPAT64 support.
- */
#define COMPAT_ELF_NGREG ELF_NGREG
typedef unsigned long compat_elf_greg_t;
typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
--
2.43.0
Hi,
This small series aligns the kernel with the latest release of Morello
Clang (1.7). Patch 1 removes a warning when building kselftests, while
patch 2 simplifies pieces of inline assembly that are not specific to
PCuABI, by making use of a relaxation in asm constraints.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello%2Flate…
Thanks,
Kevin
Kevin Brodsky (2):
kselftests/arm64: morello: Drop +c64 from -march
arm64: Switch to standard asm constraints for capabilities
arch/arm64/include/asm/futex.h | 23 ++++++++-----------
arch/arm64/include/asm/uaccess.h | 14 ++++-------
arch/arm64/include/asm/vdso/gettimeofday.h | 15 ++++--------
.../testing/selftests/arm64/morello/Makefile | 2 +-
4 files changed, 18 insertions(+), 36 deletions(-)
--
2.43.0
Hi,
This series of patches enables the use of the Wireguard VPN and all
assocaited tools required for running wireguard-tools' test script.
Wireguard's test script (netns.sh) runs to completion using purecap compiled:
wireguard-tools, iproute2, iputils (ping/ping6), iptables, nftables,
libnftnl, libmnl, libelf, argp-standalone, musl-obstack, fts,
libjansson.
Packages used in netns.sh currently not tested in purecap:
ncat, iperf3.
The bulk of the changes required are additions to the kernel config,
with a fix for a bug found in iptables.
There is an alignment issue at the user/kernel boundary in xtables with
capabilities, encountered in the macro XT_ALIGN, used in the function
xt_check_target (with the resulting message indicating size of
(kernel) and (user) not matching). This bug occurs when running certain
iptables commands in the test script. e.g.
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -d 10.0.0.0/24 -j SNAT
--to 10.0.0.1
This is my first patch to the kernel so please forgive me if anything
is drastically wrong. I have tried to follow the format of others on here...
Cheers,
Joshua Lant
Joshua Lant (2):
morello: enable wireguard kernel config
xtables: fix alignment issue
.../morello_transitional_pcuabi_defconfig | 23 +++++++++++++++++++
include/uapi/linux/netfilter/x_tables.h | 1 +
2 files changed, 24 insertions(+)
--
2.25.1
A previous patch which introduced support for capabilities in the
MMC_IOC_{MULTI_}CMD ioctls also hard-coded the ioctl values to
maintain compatibility with non-PCuABI ioctl handlers such as those
found in block.c.
This patch therefore removes the hard-coding of these ioctl values,
and enforces compatibility by accounting for the change in values
if the ioctl handler is running in compat64.
Signed-off-by: Akram Ahmad <Akram.Ahmad(a)arm.com>
---
drivers/mmc/core/block.c | 21 +++++++++++++++++++++
include/uapi/linux/mmc/ioctl.h | 21 +++++++++------------
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 17a1d24bdaed..acb7f3a9b31a 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -76,6 +76,15 @@ MODULE_ALIAS("mmc:block");
#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8)
+/*
+ * The compat_mmc_ioc_{multi_}cmd structs have different sizes in PCuABI and in
+ * compat64, which affects the expected MMC_IOC_{MULTI_}CMD ioctl values. The
+ * following ioctl values reflect the sizes of the compat64 structs defined in
+ * this file.
+ */
+#define COMPAT64_MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct compat_mmc_ioc_cmd)
+#define COMPAT64_MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct compat_mmc_ioc_multi_cmd)
+
static DEFINE_MUTEX(block_mutex);
/*
@@ -858,6 +867,9 @@ static int mmc_blk_ioctl(struct block_device *bdev, blk_mode_t mode,
int ret;
switch (cmd) {
+ case COMPAT64_MMC_IOC_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_CMD:
ret = mmc_blk_check_blkdev(bdev);
if (ret)
@@ -870,6 +882,9 @@ static int mmc_blk_ioctl(struct block_device *bdev, blk_mode_t mode,
NULL);
mmc_blk_put(md);
return ret;
+ case COMPAT64_MMC_IOC_MULTI_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_MULTI_CMD:
ret = mmc_blk_check_blkdev(bdev);
if (ret)
@@ -2678,11 +2693,17 @@ static long mmc_rpmb_ioctl(struct file *filp, unsigned int cmd,
int ret;
switch (cmd) {
+ case COMPAT64_MMC_IOC_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_CMD:
ret = mmc_blk_ioctl_cmd(rpmb->md,
(struct mmc_ioc_cmd __user *)arg,
rpmb);
break;
+ case COMPAT64_MMC_IOC_MULTI_CMD:
+ if (!in_compat64_syscall())
+ return -EINVAL;
case MMC_IOC_MULTI_CMD:
ret = mmc_blk_ioctl_multi_cmd(rpmb->md,
(struct mmc_ioc_multi_cmd __user *)arg,
diff --git a/include/uapi/linux/mmc/ioctl.h b/include/uapi/linux/mmc/ioctl.h
index 9d34bfc49198..e99d932268c6 100644
--- a/include/uapi/linux/mmc/ioctl.h
+++ b/include/uapi/linux/mmc/ioctl.h
@@ -67,26 +67,23 @@ struct mmc_ioc_multi_cmd {
/*
* The size of struct mmc_ioc_cmd changes in PCuABI due to the use of
* __kernel_uintptr_t, which in turn modifies the command value for this
- * ioctl. It is therefore necessary to hard-code the value for the ioctl
- * using the size of the struct that is expected in any ABI other than
- * PCuABI, to ensure that the value for MMC_IOC_CMD is unchanged. The
- * original definition is as follows:
- *
- * #define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
+ * ioctl. As this command value is not hard-coded to represent the original
+ * size of the struct, any ioctl handlers in compat64 must handle this change
+ * in values instead.
*/
-#define MMC_IOC_CMD _IOC(_IOC_READ|_IOC_WRITE, MMC_BLOCK_MAJOR, 0, 72)
+#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
+
/*
* MMC_IOC_MULTI_CMD: Used to send an array of MMC commands described by
* the structure mmc_ioc_multi_cmd. The MMC driver will issue all
* commands in array in sequence to card.
*
* Note: the size of struct mmc_ioc_multi_cmd changes in PCuABI, due to the
- * increased alignment of struct mmc_ioc_cmd. For that reason, its value needs
- * to be hard-coded too. Original definition:
- *
- * #define MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct mmc_ioc_multi_cmd)
+ * increased alignment of struct mmc_ioc_cmd. Similarly to MMC_IOC_CMD, any
+ * ioctl handlers must account for this change when running in compat64.
*/
-#define MMC_IOC_MULTI_CMD _IOC(_IOC_READ|_IOC_WRITE, MMC_BLOCK_MAJOR, 1, 8)
+#define MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct mmc_ioc_multi_cmd)
+
/*
* Since this ioctl is only meant to enhance (and not replace) normal access
* to the mmc bus device, an upper data transfer limit of MMC_IOC_MAX_BYTES
--
2.34.1