From: catalin.marinas at arm.com (Catalin Marinas) Subject: [PATCH v2 2/4] arm64: Define Documentation/arm64/elf_at_flags.txt Date: Fri, 22 Mar 2019 10:48:40 +0000 [thread overview] Message-ID: <20190322104839.GA13384@arrakis.emea.arm.com> (raw) In-Reply-To: <CADGdYn7HYcj4vxw2bCS6McdNRmWu7o13=VAQra5A1Z18JNPMXQ@mail.gmail.com> On Fri, Mar 22, 2019 at 11:52:37AM +0530, Amit Daniel Kachhap wrote: > On Mon, Mar 18, 2019 at 10:06 PM Vincenzo Frascino > <vincenzo.frascino at arm.com> wrote: > > +Example of correct usage (pseudo-code) for a userspace application: > > + > > +bool arm64_syscall_tbi_is_present(void) > > +{ > > + unsigned long at_flags = getauxval(AT_FLAGS); > > + if (at_flags & ARM64_AT_FLAGS_SYSCALL_TBI) > > + return true; > > + > > + return false; > > +} > > + > > +void main(void) > > +{ > > + char *addr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, > > + MAP_ANONYMOUS, -1, 0); > > + > > + int fd = open("test.txt", O_WRONLY); > > + > > + /* Check if the relaxed ABI is supported */ > > + if (arm64_syscall_tbi_is_present()) { > > + /* Add a tag to the pointer */ > > + addr = tag_pointer(addr); > > + } > > + > > + strcpy("Hello World\n", addr); > > Nit: s/strcpy("Hello World\n", addr)/strcpy(addr, "Hello World\n") Not exactly a nit ;). > > + > > + /* Write to a file */ > > + write(fd, addr, sizeof(addr)); I presume this was supposed to write "Hello World\n" to a file but sizeof(addr) is 1. Since we already support tagged pointers in user space (as long as they are not passed into the kernel), the above example could tag the pointer unconditionally and only clear it before write() if !arm64_syscall_tbi_is_present(). -- Catalin
WARNING: multiple messages have this Message-ID (diff)
From: catalin.marinas@arm.com (Catalin Marinas) Subject: [PATCH v2 2/4] arm64: Define Documentation/arm64/elf_at_flags.txt Date: Fri, 22 Mar 2019 10:48:40 +0000 [thread overview] Message-ID: <20190322104839.GA13384@arrakis.emea.arm.com> (raw) Message-ID: <20190322104840.FNnHHO34asmHFjkZiD25m-xio65adaXVpjxrmUpSBqc@z> (raw) In-Reply-To: <CADGdYn7HYcj4vxw2bCS6McdNRmWu7o13=VAQra5A1Z18JNPMXQ@mail.gmail.com> On Fri, Mar 22, 2019@11:52:37AM +0530, Amit Daniel Kachhap wrote: > On Mon, Mar 18, 2019 at 10:06 PM Vincenzo Frascino > <vincenzo.frascino@arm.com> wrote: > > +Example of correct usage (pseudo-code) for a userspace application: > > + > > +bool arm64_syscall_tbi_is_present(void) > > +{ > > + unsigned long at_flags = getauxval(AT_FLAGS); > > + if (at_flags & ARM64_AT_FLAGS_SYSCALL_TBI) > > + return true; > > + > > + return false; > > +} > > + > > +void main(void) > > +{ > > + char *addr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, > > + MAP_ANONYMOUS, -1, 0); > > + > > + int fd = open("test.txt", O_WRONLY); > > + > > + /* Check if the relaxed ABI is supported */ > > + if (arm64_syscall_tbi_is_present()) { > > + /* Add a tag to the pointer */ > > + addr = tag_pointer(addr); > > + } > > + > > + strcpy("Hello World\n", addr); > > Nit: s/strcpy("Hello World\n", addr)/strcpy(addr, "Hello World\n") Not exactly a nit ;). > > + > > + /* Write to a file */ > > + write(fd, addr, sizeof(addr)); I presume this was supposed to write "Hello World\n" to a file but sizeof(addr) is 1. Since we already support tagged pointers in user space (as long as they are not passed into the kernel), the above example could tag the pointer unconditionally and only clear it before write() if !arm64_syscall_tbi_is_present(). -- Catalin
next prev parent reply other threads:[~2019-03-22 10:48 UTC|newest] Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-15 19:51 [PATCH v11 00/14] arm64: untag user pointers passed to the kernel andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 01/14] uaccess: add untagged_addr definition for other arches andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 02/14] arm64: untag user pointers in access_ok and __uaccess_mask_ptr andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 03/14] lib, arm64: untag user pointers in strn*_user andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-18 11:33 ` kevin.brodsky 2019-03-18 11:33 ` Kevin Brodsky 2019-03-15 19:51 ` [PATCH v11 04/14] mm, arm64: untag user pointers passed to memory syscalls andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 05/14] mm, arm64: untag user pointers in mm/gup.c andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 06/14] fs, arm64: untag user pointers in copy_mount_options andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 07/14] fs, arm64: untag user pointers in fs/userfaultfd.c andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 08/14] net, arm64: untag user pointers in tcp_zerocopy_receive andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 20:03 ` eric.dumazet 2019-03-15 20:03 ` Eric Dumazet 2019-03-18 13:14 ` andreyknvl 2019-03-18 13:14 ` Andrey Konovalov 2019-03-18 13:16 ` andreyknvl 2019-03-18 13:16 ` Andrey Konovalov 2019-03-18 14:44 ` edumazet 2019-03-18 14:44 ` Eric Dumazet 2019-03-18 16:08 ` andreyknvl 2019-03-18 16:08 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 09/14] kernel, arm64: untag user pointers in prctl_set_mm* andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-18 11:47 ` kevin.brodsky 2019-03-18 11:47 ` Kevin Brodsky 2019-03-18 16:53 ` andreyknvl 2019-03-18 16:53 ` Andrey Konovalov [not found] ` <201903170317.IWsOYXBe%lkp@intel.com> 2019-03-18 16:53 ` andreyknvl 2019-03-18 16:53 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 10/14] tracing, arm64: untag user pointers in seq_print_user_ip andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 20:14 ` rostedt 2019-03-15 20:14 ` Steven Rostedt 2019-03-18 13:11 ` andreyknvl 2019-03-18 13:11 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 11/14] uprobes, arm64: untag user pointers in find_active_uprobe andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 12/14] bpf, arm64: untag user pointers in stack_map_get_build_id_offset andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 13/14] arm64: update Documentation/arm64/tagged-pointers.txt andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-18 13:26 ` kevin.brodsky 2019-03-18 13:26 ` Kevin Brodsky 2019-03-18 16:59 ` andreyknvl 2019-03-18 16:59 ` Andrey Konovalov 2019-03-15 19:51 ` [PATCH v11 14/14] selftests, arm64: add a selftest for passing tagged pointers to kernel andreyknvl 2019-03-15 19:51 ` Andrey Konovalov 2019-03-18 16:35 ` [PATCH v2 0/4] arm64 relaxed ABI vincenzo.frascino 2019-03-18 16:35 ` Vincenzo Frascino 2019-03-18 16:35 ` [PATCH v2 1/4] elf: Make AT_FLAGS arch configurable vincenzo.frascino 2019-03-18 16:35 ` Vincenzo Frascino 2019-03-18 16:35 ` [PATCH v2 2/4] arm64: Define Documentation/arm64/elf_at_flags.txt vincenzo.frascino 2019-03-18 16:35 ` Vincenzo Frascino 2019-03-22 6:22 ` amit.kachhap 2019-03-22 6:22 ` Amit Daniel Kachhap 2019-03-22 10:48 ` catalin.marinas [this message] 2019-03-22 10:48 ` Catalin Marinas 2019-03-22 15:52 ` kevin.brodsky 2019-03-22 15:52 ` Kevin Brodsky 2019-04-03 16:50 ` catalin.marinas 2019-04-03 16:50 ` Catalin Marinas 2019-04-12 14:16 ` kevin.brodsky 2019-04-12 14:16 ` Kevin Brodsky 2019-03-18 16:35 ` [PATCH v2 3/4] arm64: Relax Documentation/arm64/tagged-pointers.txt vincenzo.frascino 2019-03-18 16:35 ` Vincenzo Frascino 2019-03-18 16:35 ` [PATCH v2 4/4] arm64: elf: Advertise relaxed ABI vincenzo.frascino 2019-03-18 16:35 ` Vincenzo Frascino
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190322104839.GA13384@arrakis.emea.arm.com \ --to=linux-kselftest@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).