From patchwork Wed Sep 6 15:30:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 810681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84268-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="oaB0c1PD"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xnSGb0LS8z9t3Z for ; Thu, 7 Sep 2017 01:31:02 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=toBTHCVbxqKOJ3v8f++bI2Ms/hNlg 6DzmHpAc2O6zYscJv1PdedavPKILCsahRWsitRIiKbuPvKMlf29nqfjJfUSp05Iy Qp0ko2k/FNtXFcT6QzocHXFa4OVU2nePY0bteT9PujMRf8l/Ym1/Wj+LDMb4BrWw c5WnxUMGymt2Qg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=Yz6r9EdiyIPRzim2mxMMTfzoSgM=; b=oaB 0c1PDTxhAqdx1UYFVXZKupm0RsnOl970+iUTLJi1G9OvDFtHZE91IiTXrOfJwfi2 3IUZJ77m78jSoebqfBmc6DeWNCCD6fXo5rtTN2w0XwooDaWeVhzxnHsvYmIumK1d uyVYygj4dGH03lKkujL/Kl8+YPYadr/JoTssmjL4= Received: (qmail 116720 invoked by alias); 6 Sep 2017 15:30:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116698 invoked by uid 89); 6 Sep 2017 15:30:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:2919, 1031 X-HELO: relay1.mentorg.com Date: Wed, 6 Sep 2017 15:30:47 +0000 From: Joseph Myers To: Subject: Add fcntl sealing interfaces from Linux 3.17 to bits/fcntl-linux.h Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) While reviewing Linux 4.13 for glibc header changes needed, I noticed that bits/fcntl-linux.h was missing F_ADD_SEALS etc. from Linux 3.17. I didn't find any discussion indicating this omission is deliberate. Now, these interfaces can only be used with file descriptors created with memfd_create, and we don't have a memfd_create wrapper in glibc (a patch was submitted in October 2014, albeit without documentation / tests, and discussions continued over the next few months, but without consensus on whether to add the interface - and we still lack any general consensus on syscall wrappers), but I don't think that's a reason to exclude the constants from bits/fcntl-linux.h (especially as the header does not look compatible with simultaneously including linux/fcntl.h). (Some of those 2014/2015 discussions raised concerns about difficulty using the memfd_create / sealing interface, but those seem to me more like a question of whether it should be part of the OS-independent GNU API - in my view, even fairly specialized syscalls ought to have wrappers added to glibc if not obsolescent, but there may be cases where we only want to include them in the Linux-specific API and anything in the OS-independent GNU API should be different - rather than being relevant to whether constants for use with fcntl should appear in headers.) 2017-09-06 Joseph Myers * sysdeps/unix/sysv/linux/bits/fcntl-linux.h [__USE_GNU] (F_ADD_SEALS): New macro. [__USE_GNU] (F_GET_SEALS): Likewise. [__USE_GNU] (F_SEAL_SEAL): Likewise. [__USE_GNU] (F_SEAL_SHRINK): Likewise. [__USE_GNU] (F_SEAL_GROW): Likewise. [__USE_GNU] (F_SEAL_WRITE): Likewise. diff --git a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h index 0cd0a5d..fc65fc2 100644 --- a/sysdeps/unix/sysv/linux/bits/fcntl-linux.h +++ b/sysdeps/unix/sysv/linux/bits/fcntl-linux.h @@ -202,6 +202,8 @@ # define F_NOTIFY 1026 /* Request notifications on a directory. */ # define F_SETPIPE_SZ 1031 /* Set pipe page size array. */ # define F_GETPIPE_SZ 1032 /* Set pipe page size array. */ +# define F_ADD_SEALS 1033 /* Add seals to file. */ +# define F_GET_SEALS 1034 /* Get seals for file. */ #endif #ifdef __USE_XOPEN2K8 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with @@ -271,6 +273,14 @@ struct f_owner_ex }; #endif +#ifdef __USE_GNU +/* Types of seals. */ +# define F_SEAL_SEAL 0x0001 /* Prevent further seals from being set. */ +# define F_SEAL_SHRINK 0x0002 /* Prevent file from shrinking. */ +# define F_SEAL_GROW 0x0004 /* Prevent file from growing. */ +# define F_SEAL_WRITE 0x0008 /* Prevent writes. */ +#endif + /* Define some more compatibility macros to be backward compatible with BSD systems which did not managed to hide these kernel macros. */ #ifdef __USE_MISC