Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4569765ybi; Tue, 11 Jun 2019 08:45:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9xJNJ7+qNBch9PS2ky8+egE0NF7wR9OPdKD52HG0YZEHWPteMgfYFxMeCoihY/gfXOmoU X-Received: by 2002:a17:902:467:: with SMTP id 94mr20962581ple.131.1560267959654; Tue, 11 Jun 2019 08:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560267959; cv=none; d=google.com; s=arc-20160816; b=qGFq10uXfZV7YlYv383CTfYnvu4022aL34lAMhzVEyO55OIALBmjv4uztb4YNjAx31 qLkBgbz6ppxFfd9ug2WkmjhnRKgmd+0/F30wzbutPcFFcVNYnlG6rvTZqs2/E6V+3yUh l1tT0hay/wbjU/wx2brFYKOEpL4l9IlyRcyViLlalLDE5jvWZdLO9E5IAEPoLUilvZHi rGfQm0q5WDr8xnVk1l4E3o5wtd85HbKxT71dPlGDCngCyjfc6BqjVFNjGfcmpWwaDTvb bPeQOjJEDmt36IPs5l4odkWD4fiumTdorTo0fExrRBi9tQSkPGXld+tEMObfQehcknEF tIKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=wYH8SCpy6HJHKzAwukvouuRSkxneT6gkUbdej0OiLzk=; b=R+xIHphN7RvGrQClmJuZltWjiZ6ua51Y+76O1+irKlPgfoMWWy610NEZvEEeLkX94+ uyz6xEjj54LKQMFrx/colaMEo3EARzqFh0M34DtW/iF8pejPfvSZYX60Ixrp+lt6qwDN 6Kyt+LcoQVuQGf2QrllMFoBLYAMhtZNfuQXlE4h73qWmcqSXqV6BRvknAFGAYt3dcTXQ 35D85iH/LCR1+qjulO2mT4hv+2iWZAj5XlC6gjoj/Ks7ymMReplUMyLD8HnLi16oq8Rf KsyRB1XoNsJ1s3BauVAppfyPuN1mezUnxJle4bFkbstJg8YGt7OVbfViuRy+qjM4TDaf BhdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v204si7998684pgb.80.2019.06.11.08.45.43; Tue, 11 Jun 2019 08:45:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391697AbfFKOzd (ORCPT + 99 others); Tue, 11 Jun 2019 10:55:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:52726 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2391683AbfFKOzc (ORCPT ); Tue, 11 Jun 2019 10:55:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1A8B1AD5D; Tue, 11 Jun 2019 14:55:30 +0000 (UTC) From: Roman Penyaev Cc: Roman Penyaev , Andrew Morton , Al Viro , Arnd Bergmann , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/14] epoll: implement epoll_create2() syscall Date: Tue, 11 Jun 2019 16:54:57 +0200 Message-Id: <20190611145458.9540-14-rpenyaev@suse.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190611145458.9540-1-rpenyaev@suse.de> References: <20190611145458.9540-1-rpenyaev@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org epoll_create2() is needed to accept EPOLL_USERPOLL flags and size, i.e. this patch wires up polling from userspace. Signed-off-by: Roman Penyaev Cc: Andrew Morton Cc: Al Viro Cc: Arnd Bergmann Cc: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Hi Arnd, I am not sure is that correct, especially for alpha, because clone3() is missing for some archs. I noticed that clone3() follows with a gap, so I kept the same for all archs. Could you please take a look. arch/alpha/kernel/syscalls/syscall.tbl | 2 ++ 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 | 2 ++ arch/m68k/kernel/syscalls/syscall.tbl | 2 ++ arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_n64.tbl | 2 ++ arch/mips/kernel/syscalls/syscall_o32.tbl | 2 ++ arch/parisc/kernel/syscalls/syscall.tbl | 2 ++ arch/powerpc/kernel/syscalls/syscall.tbl | 2 ++ arch/s390/kernel/syscalls/syscall.tbl | 2 ++ arch/sh/kernel/syscalls/syscall.tbl | 2 ++ arch/sparc/kernel/syscalls/syscall.tbl | 2 ++ arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + fs/eventpoll.c | 5 +++++ include/linux/syscalls.h | 1 + include/uapi/asm-generic/unistd.h | 4 +++- kernel/sys_ni.c | 1 + 22 files changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl index 1db9bbcfb84e..a1d7b695063d 100644 --- a/arch/alpha/kernel/syscalls/syscall.tbl +++ b/arch/alpha/kernel/syscalls/syscall.tbl @@ -474,3 +474,5 @@ 542 common fsmount sys_fsmount 543 common fspick sys_fspick 544 common pidfd_open sys_pidfd_open +# 546 common clone3 sys_clone3 +547 common epoll_create2 sys_epoll_create2 diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl index ff45d8807cb8..1497f3c87d54 100644 --- a/arch/arm/tools/syscall.tbl +++ b/arch/arm/tools/syscall.tbl @@ -449,3 +449,4 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 24480c2d95da..8ed47af3d64a 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -44,7 +44,7 @@ #define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5) #define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) -#define __NR_compat_syscalls 437 +#define __NR_compat_syscalls 438 #endif #define __ARCH_WANT_SYS_CLONE diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index 10f16b0175ca..eb467e639352 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -890,6 +890,8 @@ __SYSCALL(__NR_fspick, sys_fspick) __SYSCALL(__NR_pidfd_open, sys_pidfd_open) #define __NR_clone3 436 __SYSCALL(__NR_clone3, sys_clone3) +#define __NR_epoll_create2 437 +__SYSCALL(__NR_epoll_create2, sys_epoll_create2) /* * 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 ecc44926737b..5cecff901853 100644 --- a/arch/ia64/kernel/syscalls/syscall.tbl +++ b/arch/ia64/kernel/syscalls/syscall.tbl @@ -355,3 +355,5 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl index 9a3eb2558568..29d944e2e9d6 100644 --- a/arch/m68k/kernel/syscalls/syscall.tbl +++ b/arch/m68k/kernel/syscalls/syscall.tbl @@ -434,3 +434,5 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl index 9181f181f76d..fad83841b16b 100644 --- a/arch/microblaze/kernel/syscalls/syscall.tbl +++ b/arch/microblaze/kernel/syscalls/syscall.tbl @@ -441,3 +441,4 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index 97035e19ad03..661d63d7ea84 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -373,3 +373,5 @@ 432 n32 fsmount sys_fsmount 433 n32 fspick sys_fspick 434 n32 pidfd_open sys_pidfd_open +# 436 n32 clone3 sys_clone3 +437 n32 epoll_create2 sys_epoll_create2 diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl index d7292722d3b0..4a7f270ef126 100644 --- a/arch/mips/kernel/syscalls/syscall_n64.tbl +++ b/arch/mips/kernel/syscalls/syscall_n64.tbl @@ -349,3 +349,5 @@ 432 n64 fsmount sys_fsmount 433 n64 fspick sys_fspick 434 n64 pidfd_open sys_pidfd_open +# 436 n64 clone3 sys_clone3 +437 n64 epoll_create2 sys_epoll_create2 diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index dba084c92f14..db87225a9dc5 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -422,3 +422,5 @@ 432 o32 fsmount sys_fsmount 433 o32 fspick sys_fspick 434 o32 pidfd_open sys_pidfd_open +# 436 o32 clone3 sys_clone3 +437 o32 epoll_create2 sys_epoll_create2 diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index 5022b9e179c2..25374a2c4e16 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -431,3 +431,5 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index f2c3bda2d39f..9f48d8a737ab 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -516,3 +516,5 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index 6ebacfeaf853..0cef54850a1c 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -437,3 +437,5 @@ 432 common fsmount sys_fsmount sys_fsmount 433 common fspick sys_fspick sys_fspick 434 common pidfd_open sys_pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 sys_epoll_create2 diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl index 834c9c7d79fa..42769d6ec8fe 100644 --- a/arch/sh/kernel/syscalls/syscall.tbl +++ b/arch/sh/kernel/syscalls/syscall.tbl @@ -437,3 +437,5 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl index c58e71f21129..bf86fa32913d 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -480,3 +480,5 @@ 432 common fsmount sys_fsmount 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open +# 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 6a99dbbf7e04..26d64f09b097 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -440,3 +440,4 @@ 433 i386 fspick sys_fspick __ia32_sys_fspick 434 i386 pidfd_open sys_pidfd_open __ia32_sys_pidfd_open 436 i386 clone3 sys_clone3 __ia32_sys_clone3 +437 i386 epoll_create2 sys_epoll_create2 __ia32_sys_epoll_create2 diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index 68227c7f71e5..4b58d8694693 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -357,6 +357,7 @@ 433 common fspick __x64_sys_fspick 434 common pidfd_open __x64_sys_pidfd_open 436 common clone3 __x64_sys_clone3/ptregs +437 common epoll_create2 __x64_sys_epoll_create2 # # 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 d5a1fd2c96c7..eef4367d433e 100644 --- a/arch/xtensa/kernel/syscalls/syscall.tbl +++ b/arch/xtensa/kernel/syscalls/syscall.tbl @@ -406,3 +406,4 @@ 433 common fspick sys_fspick 434 common pidfd_open sys_pidfd_open 436 common clone3 sys_clone3 +437 common epoll_create2 sys_epoll_create2 diff --git a/fs/eventpoll.c b/fs/eventpoll.c index c5db15c5f8b0..6b1b5c043e42 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -2799,6 +2799,11 @@ static int do_epoll_create(int flags, size_t size) return error; } +SYSCALL_DEFINE2(epoll_create2, int, flags, size_t, size) +{ + return do_epoll_create(flags, size); +} + SYSCALL_DEFINE1(epoll_create1, int, flags) { return do_epoll_create(flags, 0); diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index b01d54a5732e..655ac0ebfdf9 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -357,6 +357,7 @@ asmlinkage long sys_eventfd2(unsigned int count, int flags); /* fs/eventpoll.c */ asmlinkage long sys_epoll_create1(int flags); +asmlinkage long sys_epoll_create2(int flags, size_t size); asmlinkage long sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event); asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events, diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 7c7c14a2e097..59c9dea64565 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -848,9 +848,11 @@ __SYSCALL(__NR_fspick, sys_fspick) __SYSCALL(__NR_pidfd_open, sys_pidfd_open) #define __NR_clone3 436 __SYSCALL(__NR_clone3, sys_clone3) +#define __NR_epoll_create2 437 +__SYSCALL(__NR_epoll_create2, sys_epoll_create2) #undef __NR_syscalls -#define __NR_syscalls 437 +#define __NR_syscalls 438 /* * 32 bit systems traditionally used different diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 4d9ae5ea6caf..665908b8a326 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c @@ -65,6 +65,7 @@ COND_SYSCALL(eventfd2); /* fs/eventfd.c */ COND_SYSCALL(epoll_create1); +COND_SYSCALL(epoll_create2); COND_SYSCALL(epoll_ctl); COND_SYSCALL(epoll_pwait); COND_SYSCALL_COMPAT(epoll_pwait); -- 2.21.0