diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-06-28 17:55:01 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-06-28 17:55:01 +0200 |
commit | 8f9782e63481c4cd643285158e560949954341e7 (patch) | |
tree | 29b210e2abe3fec9fb00ccefaaefffd4911a0183 | |
parent | 6c6a0147ce8ee79ce8176b076f7e6eb512989982 (diff) | |
download | patches-8f9782e63481c4cd643285158e560949954341e7.tar.gz |
updates
-rw-r--r-- | 0001-Revert-zram-convert-remaining-CLASS_ATTR-to-CLASS_AT.patch | 30 | ||||
-rw-r--r-- | 0001-readfile-implement-readfile-syscall.patch | 13 | ||||
-rw-r--r-- | 0002-arch-wire-up-the-readfile-syscall.patch | 89 | ||||
-rw-r--r-- | 0003-selftests-add-readfile-2-selftests.patch | 31 | ||||
-rw-r--r-- | 0004-readfile.2.patch | 242 | ||||
-rw-r--r-- | series | 2 |
6 files changed, 308 insertions, 99 deletions
diff --git a/0001-Revert-zram-convert-remaining-CLASS_ATTR-to-CLASS_AT.patch b/0001-Revert-zram-convert-remaining-CLASS_ATTR-to-CLASS_AT.patch new file mode 100644 index 00000000000000..585456a140ae54 --- /dev/null +++ b/0001-Revert-zram-convert-remaining-CLASS_ATTR-to-CLASS_AT.patch @@ -0,0 +1,30 @@ +From dc2440d69ee81aff9c56ec8ded0fd37b7b344130 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Wed, 17 Jun 2020 12:28:23 +0200 +Subject: [PATCH] Revert "zram: convert remaining CLASS_ATTR() to + CLASS_ATTR_RO()" + +Turns out that the permissions for 0400 really are what we want here, +otherwise any user can write to this file. + +Reported-by: Wade Mealing <wmealing@redhat.com> +Cc: stable <stable@vger.kernel.org> +Fixes: f40609d1591f ("zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()") +Link: https://bugzilla.redhat.com/show_bug.cgi?id=1847832 +Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +--- + drivers/block/zram/zram_drv.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/block/zram/zram_drv.c ++++ b/drivers/block/zram/zram_drv.c +@@ -2021,7 +2021,8 @@ static ssize_t hot_add_show(struct class + return ret; + return scnprintf(buf, PAGE_SIZE, "%d\n", ret); + } +-static CLASS_ATTR_RO(hot_add); ++static struct class_attribute class_attr_hot_add = ++ __ATTR(hot_add, 0400, hot_add_show, NULL); + + static ssize_t hot_remove_store(struct class *class, + struct class_attribute *attr, diff --git a/0001-readfile-implement-readfile-syscall.patch b/0001-readfile-implement-readfile-syscall.patch index 1393312d340858..0e0e0653b1ec33 100644 --- a/0001-readfile-implement-readfile-syscall.patch +++ b/0001-readfile-implement-readfile-syscall.patch @@ -1,7 +1,7 @@ -From 64793c95677d62753de4db132b0c85adab7aa9ab Mon Sep 17 00:00:00 2001 +From 654540d453a03efc0fe7fc0e0d155981051b10c4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Date: Sun, 24 May 2020 12:37:15 +0200 -Subject: [PATCH 1/3] readfile: implement readfile syscall +Subject: [PATCH 1/4] readfile: implement readfile syscall It's a tiny syscall, meant to allow a user to do a single "open this file, read into this buffer, and close the file" all in a single shot. @@ -15,14 +15,12 @@ overhead. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- - fs/open.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + fs/open.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) -diff --git a/fs/open.c b/fs/open.c -index 6cd48a61cda3..9ec18cddee18 100644 --- a/fs/open.c +++ b/fs/open.c -@@ -1370,3 +1370,53 @@ int stream_open(struct inode *inode, struct file *filp) +@@ -1370,3 +1370,53 @@ int stream_open(struct inode *inode, str } EXPORT_SYMBOL(stream_open); @@ -76,6 +74,3 @@ index 6cd48a61cda3..9ec18cddee18 100644 + + return retval; +} --- -2.27.0 - diff --git a/0002-arch-wire-up-the-readfile-syscall.patch b/0002-arch-wire-up-the-readfile-syscall.patch index 34e76f3e4c134a..027af3452083ed 100644 --- a/0002-arch-wire-up-the-readfile-syscall.patch +++ b/0002-arch-wire-up-the-readfile-syscall.patch @@ -1,36 +1,34 @@ -From ef5dc99f43ca5c982c124ff6ac7acf0c1151d5bf Mon Sep 17 00:00:00 2001 +From 4135ebc2076a72c3ad10d0102e8ebc82140abf8d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Date: Sun, 24 May 2020 12:36:21 +0200 -Subject: [PATCH 2/3] arch: wire up the readfile syscall +Subject: [PATCH 2/4] arch: wire up the readfile syscall This wires up the readfile syscall for all architectures Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- - arch/alpha/kernel/syscalls/syscall.tbl | 1 + - arch/arm/tools/syscall.tbl | 1 + - arch/arm64/include/asm/unistd.h | 2 +- - arch/arm64/include/asm/unistd32.h | 2 ++ - arch/ia64/kernel/syscalls/syscall.tbl | 1 + - arch/m68k/kernel/syscalls/syscall.tbl | 1 + - arch/microblaze/kernel/syscalls/syscall.tbl | 1 + - arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + - arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + - arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + - arch/parisc/kernel/syscalls/syscall.tbl | 1 + - arch/powerpc/kernel/syscalls/syscall.tbl | 1 + - arch/s390/kernel/syscalls/syscall.tbl | 1 + - arch/sh/kernel/syscalls/syscall.tbl | 1 + - arch/sparc/kernel/syscalls/syscall.tbl | 1 + - arch/x86/entry/syscalls/syscall_32.tbl | 1 + - arch/x86/entry/syscalls/syscall_64.tbl | 1 + - arch/xtensa/kernel/syscalls/syscall.tbl | 1 + - include/linux/syscalls.h | 2 ++ - include/uapi/asm-generic/unistd.h | 4 +++- + arch/alpha/kernel/syscalls/syscall.tbl | 1 + + arch/arm/tools/syscall.tbl | 1 + + arch/arm64/include/asm/unistd.h | 2 +- + arch/arm64/include/asm/unistd32.h | 2 ++ + arch/ia64/kernel/syscalls/syscall.tbl | 1 + + arch/m68k/kernel/syscalls/syscall.tbl | 1 + + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + + arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + + arch/parisc/kernel/syscalls/syscall.tbl | 1 + + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + + arch/s390/kernel/syscalls/syscall.tbl | 1 + + arch/sh/kernel/syscalls/syscall.tbl | 1 + + arch/sparc/kernel/syscalls/syscall.tbl | 1 + + arch/x86/entry/syscalls/syscall_32.tbl | 1 + + arch/x86/entry/syscalls/syscall_64.tbl | 1 + + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + + include/linux/syscalls.h | 2 ++ + include/uapi/asm-generic/unistd.h | 4 +++- 20 files changed, 24 insertions(+), 2 deletions(-) -diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl -index 5ddd128d4b7a..4132380e997f 100644 --- a/arch/alpha/kernel/syscalls/syscall.tbl +++ b/arch/alpha/kernel/syscalls/syscall.tbl @@ -478,3 +478,4 @@ @@ -38,8 +36,6 @@ index 5ddd128d4b7a..4132380e997f 100644 548 common pidfd_getfd sys_pidfd_getfd 549 common faccessat2 sys_faccessat2 +550 common readfile sys_readfile -diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl -index d5cae5ffede0..454873892ba3 100644 --- a/arch/arm/tools/syscall.tbl +++ b/arch/arm/tools/syscall.tbl @@ -452,3 +452,4 @@ @@ -47,8 +43,6 @@ index d5cae5ffede0..454873892ba3 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h -index 3b859596840d..b3b2019f8d16 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -38,7 +38,7 @@ @@ -60,8 +54,6 @@ index 3b859596840d..b3b2019f8d16 100644 #endif #define __ARCH_WANT_SYS_CLONE -diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h -index 6d95d0c8bf2f..524d19779612 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -885,6 +885,8 @@ __SYSCALL(__NR_openat2, sys_openat2) @@ -73,8 +65,6 @@ index 6d95d0c8bf2f..524d19779612 100644 /* * Please add new compat syscalls above this comment and update -diff --git a/arch/ia64/kernel/syscalls/syscall.tbl b/arch/ia64/kernel/syscalls/syscall.tbl -index 49e325b604b3..b188f03736bb 100644 --- a/arch/ia64/kernel/syscalls/syscall.tbl +++ b/arch/ia64/kernel/syscalls/syscall.tbl @@ -359,3 +359,4 @@ @@ -82,8 +72,6 @@ index 49e325b604b3..b188f03736bb 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl -index f71b1bbcc198..ab24bcb91344 100644 --- a/arch/m68k/kernel/syscalls/syscall.tbl +++ b/arch/m68k/kernel/syscalls/syscall.tbl @@ -438,3 +438,4 @@ @@ -91,8 +79,6 @@ index f71b1bbcc198..ab24bcb91344 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl -index edacc4561f2b..46c06f800e8e 100644 --- a/arch/microblaze/kernel/syscalls/syscall.tbl +++ b/arch/microblaze/kernel/syscalls/syscall.tbl @@ -444,3 +444,4 @@ @@ -100,8 +86,6 @@ index edacc4561f2b..46c06f800e8e 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl -index f777141f5256..552ba4dafbef 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -377,3 +377,4 @@ @@ -109,8 +93,6 @@ index f777141f5256..552ba4dafbef 100644 438 n32 pidfd_getfd sys_pidfd_getfd 439 n32 faccessat2 sys_faccessat2 +440 n32 readfile sys_readfile -diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl -index da8c76394e17..e12581bf900b 100644 --- a/arch/mips/kernel/syscalls/syscall_n64.tbl +++ b/arch/mips/kernel/syscalls/syscall_n64.tbl @@ -353,3 +353,4 @@ @@ -118,8 +100,6 @@ index da8c76394e17..e12581bf900b 100644 438 n64 pidfd_getfd sys_pidfd_getfd 439 n64 faccessat2 sys_faccessat2 +440 n64 readfile sys_readfile -diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl -index 13280625d312..67cb8f8fbdb2 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -426,3 +426,4 @@ @@ -127,8 +107,6 @@ index 13280625d312..67cb8f8fbdb2 100644 438 o32 pidfd_getfd sys_pidfd_getfd 439 o32 faccessat2 sys_faccessat2 +440 o32 readfile sys_readfile -diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl -index 5a758fa6ec52..775e5228ab51 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -436,3 +436,4 @@ @@ -136,8 +114,6 @@ index 5a758fa6ec52..775e5228ab51 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl -index f833a3190822..d452db708635 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -528,3 +528,4 @@ @@ -145,8 +121,6 @@ index f833a3190822..d452db708635 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl -index bfdcb7633957..7ab529813a42 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -441,3 +441,4 @@ @@ -154,8 +128,6 @@ index bfdcb7633957..7ab529813a42 100644 438 common pidfd_getfd sys_pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 sys_faccessat2 +440 common readfile sys_readfile sys_readfile -diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl -index acc35daa1b79..ce8862cdb707 100644 --- a/arch/sh/kernel/syscalls/syscall.tbl +++ b/arch/sh/kernel/syscalls/syscall.tbl @@ -441,3 +441,4 @@ @@ -163,8 +135,6 @@ index acc35daa1b79..ce8862cdb707 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl -index 8004a276cb74..d89e7224bb0f 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -484,3 +484,4 @@ @@ -172,8 +142,6 @@ index 8004a276cb74..d89e7224bb0f 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl -index d8f8a1a69ed1..6f8d0b0acb6a 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -443,3 +443,4 @@ @@ -181,8 +149,6 @@ index d8f8a1a69ed1..6f8d0b0acb6a 100644 438 i386 pidfd_getfd sys_pidfd_getfd 439 i386 faccessat2 sys_faccessat2 +440 i386 readfile sys_readfile -diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl -index 78847b32e137..9c54081b7c14 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -360,6 +360,7 @@ @@ -193,8 +159,6 @@ index 78847b32e137..9c54081b7c14 100644 # # x32-specific system call numbers start at 512 to avoid cache impact -diff --git a/arch/xtensa/kernel/syscalls/syscall.tbl b/arch/xtensa/kernel/syscalls/syscall.tbl -index 69d0d73876b3..7b1f2ea76621 100644 --- a/arch/xtensa/kernel/syscalls/syscall.tbl +++ b/arch/xtensa/kernel/syscalls/syscall.tbl @@ -409,3 +409,4 @@ @@ -202,11 +166,9 @@ index 69d0d73876b3..7b1f2ea76621 100644 438 common pidfd_getfd sys_pidfd_getfd 439 common faccessat2 sys_faccessat2 +440 common readfile sys_readfile -diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h -index 7c354c2955f5..b5cb9425c0f4 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h -@@ -1005,6 +1005,8 @@ asmlinkage long sys_pidfd_send_signal(int pidfd, int sig, +@@ -1005,6 +1005,8 @@ asmlinkage long sys_pidfd_send_signal(in siginfo_t __user *info, unsigned int flags); asmlinkage long sys_pidfd_getfd(int pidfd, int fd, unsigned int flags); @@ -215,8 +177,6 @@ index 7c354c2955f5..b5cb9425c0f4 100644 /* * Architecture-specific system calls -diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h -index f4a01305d9a6..81b677c01266 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -857,9 +857,11 @@ __SYSCALL(__NR_openat2, sys_openat2) @@ -232,6 +192,3 @@ index f4a01305d9a6..81b677c01266 100644 /* * 32 bit systems traditionally used different --- -2.27.0 - diff --git a/0003-selftests-add-readfile-2-selftests.patch b/0003-selftests-add-readfile-2-selftests.patch index c3a405403a0e70..8b9280a4fb5722 100644 --- a/0003-selftests-add-readfile-2-selftests.patch +++ b/0003-selftests-add-readfile-2-selftests.patch @@ -1,7 +1,7 @@ -From 2a133d8e0cb79bc7566c39aae1191a7118a1202e Mon Sep 17 00:00:00 2001 +From 8928abbad99c7d3750695998e5fa7ba144da3300 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Date: Sun, 8 Mar 2020 09:54:45 +0100 -Subject: [PATCH 3/3] selftests: add readfile(2) selftests +Subject: [PATCH 3/4] selftests: add readfile(2) selftests Test the functionality of readfile(2) in various ways. @@ -10,19 +10,17 @@ instead of using open()/read()/close(). Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- - tools/testing/selftests/Makefile | 1 + - tools/testing/selftests/readfile/.gitignore | 3 + - tools/testing/selftests/readfile/Makefile | 7 + - tools/testing/selftests/readfile/readfile.c | 285 ++++++++++++++++++ - .../selftests/readfile/readfile_speed.c | 221 ++++++++++++++ + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/readfile/.gitignore | 3 + tools/testing/selftests/readfile/Makefile | 7 + tools/testing/selftests/readfile/readfile.c | 285 ++++++++++++++++++++++ + tools/testing/selftests/readfile/readfile_speed.c | 221 +++++++++++++++++ 5 files changed, 517 insertions(+) create mode 100644 tools/testing/selftests/readfile/.gitignore create mode 100644 tools/testing/selftests/readfile/Makefile create mode 100644 tools/testing/selftests/readfile/readfile.c create mode 100644 tools/testing/selftests/readfile/readfile_speed.c -diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile -index 1195bd85af38..82359233b945 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -46,6 +46,7 @@ TARGETS += ptrace @@ -33,18 +31,12 @@ index 1195bd85af38..82359233b945 100644 TARGETS += seccomp TARGETS += sigaltstack TARGETS += size -diff --git a/tools/testing/selftests/readfile/.gitignore b/tools/testing/selftests/readfile/.gitignore -new file mode 100644 -index 000000000000..f0e758d437e4 --- /dev/null +++ b/tools/testing/selftests/readfile/.gitignore @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +readfile +readfile_speed -diff --git a/tools/testing/selftests/readfile/Makefile b/tools/testing/selftests/readfile/Makefile -new file mode 100644 -index 000000000000..1bf1bdec40f8 --- /dev/null +++ b/tools/testing/selftests/readfile/Makefile @@ -0,0 +1,7 @@ @@ -55,9 +47,6 @@ index 000000000000..1bf1bdec40f8 +TEST_GEN_PROGS := readfile readfile_speed + +include ../lib.mk -diff --git a/tools/testing/selftests/readfile/readfile.c b/tools/testing/selftests/readfile/readfile.c -new file mode 100644 -index 000000000000..f0736c6dfa69 --- /dev/null +++ b/tools/testing/selftests/readfile/readfile.c @@ -0,0 +1,285 @@ @@ -346,9 +335,6 @@ index 000000000000..f0736c6dfa69 + return ksft_exit_pass(); +} + -diff --git a/tools/testing/selftests/readfile/readfile_speed.c b/tools/testing/selftests/readfile/readfile_speed.c -new file mode 100644 -index 000000000000..bbf985b30d1b --- /dev/null +++ b/tools/testing/selftests/readfile/readfile_speed.c @@ -0,0 +1,221 @@ @@ -573,6 +559,3 @@ index 000000000000..bbf985b30d1b + + return retval; +} --- -2.27.0 - diff --git a/0004-readfile.2.patch b/0004-readfile.2.patch new file mode 100644 index 00000000000000..be3b579d0158f7 --- /dev/null +++ b/0004-readfile.2.patch @@ -0,0 +1,242 @@ +From 1dcacd2cfdce9695c9e66e21d6ec0292d66da400 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> +Date: Fri, 12 Jun 2020 12:11:39 +0200 +Subject: [PATCH 4/4] readfile.2 + +--- + readfile.2 | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 229 insertions(+) + create mode 100644 readfile.2 + +--- /dev/null ++++ b/readfile.2 +@@ -0,0 +1,229 @@ ++.\" This manpage is Copyright (C) 2020 Greg Kroah-Hartman; ++.\" and Copyright (C) 2020 The Linux Foundation ++.\" ++.\" %%%LICENSE_START(VERBATIM) ++.\" Permission is granted to make and distribute verbatim copies of this ++.\" manual provided the copyright notice and this permission notice are ++.\" preserved on all copies. ++.\" ++.\" Permission is granted to copy and distribute modified versions of this ++.\" manual under the conditions for verbatim copying, provided that the ++.\" entire resulting derived work is distributed under the terms of a ++.\" permission notice identical to this one. ++.\" ++.\" Since the Linux kernel and libraries are constantly changing, this ++.\" manual page may be incorrect or out-of-date. The author(s) assume no ++.\" responsibility for errors or omissions, or for damages resulting from ++.\" the use of the information contained herein. The author(s) may not ++.\" have taken the same level of care in the production of this manual, ++.\" which is licensed free of charge, as they might when working ++.\" professionally. ++.\" ++.\" Formatted or processed versions of this manual, if unaccompanied by ++.\" the source, must acknowledge the copyright and authors of this work. ++.\" %%%LICENSE_END ++.\" ++.TH READFILE 2 2020-06-12 "Linux" "Linux Programmer's Manual" ++.SH NAME ++readfile \- read a file into a buffer ++.SH SYNOPSIS ++.nf ++.B #include <unistd.h> ++.PP ++.BI "ssize_t readfile(int " dirfd ", const char *" pathname ", void *" buf \ ++", size_t " count ", int " flags ); ++.fi ++.SH DESCRIPTION ++.BR readfile () ++attempts to open the file specified by ++.IR pathname ++and to read up to ++.I count ++bytes from the file into the buffer starting at ++.IR buf . ++It is to be a shortcut of doing the sequence of ++.BR open () ++and then ++.BR read () ++and then ++.BR close () ++for small files that are read frequently, such as those in ++.B procfs ++or ++.BR sysfs . ++.PP ++If the size of file is smaller than the value provided in ++.I count ++then the whole file will be copied into ++.IR buf . ++.PP ++If the file is larger than the value provided in ++.I count ++then only ++.I count ++number of bytes will be copied into ++.IR buf . ++.PP ++The argument ++.I flags ++may contain one of the following ++.IR "access modes" : ++.BR O_NOFOLLOW ", or " O_NOATIME . ++.PP ++If the pathname given in ++.I pathname ++is relative, then it is interpreted relative to the directory ++referred to by the file descriptor ++.IR dirfd . ++.PP ++If ++.I pathname ++is relative and ++.I dirfd ++is the special value ++.BR AT_FDCWD , ++then ++.I pathname ++is interpreted relative to the current working ++directory of the calling process (like ++.BR open ()). ++.PP ++If ++.I pathname ++is absolute, then ++.I dirfd ++is ignored. ++.SH RETURN VALUE ++On success, the number of bytes read is returned. ++It is not an error if this number is smaller than the number of bytes ++requested; this can happen if the file is smaller than the number of ++bytes requested. ++.PP ++On error, \-1 is returned, and ++.I errno ++is set appropriately. ++.SH ERRORS ++.TP ++.B EAGAIN ++The file descriptor ++.I fd ++refers to a file other than a socket and has been marked nonblocking ++.RB ( O_NONBLOCK ), ++and the read would block. ++See ++.BR open (2) ++for further details on the ++.BR O_NONBLOCK ++flag. ++.TP ++.BR EAGAIN " or " EWOULDBLOCK ++.\" Actually EAGAIN on Linux ++The file descriptor ++.I fd ++refers to a socket and has been marked nonblocking ++.RB ( O_NONBLOCK ), ++and the read would block. ++POSIX.1-2001 allows either error to be returned for this case, ++and does not require these constants to have the same value, ++so a portable application should check for both possibilities. ++.TP ++.B EBADF ++.I fd ++is not a valid file descriptor or is not open for reading. ++.TP ++.B EFAULT ++.I buf ++is outside your accessible address space. ++.TP ++.B EINTR ++The call was interrupted by a signal before any data was read; see ++.BR signal (7). ++.TP ++.B EINVAL ++.I fd ++is attached to an object which is unsuitable for reading; ++or the file was opened with the ++.B O_DIRECT ++flag, and either the address specified in ++.IR buf , ++the value specified in ++.IR count , ++or the file offset is not suitably aligned. ++.TP ++.B EINVAL ++.I fd ++was created via a call to ++.BR timerfd_create (2) ++and the wrong size buffer was given to ++.BR read (); ++see ++.BR timerfd_create (2) ++for further information. ++.TP ++.B EIO ++I/O error. ++This will happen for example when the process is in a ++background process group, tries to read from its controlling terminal, ++and either it is ignoring or blocking ++.B SIGTTIN ++or its process group ++is orphaned. ++It may also occur when there is a low-level I/O error ++while reading from a disk or tape. ++A further possible cause of ++.B EIO ++on networked filesystems is when an advisory lock had been taken ++out on the file descriptor and this lock has been lost. ++See the ++.I "Lost locks" ++section of ++.BR fcntl (2) ++for further details. ++.TP ++.B EISDIR ++.I fd ++refers to a directory. ++.PP ++Other errors may occur, depending on the object connected to ++.IR fd . ++.SH CONFORMING TO ++SVr4, 4.3BSD, POSIX.1-2001. ++.SH NOTES ++The types ++.I size_t ++and ++.I ssize_t ++are, respectively, ++unsigned and signed integer data types specified by POSIX.1. ++.PP ++On Linux, ++.BR read () ++(and similar system calls) will transfer at most ++0x7ffff000 (2,147,479,552) bytes, ++returning the number of bytes actually transferred. ++.\" commit e28cc71572da38a5a12c1cfe4d7032017adccf69 ++(This is true on both 32-bit and 64-bit systems.) ++.PP ++On NFS filesystems, reading small amounts of data will update the ++timestamp only the first time, subsequent calls may not do so. ++This is caused ++by client side attribute caching, because most if not all NFS clients ++leave ++.I st_atime ++(last file access time) ++updates to the server, and client side reads satisfied from the ++client's cache will not cause ++.I st_atime ++updates on the server as there are no ++server-side reads. ++UNIX semantics can be obtained by disabling client-side attribute caching, ++but in most situations this will substantially ++increase server load and decrease performance. ++.SH BUGS ++None yet! ++.SH SEE ALSO ++.BR close (2), ++.BR open (2), ++.BR openat (2), ++.BR read (2), ++.BR fread (3) @@ -1,7 +1,9 @@ # +0001-Revert-zram-convert-remaining-CLASS_ATTR-to-CLASS_AT.patch 0001-readfile-implement-readfile-syscall.patch 0002-arch-wire-up-the-readfile-syscall.patch 0003-selftests-add-readfile-2-selftests.patch +0004-readfile.2.patch spdxcheck-print-out-files-without-any-spdx-lines.patch 0001-tty-n_r3964-locking-fixups.patch |