From patchwork Tue Jul 11 11:25:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 118426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp405868vqm; Tue, 11 Jul 2023 04:30:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlH/YZmYvwUIOTR2/zugQm7FpRKhuxJa5lN7Ile0ZH5TqIs9Lksf5qaCs5o40kvPfvJOz00+ X-Received: by 2002:a17:903:48f:b0:1b8:d32:2cd8 with SMTP id jj15-20020a170903048f00b001b80d322cd8mr10938662plb.55.1689075016813; Tue, 11 Jul 2023 04:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689075016; cv=none; d=google.com; s=arc-20160816; b=B/9X/DNreRoRz9nA1I5MXUizZJ1mw01kVeF2bchYkiGwGirYDmb/0vJIiLcPtl+whD 0QeuqWW4amNFk2CP3O88BMQjUIe1LT+nKeYzodnuxUYI0/3WyMJkKsztOoQnIGj7UVYs bsOleTZI2QZSccqdwTqqiShSIGCIA1tJRjbI6465jdJhmFfPjKdZbhFaUa3bF+3ybVI4 QmHmYg/DFe7rzyMD0B4pcZKBKvZl87jLrxkMV6RQV6Qhwi1Dnv5yjx9TIX5QsbMk+vJ7 GTQO5QL9+AdR27lrAs09M7kpaJPYbdBB5m4TTV29pwdTfmlzkLJj+WRGEx3drSQ5pmoH d2CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k3/Pq5VvWJsFt7ylp4WqvH+yJo9cOzoEASObW7mHhCc=; fh=seYkIZwGhsaZ2mPN9tbwuL3qzBlMHi0iBX9GrZDxiYI=; b=Usf17iMT1H/G651rxDNtf3h7heeefIyEXTSNIjJFqTQ/ixn+NBEnGVJoHTYrBBhbNP xg3leQINhfJYbToAWXWnUhPGIRDeujT0ESvBqhB6AfKbdfoLyE14KXDv1KRN+vNdecYE IOPB4pE9wJZVA9IwPOz8fqJSSQMhp0wEt0nhyzlyLTe0jYILW3h6Olw5M5LoWlJmGp9J Bg3IoQGhXkwqzeVoWz0gXrk5dD0ShxLal6TIZ8Yr8M+fJsFmfFG7JOP3fJNUHsDYpVZN iW3d9Xo3sFO0Jy87klx4E7urVDc0B8amPNC5MX8aijI/8nDo8mqouu53QYX+xIcQnng4 bONQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a170902c70c00b001b4fc117bf0si1419354plp.116.2023.07.11.04.30.03; Tue, 11 Jul 2023 04:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231898AbjGKL2k (ORCPT + 99 others); Tue, 11 Jul 2023 07:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232016AbjGKL2d (ORCPT ); Tue, 11 Jul 2023 07:28:33 -0400 Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B03131733 for ; Tue, 11 Jul 2023 04:28:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-kBJ53YogNVCGT9y2vG2Zzg-1; Tue, 11 Jul 2023 07:26:26 -0400 X-MC-Unique: kBJ53YogNVCGT9y2vG2Zzg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 66932185A794; Tue, 11 Jul 2023 11:26:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.45.225.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98AD563F3C; Tue, 11 Jul 2023 11:26:13 +0000 (UTC) From: Alexey Gladkov To: LKML , Arnd Bergmann , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk Cc: Palmer Dabbelt , James.Bottomley@HansenPartnership.com, acme@kernel.org, alexander.shishkin@linux.intel.com, axboe@kernel.dk, benh@kernel.crashing.org, borntraeger@de.ibm.com, bp@alien8.de, catalin.marinas@arm.com, christian@brauner.io, dalias@libc.org, davem@davemloft.net, deepa.kernel@gmail.com, deller@gmx.de, dhowells@redhat.com, fenghua.yu@intel.com, firoz.khan@linaro.org, fweimer@redhat.com, geert@linux-m68k.org, glebfm@altlinux.org, gor@linux.ibm.com, hare@suse.com, heiko.carstens@de.ibm.com, hpa@zytor.com, ink@jurassic.park.msu.ru, jhogan@kernel.org, kim.phillips@arm.com, ldv@altlinux.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux@armlinux.org.uk, linuxppc-dev@lists.ozlabs.org, luto@kernel.org, mattst88@gmail.com, mingo@redhat.com, monstr@monstr.eu, mpe@ellerman.id.au, namhyung@kernel.org, paul.burton@mips.com, paulus@samba.org, peterz@infradead.org, ralf@linux-mips.org, rth@twiddle.net, schwidefsky@de.ibm.com, sparclinux@vger.kernel.org, stefan@agner.ch, tglx@linutronix.de, tony.luck@intel.com, tycho@tycho.ws, will@kernel.org, x86@kernel.org, ysato@users.sourceforge.jp Subject: [PATCH v3 1/5] Non-functional cleanup of a "__user * filename" Date: Tue, 11 Jul 2023 13:25:42 +0200 Message-Id: <3098381cf93a5010e878319c6218d2c5851746c0.1689074739.git.legion@kernel.org> In-Reply-To: References: <87o8pscpny.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771123524986440304 X-GMAIL-MSGID: 1771123524986440304 From: Palmer Dabbelt The next patch defines a very similar interface, which I copied from this definition. Since I'm touching it anyway I don't see any reason not to just go fix this one up. Signed-off-by: Palmer Dabbelt Acked-by: Arnd Bergmann --- include/linux/syscalls.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 33a0ee3bcb2e..497bdd968c32 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -464,7 +464,7 @@ asmlinkage long sys_chdir(const char __user *filename); asmlinkage long sys_fchdir(unsigned int fd); asmlinkage long sys_chroot(const char __user *filename); asmlinkage long sys_fchmod(unsigned int fd, umode_t mode); -asmlinkage long sys_fchmodat(int dfd, const char __user * filename, +asmlinkage long sys_fchmodat(int dfd, const char __user *filename, umode_t mode); asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, int flag); From patchwork Tue Jul 11 11:25:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 118427 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp405923vqm; Tue, 11 Jul 2023 04:30:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlEeWa5jjzEGlJCCR4ocRQwN+Cll+7FBcr2kxW8JC3bjxKTEgglfRvPQW7N5O0oQ/7APnXd7 X-Received: by 2002:a17:90a:f40f:b0:263:30d6:dca with SMTP id ch15-20020a17090af40f00b0026330d60dcamr15698486pjb.29.1689075020081; Tue, 11 Jul 2023 04:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689075020; cv=none; d=google.com; s=arc-20160816; b=sgKuokgm0yPmlK8MxLyqZujAP5eBh8wektQjY/Dw9PzxNzcDhfQIFkl/8/EaVRQKq7 CWz3isgt9032et25Fq6yx5hy4qHNRQtNljpRAfeS6eBjoz+Dth5A+eYB1EHsMAJ+APpl vtKkv1ASIr30xpr/oTMqHcSo2pn3piss4UzHBnAcAuuhvenkISO0mrTq6zOK5eS0vicC aup6uHUeN4S++wxsOFtHsqy7vIHeApfjk9K3+ZjGrT9/Q+qYLUdhGRrCaZ/tr11XZCUm tNuPRKnOUoG4G7/+JTVdGYWtBZT7EUBDO8vtUZW490hgB+b9viijNvCjcPyb/vLyJVnj 4wKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tqGTDjWgCyl3301VCICiGeNnsnGd2C5+b72JLCu08OI=; fh=seYkIZwGhsaZ2mPN9tbwuL3qzBlMHi0iBX9GrZDxiYI=; b=GupDeQAlkqzfvVzjEbj88ZqrUSUsdX1GxNEl6o2u9B3nKqx8pKc6oSIpnM/G2ZSHOT Nyktf6fVBwSnQnOQmzxWGyWrc5jB6t8l8JQ70kqbp/Oj1A+f1A04+vtEdZv+A4rt3Vsf a4+AAVYveQy4G5nCwoFVrcqgYWKI/9CW+iWEnQhrdJnJLe0lobrn2mHubPZ78R1HVPMr 1rHuBrHZOUiXll18CAPgXVTojs283Wk5jQHZTH9pq25O6ZowDw9X3GQk6P+jOpjl1R1K Ctdkh9yTU+Z6AfxuR5HdlYdEjMu75h9ZeYcA0BtJ/bQOqeAPT48sTdotin3XLJFOfvCf rVeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca18-20020a17090af31200b0024c1ddfa1bfsi4845353pjb.92.2023.07.11.04.30.07; Tue, 11 Jul 2023 04:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbjGKL3F (ORCPT + 99 others); Tue, 11 Jul 2023 07:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbjGKL2i (ORCPT ); Tue, 11 Jul 2023 07:28:38 -0400 Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C1F1BC9 for ; Tue, 11 Jul 2023 04:28:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-349-1yjghznhNHO9f6zghBUlhw-1; Tue, 11 Jul 2023 07:26:39 -0400 X-MC-Unique: 1yjghznhNHO9f6zghBUlhw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F71B3C13928; Tue, 11 Jul 2023 11:26:38 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.45.225.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5A9463F3C; Tue, 11 Jul 2023 11:26:25 +0000 (UTC) From: Alexey Gladkov To: LKML , Arnd Bergmann , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk Cc: Palmer Dabbelt , James.Bottomley@HansenPartnership.com, acme@kernel.org, alexander.shishkin@linux.intel.com, axboe@kernel.dk, benh@kernel.crashing.org, borntraeger@de.ibm.com, bp@alien8.de, catalin.marinas@arm.com, christian@brauner.io, dalias@libc.org, davem@davemloft.net, deepa.kernel@gmail.com, deller@gmx.de, dhowells@redhat.com, fenghua.yu@intel.com, firoz.khan@linaro.org, fweimer@redhat.com, geert@linux-m68k.org, glebfm@altlinux.org, gor@linux.ibm.com, hare@suse.com, heiko.carstens@de.ibm.com, hpa@zytor.com, ink@jurassic.park.msu.ru, jhogan@kernel.org, kim.phillips@arm.com, ldv@altlinux.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux@armlinux.org.uk, linuxppc-dev@lists.ozlabs.org, luto@kernel.org, mattst88@gmail.com, mingo@redhat.com, monstr@monstr.eu, mpe@ellerman.id.au, namhyung@kernel.org, paul.burton@mips.com, paulus@samba.org, peterz@infradead.org, ralf@linux-mips.org, rth@twiddle.net, schwidefsky@de.ibm.com, sparclinux@vger.kernel.org, stefan@agner.ch, tglx@linutronix.de, tony.luck@intel.com, tycho@tycho.ws, will@kernel.org, x86@kernel.org, ysato@users.sourceforge.jp Subject: [PATCH v3 2/5] fs: Add fchmodat4() Date: Tue, 11 Jul 2023 13:25:43 +0200 Message-Id: In-Reply-To: References: <87o8pscpny.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771123528131488174 X-GMAIL-MSGID: 1771123528131488174 From: Palmer Dabbelt On the userspace side fchmodat(3) is implemented as a wrapper function which implements the POSIX-specified interface. This interface differs from the underlying kernel system call, which does not have a flags argument. Most implementations require procfs [1][2]. There doesn't appear to be a good userspace workaround for this issue but the implementation in the kernel is pretty straight-forward. The new fchmodat4() syscall allows to pass the AT_SYMLINK_NOFOLLOW flag, unlike existing fchmodat. [1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/fchmodat.c;h=17eca54051ee28ba1ec3f9aed170a62630959143;hb=a492b1e5ef7ab50c6fdd4e4e9879ea5569ab0a6c#l35 [2] https://git.musl-libc.org/cgit/musl/tree/src/stat/fchmodat.c?id=718f363bc2067b6487900eddc9180c84e7739f80#n28 Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov Acked-by: Arnd Bergmann --- fs/open.c | 18 ++++++++++++++---- include/linux/syscalls.h | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fs/open.c b/fs/open.c index 4478adcc4f3a..58bb88c6afb6 100644 --- a/fs/open.c +++ b/fs/open.c @@ -671,11 +671,11 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) return err; } -static int do_fchmodat(int dfd, const char __user *filename, umode_t mode) +static int do_fchmodat4(int dfd, const char __user *filename, umode_t mode, int lookup_flags) { struct path path; int error; - unsigned int lookup_flags = LOOKUP_FOLLOW; + retry: error = user_path_at(dfd, filename, lookup_flags, &path); if (!error) { @@ -689,15 +689,25 @@ static int do_fchmodat(int dfd, const char __user *filename, umode_t mode) return error; } +SYSCALL_DEFINE4(fchmodat4, int, dfd, const char __user *, filename, + umode_t, mode, int, flags) +{ + if (unlikely(flags & ~AT_SYMLINK_NOFOLLOW)) + return -EINVAL; + + return do_fchmodat4(dfd, filename, mode, + flags & AT_SYMLINK_NOFOLLOW ? 0 : LOOKUP_FOLLOW); +} + SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, umode_t, mode) { - return do_fchmodat(dfd, filename, mode); + return do_fchmodat4(dfd, filename, mode, LOOKUP_FOLLOW); } SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode) { - return do_fchmodat(AT_FDCWD, filename, mode); + return do_fchmodat4(AT_FDCWD, filename, mode, LOOKUP_FOLLOW); } /** diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 497bdd968c32..b17d37d2bad6 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -466,6 +466,8 @@ asmlinkage long sys_chroot(const char __user *filename); asmlinkage long sys_fchmod(unsigned int fd, umode_t mode); asmlinkage long sys_fchmodat(int dfd, const char __user *filename, umode_t mode); +asmlinkage long sys_fchmodat4(int dfd, const char __user *filename, + umode_t mode, int flags); asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, int flag); asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group); From patchwork Tue Jul 11 11:25:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 118433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp407783vqm; Tue, 11 Jul 2023 04:33:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlGx6VAKClxA8/Hg6iGOUf2JYuA3zF5a8gJUFg1gIXxZBFqf8lMe75LRcqEN/0u6ouaJL2rG X-Received: by 2002:a17:902:ecc2:b0:1b6:6e3a:77fb with SMTP id a2-20020a170902ecc200b001b66e3a77fbmr21680962plh.2.1689075211476; Tue, 11 Jul 2023 04:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689075211; cv=none; d=google.com; s=arc-20160816; b=MX3N5Z255k/Tl6gBp0lMDt/Ix0yYyq6jkaf2INGfUodiKMESDZYJByNW8YRxOKKkvU /01pNhrMkin0k1d76mRCffLaOWMWzPV53bYRqKyj025Sa9AdI9ApfZOOQQFfAtklj0PE kzXRidCY3hqIau/lLUfuC4O70CurRKhbKo54DPD4HMfE+2aqWrTKNzxBDBObqDEK/bqr pTnjNLDcF29zx1Mpp8P0igTpdKMbpwCSKdgR7dJZ2FFNQ1ER8vhVTl1HMOB8cUe0sZwc rhBjdfPrV6j+BDomLRSt86HS0rm5wPBMZu0H77mEpwO9IEvIsSZbirNBEI+lBAYd/xuX 3yTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OilzPvFjPZ6PIap7xI+TAfJeMwM0NhOXABBRSSCimvc=; fh=seYkIZwGhsaZ2mPN9tbwuL3qzBlMHi0iBX9GrZDxiYI=; b=vY00fBoPaQSPUQ0bZTZYO5B9OhhZrT3d5GtIhYFLDY2KTZAlNbW4QUMEtXXe8s31fA 6MLNXuvY4ReqbejRcLKjrQ1jeg0Z80ABikOyDGUHlGrrHyC2+m6iPAdnEGvTF3kJZOnz yvL5JKQKMg0O7a6meWy9D7a5lEHuc7/R1xF65ZBcI/zEosOg5mdiR/MYydGQTIUG1iRZ bbIAr467oUyms8o1DZ5ys9q/FZNswqELc3uTSxr3lQP0ZfznUJ761x6K+VZ3hsOwnVYV pxsJTdADT2Vkmn9EQi8+QRHEQXEoIqqIPdrtDduYe3/qnYYbbuwnKpKG3QtHyv5RtPIz 8ghQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a170902c70c00b001b4fc117bf0si1419354plp.116.2023.07.11.04.33.18; Tue, 11 Jul 2023 04:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjGKL1L (ORCPT + 99 others); Tue, 11 Jul 2023 07:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231706AbjGKL1I (ORCPT ); Tue, 11 Jul 2023 07:27:08 -0400 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F9D2E51 for ; Tue, 11 Jul 2023 04:26:58 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-mrM3ULHUPVeLna_rRXTMqA-1; Tue, 11 Jul 2023 07:26:51 -0400 X-MC-Unique: mrM3ULHUPVeLna_rRXTMqA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6408A88D1B7; Tue, 11 Jul 2023 11:26:50 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.45.225.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEB8CF66B9; Tue, 11 Jul 2023 11:26:38 +0000 (UTC) From: Alexey Gladkov To: LKML , Arnd Bergmann , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk Cc: Palmer Dabbelt , James.Bottomley@HansenPartnership.com, acme@kernel.org, alexander.shishkin@linux.intel.com, axboe@kernel.dk, benh@kernel.crashing.org, borntraeger@de.ibm.com, bp@alien8.de, catalin.marinas@arm.com, christian@brauner.io, dalias@libc.org, davem@davemloft.net, deepa.kernel@gmail.com, deller@gmx.de, dhowells@redhat.com, fenghua.yu@intel.com, firoz.khan@linaro.org, fweimer@redhat.com, geert@linux-m68k.org, glebfm@altlinux.org, gor@linux.ibm.com, hare@suse.com, heiko.carstens@de.ibm.com, hpa@zytor.com, ink@jurassic.park.msu.ru, jhogan@kernel.org, kim.phillips@arm.com, ldv@altlinux.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux@armlinux.org.uk, linuxppc-dev@lists.ozlabs.org, luto@kernel.org, mattst88@gmail.com, mingo@redhat.com, monstr@monstr.eu, mpe@ellerman.id.au, namhyung@kernel.org, paul.burton@mips.com, paulus@samba.org, peterz@infradead.org, ralf@linux-mips.org, rth@twiddle.net, schwidefsky@de.ibm.com, sparclinux@vger.kernel.org, stefan@agner.ch, tglx@linutronix.de, tony.luck@intel.com, tycho@tycho.ws, will@kernel.org, x86@kernel.org, ysato@users.sourceforge.jp Subject: [PATCH v3 3/5] arch: Register fchmodat4, usually as syscall 451 Date: Tue, 11 Jul 2023 13:25:44 +0200 Message-Id: In-Reply-To: References: <87o8pscpny.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771123729195488802 X-GMAIL-MSGID: 1771123729195488802 From: Palmer Dabbelt This registers the new fchmodat4 syscall in most places as nuber 451, with alpha being the exception where it's 561. I found all these sites by grepping for fspick, which I assume has found me everything. Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov --- arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + 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/uapi/asm-generic/unistd.h | 5 ++++- 18 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl index 8ebacf37a8cf..00ceeffec7ff 100644 --- a/arch/alpha/kernel/syscalls/syscall.tbl +++ b/arch/alpha/kernel/syscalls/syscall.tbl @@ -490,3 +490,4 @@ 558 common process_mrelease sys_process_mrelease 559 common futex_waitv sys_futex_waitv 560 common set_mempolicy_home_node sys_ni_syscall +561 common fchmodat4 sys_fchmodat4 diff --git a/arch/arm/tools/syscall.tbl b/arch/arm/tools/syscall.tbl index ac964612d8b0..0b9702d5c425 100644 --- a/arch/arm/tools/syscall.tbl +++ b/arch/arm/tools/syscall.tbl @@ -464,3 +464,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index 604a2053d006..49c65d935049 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -907,6 +907,8 @@ __SYSCALL(__NR_process_mrelease, sys_process_mrelease) __SYSCALL(__NR_futex_waitv, sys_futex_waitv) #define __NR_set_mempolicy_home_node 450 __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node) +#define __NR_fchmodat4 451 +__SYSCALL(__NR_fchmodat4, sys_fchmodat4) /* * 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 72c929d9902b..b35225c64781 100644 --- a/arch/ia64/kernel/syscalls/syscall.tbl +++ b/arch/ia64/kernel/syscalls/syscall.tbl @@ -371,3 +371,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/m68k/kernel/syscalls/syscall.tbl b/arch/m68k/kernel/syscalls/syscall.tbl index b1f3940bc298..4d80cd87e089 100644 --- a/arch/m68k/kernel/syscalls/syscall.tbl +++ b/arch/m68k/kernel/syscalls/syscall.tbl @@ -450,3 +450,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/microblaze/kernel/syscalls/syscall.tbl b/arch/microblaze/kernel/syscalls/syscall.tbl index 820145e47350..306bd18e5b52 100644 --- a/arch/microblaze/kernel/syscalls/syscall.tbl +++ b/arch/microblaze/kernel/syscalls/syscall.tbl @@ -456,3 +456,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl b/arch/mips/kernel/syscalls/syscall_n32.tbl index 253ff994ed2e..2ef47a546fd3 100644 --- a/arch/mips/kernel/syscalls/syscall_n32.tbl +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl @@ -389,3 +389,4 @@ 448 n32 process_mrelease sys_process_mrelease 449 n32 futex_waitv sys_futex_waitv 450 n32 set_mempolicy_home_node sys_set_mempolicy_home_node +451 n32 fchmodat4 sys_fchmodat4 diff --git a/arch/mips/kernel/syscalls/syscall_n64.tbl b/arch/mips/kernel/syscalls/syscall_n64.tbl index 3f1886ad9d80..6356c0a6cda0 100644 --- a/arch/mips/kernel/syscalls/syscall_n64.tbl +++ b/arch/mips/kernel/syscalls/syscall_n64.tbl @@ -365,3 +365,4 @@ 448 n64 process_mrelease sys_process_mrelease 449 n64 futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 n64 fchmodat4 sys_fchmodat4 diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl b/arch/mips/kernel/syscalls/syscall_o32.tbl index 8f243e35a7b2..d1111edba47e 100644 --- a/arch/mips/kernel/syscalls/syscall_o32.tbl +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl @@ -438,3 +438,4 @@ 448 o32 process_mrelease sys_process_mrelease 449 o32 futex_waitv sys_futex_waitv 450 o32 set_mempolicy_home_node sys_set_mempolicy_home_node +451 o32 fchmodat4 sys_fchmodat4 diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl index 0e42fceb2d5e..0a1c13744c32 100644 --- a/arch/parisc/kernel/syscalls/syscall.tbl +++ b/arch/parisc/kernel/syscalls/syscall.tbl @@ -448,3 +448,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl b/arch/powerpc/kernel/syscalls/syscall.tbl index a0be127475b1..ee23866fa1c8 100644 --- a/arch/powerpc/kernel/syscalls/syscall.tbl +++ b/arch/powerpc/kernel/syscalls/syscall.tbl @@ -537,3 +537,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 nospu set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/s390/kernel/syscalls/syscall.tbl b/arch/s390/kernel/syscalls/syscall.tbl index b68f47541169..d5ce80065ece 100644 --- a/arch/s390/kernel/syscalls/syscall.tbl +++ b/arch/s390/kernel/syscalls/syscall.tbl @@ -453,3 +453,4 @@ 448 common process_mrelease sys_process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 sys_fchmodat4 diff --git a/arch/sh/kernel/syscalls/syscall.tbl b/arch/sh/kernel/syscalls/syscall.tbl index 2de85c977f54..697b914f5c33 100644 --- a/arch/sh/kernel/syscalls/syscall.tbl +++ b/arch/sh/kernel/syscalls/syscall.tbl @@ -453,3 +453,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/sparc/kernel/syscalls/syscall.tbl b/arch/sparc/kernel/syscalls/syscall.tbl index 4398cc6fb68d..79be56831f39 100644 --- a/arch/sparc/kernel/syscalls/syscall.tbl +++ b/arch/sparc/kernel/syscalls/syscall.tbl @@ -496,3 +496,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl index 320480a8db4f..3ab07bd87ea9 100644 --- a/arch/x86/entry/syscalls/syscall_32.tbl +++ b/arch/x86/entry/syscalls/syscall_32.tbl @@ -455,3 +455,4 @@ 448 i386 process_mrelease sys_process_mrelease 449 i386 futex_waitv sys_futex_waitv 450 i386 set_mempolicy_home_node sys_set_mempolicy_home_node +451 i386 fchmodat4 sys_fchmodat4 diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl index c84d12608cd2..17047878293c 100644 --- a/arch/x86/entry/syscalls/syscall_64.tbl +++ b/arch/x86/entry/syscalls/syscall_64.tbl @@ -372,6 +372,7 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 # # Due to a historical design error, certain syscalls are numbered differently diff --git a/arch/xtensa/kernel/syscalls/syscall.tbl b/arch/xtensa/kernel/syscalls/syscall.tbl index 52c94ab5c205..ed47fd3b2293 100644 --- a/arch/xtensa/kernel/syscalls/syscall.tbl +++ b/arch/xtensa/kernel/syscalls/syscall.tbl @@ -421,3 +421,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h index 45fa180cc56a..b7978b3ce3f1 100644 --- a/include/uapi/asm-generic/unistd.h +++ b/include/uapi/asm-generic/unistd.h @@ -886,8 +886,11 @@ __SYSCALL(__NR_futex_waitv, sys_futex_waitv) #define __NR_set_mempolicy_home_node 450 __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node) +#define __NR_fchmodat4 451 +__SYSCALL(__NR_fchmodat4, sys_fchmodat4) + #undef __NR_syscalls -#define __NR_syscalls 451 +#define __NR_syscalls 452 /* * 32 bit systems traditionally used different From patchwork Tue Jul 11 11:25:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 118428 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp406027vqm; Tue, 11 Jul 2023 04:30:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBgYYm0USB8ZJ9AZSWJG8VCX1H6h7ctQHsgH8r9njJzCRdV6pa1NhWxWVOhas2VmLNYMP5 X-Received: by 2002:a17:902:ab56:b0:1b8:954c:1fb with SMTP id ij22-20020a170902ab5600b001b8954c01fbmr24344967plb.7.1689075030082; Tue, 11 Jul 2023 04:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689075030; cv=none; d=google.com; s=arc-20160816; b=khFve4dMGyC4s/4tv8YLEwfzuYHZuFe7W+LinT5w+sR9mvSD1bqpTDsLwFrji1Xen6 +PUfVYms+QER6kMwUsfeSYzYC4w27ivmInPQCNa8QrrrI+42jjQlnKSZirsnyISRLyCx XIyztUbiIWuYvXNH7lX24T+omKcp276GzyBHeymk3QBnOu6lnTvO6cNFQKrrhsmLmqkp hE/jYEcOjIZVPLJGcbR41CyP18kvMQzSagWK7n67TkMwNz4kw+OoNnDAa46rgUPcuMla +aPjCy8OugYONMMFF4f27hO72+LJx3LvKjS0DIGFcrhjSp9XPPOX5Mbl2W2i8NT1bLVf mMpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RYOCE7AFVHPm1pV8r3IQ0VoieCazfRoov54mUwtjGiE=; fh=seYkIZwGhsaZ2mPN9tbwuL3qzBlMHi0iBX9GrZDxiYI=; b=tR54RVWagitYTpeQCSLFQdGia8/M0pYodkkmjE4c5M5sa/znX7C1UMhj/ZDLwxzOPf qAWnw+TrOl3bPn2kUQl2RZdK4Hf//rImepl2PtIqX9w5s7v661fcnwy8YAznZYj4bWjX nCkBNnYKYU+nvdAOSpcHpoM69pewy1dC2+FGNAUpP01D4Gf/1gwpnfFVE0vimi64Jtc3 eCROxv5/MCWQthkDNj5ML/Is43PCaBbJbGgN4eiGp+ATo6uXYBmh0zrP1kRH7a6oUlL2 vjzOsKRXFbyC4jaep9HNX1KYUmcy6FsymmlMHof8YcDmJNdjIPAtKtiOSgRgg9hZxF7x eYTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a633812000000b00557622a044esi1301110pga.805.2023.07.11.04.30.16; Tue, 11 Jul 2023 04:30:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbjGKL32 (ORCPT + 99 others); Tue, 11 Jul 2023 07:29:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231992AbjGKL27 (ORCPT ); Tue, 11 Jul 2023 07:28:59 -0400 Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B34F1709 for ; Tue, 11 Jul 2023 04:28:43 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-x-qLHQFXN3-4IM4VQ4fRJA-1; Tue, 11 Jul 2023 07:27:03 -0400 X-MC-Unique: x-qLHQFXN3-4IM4VQ4fRJA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A8F33C1392B; Tue, 11 Jul 2023 11:27:03 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.45.225.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id C29E0F66B9; Tue, 11 Jul 2023 11:26:50 +0000 (UTC) From: Alexey Gladkov To: LKML , Arnd Bergmann , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk Cc: Palmer Dabbelt , James.Bottomley@HansenPartnership.com, acme@kernel.org, alexander.shishkin@linux.intel.com, axboe@kernel.dk, benh@kernel.crashing.org, borntraeger@de.ibm.com, bp@alien8.de, catalin.marinas@arm.com, christian@brauner.io, dalias@libc.org, davem@davemloft.net, deepa.kernel@gmail.com, deller@gmx.de, dhowells@redhat.com, fenghua.yu@intel.com, firoz.khan@linaro.org, fweimer@redhat.com, geert@linux-m68k.org, glebfm@altlinux.org, gor@linux.ibm.com, hare@suse.com, heiko.carstens@de.ibm.com, hpa@zytor.com, ink@jurassic.park.msu.ru, jhogan@kernel.org, kim.phillips@arm.com, ldv@altlinux.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux@armlinux.org.uk, linuxppc-dev@lists.ozlabs.org, luto@kernel.org, mattst88@gmail.com, mingo@redhat.com, monstr@monstr.eu, mpe@ellerman.id.au, namhyung@kernel.org, paul.burton@mips.com, paulus@samba.org, peterz@infradead.org, ralf@linux-mips.org, rth@twiddle.net, schwidefsky@de.ibm.com, sparclinux@vger.kernel.org, stefan@agner.ch, tglx@linutronix.de, tony.luck@intel.com, tycho@tycho.ws, will@kernel.org, x86@kernel.org, ysato@users.sourceforge.jp Subject: [PATCH v3 4/5] tools headers UAPI: Sync files changed by new fchmodat4 syscall Date: Tue, 11 Jul 2023 13:25:45 +0200 Message-Id: <1d92a38d1f447ef49ff420847faad7bf2bd4e281.1689074739.git.legion@kernel.org> In-Reply-To: References: <87o8pscpny.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771123539015293744 X-GMAIL-MSGID: 1771123539015293744 From: Palmer Dabbelt That add support for this new syscall in tools such as 'perf trace'. Signed-off-by: Palmer Dabbelt Signed-off-by: Alexey Gladkov --- tools/include/uapi/asm-generic/unistd.h | 5 ++++- tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl | 1 + tools/perf/arch/powerpc/entry/syscalls/syscall.tbl | 1 + tools/perf/arch/s390/entry/syscalls/syscall.tbl | 1 + tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/asm-generic/unistd.h b/tools/include/uapi/asm-generic/unistd.h index 45fa180cc56a..b7978b3ce3f1 100644 --- a/tools/include/uapi/asm-generic/unistd.h +++ b/tools/include/uapi/asm-generic/unistd.h @@ -886,8 +886,11 @@ __SYSCALL(__NR_futex_waitv, sys_futex_waitv) #define __NR_set_mempolicy_home_node 450 __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node) +#define __NR_fchmodat4 451 +__SYSCALL(__NR_fchmodat4, sys_fchmodat4) + #undef __NR_syscalls -#define __NR_syscalls 451 +#define __NR_syscalls 452 /* * 32 bit systems traditionally used different diff --git a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl index 3f1886ad9d80..6356c0a6cda0 100644 --- a/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl +++ b/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl @@ -365,3 +365,4 @@ 448 n64 process_mrelease sys_process_mrelease 449 n64 futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 n64 fchmodat4 sys_fchmodat4 diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl index a0be127475b1..ee23866fa1c8 100644 --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl @@ -537,3 +537,4 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 nospu set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl index b68f47541169..d5ce80065ece 100644 --- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl @@ -453,3 +453,4 @@ 448 common process_mrelease sys_process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 sys_fchmodat4 diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl index c84d12608cd2..17047878293c 100644 --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl @@ -372,6 +372,7 @@ 448 common process_mrelease sys_process_mrelease 449 common futex_waitv sys_futex_waitv 450 common set_mempolicy_home_node sys_set_mempolicy_home_node +451 common fchmodat4 sys_fchmodat4 # # Due to a historical design error, certain syscalls are numbered differently From patchwork Tue Jul 11 11:25:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Gladkov X-Patchwork-Id: 118424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp405677vqm; Tue, 11 Jul 2023 04:30:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlHJQbFaxHLfVmDr9LEB5XeO8/4VWWhvKENTqdG8RTtgPOT3Vvr6aCQZAcL5+zOf9LKXR20Y X-Received: by 2002:a05:6a00:2384:b0:668:9bf9:fa8d with SMTP id f4-20020a056a00238400b006689bf9fa8dmr19936422pfc.16.1689074999771; Tue, 11 Jul 2023 04:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689074999; cv=none; d=google.com; s=arc-20160816; b=bQnAqwjreh6Pxt38pSa84lEepvFLtDBtM4kx/fTLZiy9RLHRU1Qa430KfYrSqT47Yq QlqMlH+0XMokMw3q9Q7x5thRYpeXeCKmk/EKsbGmUGNgDeIvIQvs/0xAwIM+RytCJSAg C7UFMNhQ4tPrionRkdSKFTfVLNdrJ1+nsfOdN/ZdfwNk7treB4eUx6NOLsjlvNSNz/El JlSzsXkqU8WTEPHhicPO7ad+Lbi+U+v5p6fQjIFihhSDVDTWe20ojXeUJT1G+MhMtZ5A 5yJti4vvyskppF+TWbZXDaYK4aRlXPXa8Z5TKVgxj1OScC05F/mCZxQwsQTtGOg37GvB PT9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jGQ/tw/a5dQ8uxsjckv04amrzSLEzz6odOAdjrDS5z4=; fh=6ism3Dc4O3S5xaq3Wfu2tj6fXRIbA5d6TtO7Da76gaE=; b=nTPKcsGW+s8McoQ/x6JSX42lxsH153GoinuaCn64C/EiK5qom0w4LuxdmEsrGpFVhG JqLMuj4bsJ3WX4t4izFwA6LDbkNYOSYFYVduDDw9oAEfUEt4K3oPkuT8UDuwVZQiV+PF FF+F9SIVO4rkSWgm7EQrK/zFVv4Ixj+7gzgE2rvqjn1Bp6MCSApfWF2lCmDAvvlUtYHW E4vRXIAN99QEJOci/gC+SJWCCPFPbOcVJr4hz6l4cutOPb9j9OWd1qhWFDTiNbBRMNE7 HjJvi1aKbfUZb0AQqvXOqwZeJNC279+yJKEgNGrzHINWv4Py1yRyxUlAgOvGCBnyzweD Nu9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s34-20020a635262000000b0052c2904e37dsi1271703pgl.362.2023.07.11.04.29.47; Tue, 11 Jul 2023 04:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231874AbjGKL1w (ORCPT + 99 others); Tue, 11 Jul 2023 07:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbjGKL1m (ORCPT ); Tue, 11 Jul 2023 07:27:42 -0400 Received: from us-smtp-delivery-44.mimecast.com (unknown [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0EF1701 for ; Tue, 11 Jul 2023 04:27:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-121-RClLxTYNPgeFdqNoss_6Vg-1; Tue, 11 Jul 2023 07:27:15 -0400 X-MC-Unique: RClLxTYNPgeFdqNoss_6Vg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 154C63815F67; Tue, 11 Jul 2023 11:27:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.45.225.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7857FF66B9; Tue, 11 Jul 2023 11:27:03 +0000 (UTC) From: Alexey Gladkov To: LKML , Arnd Bergmann , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk Cc: James.Bottomley@HansenPartnership.com, acme@kernel.org, alexander.shishkin@linux.intel.com, axboe@kernel.dk, benh@kernel.crashing.org, borntraeger@de.ibm.com, bp@alien8.de, catalin.marinas@arm.com, christian@brauner.io, dalias@libc.org, davem@davemloft.net, deepa.kernel@gmail.com, deller@gmx.de, dhowells@redhat.com, fenghua.yu@intel.com, firoz.khan@linaro.org, fweimer@redhat.com, geert@linux-m68k.org, glebfm@altlinux.org, gor@linux.ibm.com, hare@suse.com, heiko.carstens@de.ibm.com, hpa@zytor.com, ink@jurassic.park.msu.ru, jhogan@kernel.org, kim.phillips@arm.com, ldv@altlinux.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux@armlinux.org.uk, linuxppc-dev@lists.ozlabs.org, luto@kernel.org, mattst88@gmail.com, mingo@redhat.com, monstr@monstr.eu, mpe@ellerman.id.au, namhyung@kernel.org, palmer@sifive.com, paul.burton@mips.com, paulus@samba.org, peterz@infradead.org, ralf@linux-mips.org, rth@twiddle.net, schwidefsky@de.ibm.com, sparclinux@vger.kernel.org, stefan@agner.ch, tglx@linutronix.de, tony.luck@intel.com, tycho@tycho.ws, will@kernel.org, x86@kernel.org, ysato@users.sourceforge.jp Subject: [PATCH v3 5/5] selftests: add fchmodat4(2) selftest Date: Tue, 11 Jul 2023 13:25:46 +0200 Message-Id: In-Reply-To: References: <87o8pscpny.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771123506890644100 X-GMAIL-MSGID: 1771123506890644100 The test marks as skipped if a syscall with the AT_SYMLINK_NOFOLLOW flag fails. This is because not all filesystems support changing the mode bits of symlinks properly. These filesystems return an error but change the mode bits: newfstatat(4, "regfile", {st_mode=S_IFREG|0640, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0 newfstatat(4, "symlink", {st_mode=S_IFLNK|0777, st_size=7, ...}, AT_SYMLINK_NOFOLLOW) = 0 syscall_0x1c3(0x4, 0x55fa1f244396, 0x180, 0x100, 0x55fa1f24438e, 0x34) = -1 EOPNOTSUPP (Operation not supported) newfstatat(4, "regfile", {st_mode=S_IFREG|0640, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0 This happens with btrfs and xfs: $ /kernel/tools/testing/selftests/fchmodat4/fchmodat4_test TAP version 13 1..1 ok 1 # SKIP fchmodat4(symlink) # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0 $ stat /tmp/ksft-fchmodat4.*/symlink File: /tmp/ksft-fchmodat4.3NCqlE/symlink -> regfile Size: 7 Blocks: 0 IO Block: 4096 symbolic link Device: 7,0 Inode: 133 Links: 1 Access: (0600/lrw-------) Uid: ( 0/ root) Gid: ( 0/ root) Signed-off-by: Alexey Gladkov --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/fchmodat4/.gitignore | 2 + tools/testing/selftests/fchmodat4/Makefile | 6 + .../selftests/fchmodat4/fchmodat4_test.c | 151 ++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 tools/testing/selftests/fchmodat4/.gitignore create mode 100644 tools/testing/selftests/fchmodat4/Makefile create mode 100644 tools/testing/selftests/fchmodat4/fchmodat4_test.c diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 90a62cf75008..fe61fa55412d 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -17,6 +17,7 @@ TARGETS += drivers/net/bonding TARGETS += drivers/net/team TARGETS += efivarfs TARGETS += exec +TARGETS += fchmodat4 TARGETS += filesystems TARGETS += filesystems/binderfs TARGETS += filesystems/epoll diff --git a/tools/testing/selftests/fchmodat4/.gitignore b/tools/testing/selftests/fchmodat4/.gitignore new file mode 100644 index 000000000000..82a4846cbc4b --- /dev/null +++ b/tools/testing/selftests/fchmodat4/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +/*_test diff --git a/tools/testing/selftests/fchmodat4/Makefile b/tools/testing/selftests/fchmodat4/Makefile new file mode 100644 index 000000000000..3d38a69c3c12 --- /dev/null +++ b/tools/testing/selftests/fchmodat4/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined +TEST_GEN_PROGS := fchmodat4_test + +include ../lib.mk diff --git a/tools/testing/selftests/fchmodat4/fchmodat4_test.c b/tools/testing/selftests/fchmodat4/fchmodat4_test.c new file mode 100644 index 000000000000..50beb731d8ba --- /dev/null +++ b/tools/testing/selftests/fchmodat4/fchmodat4_test.c @@ -0,0 +1,151 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include "../kselftest.h" + +#ifndef __NR_fchmodat4 + #if defined __alpha__ + #define __NR_fchmodat4 561 + #elif defined _MIPS_SIM + #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ + #define __NR_fchmodat4 (451 + 4000) + #endif + #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ + #define __NR_fchmodat4 (451 + 6000) + #endif + #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ + #define __NR_fchmodat4 (451 + 5000) + #endif + #elif defined __ia64__ + #define __NR_fchmodat4 (451 + 1024) + #else + #define __NR_fchmodat4 451 + #endif +#endif + +int sys_fchmodat4(int dfd, const char *filename, mode_t mode, int flags) +{ + int ret = syscall(__NR_fchmodat4, dfd, filename, mode, flags); + return ret >= 0 ? ret : -errno; +} + +int setup_testdir(void) +{ + int dfd, ret; + char dirname[] = "/tmp/ksft-fchmodat4.XXXXXX"; + + /* Make the top-level directory. */ + if (!mkdtemp(dirname)) + ksft_exit_fail_msg("setup_testdir: failed to create tmpdir\n"); + + dfd = open(dirname, O_PATH | O_DIRECTORY); + if (dfd < 0) + ksft_exit_fail_msg("setup_testdir: failed to open tmpdir\n"); + + ret = openat(dfd, "regfile", O_CREAT | O_WRONLY | O_TRUNC, 0644); + if (ret < 0) + ksft_exit_fail_msg("setup_testdir: failed to create file in tmpdir\n"); + close(ret); + + ret = symlinkat("regfile", dfd, "symlink"); + if (ret < 0) + ksft_exit_fail_msg("setup_testdir: failed to create symlink in tmpdir\n"); + + return dfd; +} + +int expect_mode(int dfd, const char *filename, mode_t expect_mode) +{ + struct stat st; + int ret = fstatat(dfd, filename, &st, AT_SYMLINK_NOFOLLOW); + + if (ret) + ksft_exit_fail_msg("expect_mode: %s: fstatat failed\n", filename); + + return (st.st_mode == expect_mode); +} + +void test_regfile(void) +{ + int dfd, ret; + + dfd = setup_testdir(); + + ret = sys_fchmodat4(dfd, "regfile", 0640, 0); + + if (ret < 0) + ksft_exit_fail_msg("test_regfile: fchmodat4(noflag) failed\n"); + + if (!expect_mode(dfd, "regfile", 0100640)) + ksft_exit_fail_msg("test_regfile: wrong file mode bits after fchmodat4\n"); + + ret = sys_fchmodat4(dfd, "regfile", 0600, AT_SYMLINK_NOFOLLOW); + + if (ret < 0) + ksft_exit_fail_msg("test_regfile: fchmodat4(AT_SYMLINK_NOFOLLOW) failed\n"); + + if (!expect_mode(dfd, "regfile", 0100600)) + ksft_exit_fail_msg("test_regfile: wrong file mode bits after fchmodat4 with nofollow\n"); + + ksft_test_result_pass("fchmodat4(regfile)\n"); +} + +void test_symlink(void) +{ + int dfd, ret; + + dfd = setup_testdir(); + + ret = sys_fchmodat4(dfd, "symlink", 0640, 0); + + if (ret < 0) + ksft_exit_fail_msg("test_symlink: fchmodat4(noflag) failed\n"); + + if (!expect_mode(dfd, "regfile", 0100640)) + ksft_exit_fail_msg("test_symlink: wrong file mode bits after fchmodat4\n"); + + if (!expect_mode(dfd, "symlink", 0120777)) + ksft_exit_fail_msg("test_symlink: wrong symlink mode bits after fchmodat4\n"); + + ret = sys_fchmodat4(dfd, "symlink", 0600, AT_SYMLINK_NOFOLLOW); + + /* + * On certain filesystems (xfs or btrfs), chmod operation fails. So we + * first check the symlink target but if the operation fails we mark the + * test as skipped. + * + * https://sourceware.org/legacy-ml/libc-alpha/2020-02/msg00467.html + */ + if (ret == 0 && !expect_mode(dfd, "symlink", 0120600)) + ksft_exit_fail_msg("test_symlink: wrong symlink mode bits after fchmodat4 with nofollow\n"); + + if (!expect_mode(dfd, "regfile", 0100640)) + ksft_exit_fail_msg("test_symlink: wrong file mode bits after fchmodat4 with nofollow\n"); + + if (ret != 0) + ksft_test_result_skip("fchmodat4(symlink)\n"); + else + ksft_test_result_pass("fchmodat4(symlink)\n"); +} + +#define NUM_TESTS 2 + +int main(int argc, char **argv) +{ + ksft_print_header(); + ksft_set_plan(NUM_TESTS); + + test_regfile(); + test_symlink(); + + if (ksft_get_fail_cnt() + ksft_get_error_cnt() > 0) + ksft_exit_fail(); + else + ksft_exit_pass(); +}