From patchwork Fri Apr 3 21:12:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 38748 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 5D94B385DC03 for ; Fri, 3 Apr 2020 21:12:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5D94B385DC03 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: ZjblpRe7GGvrSbhK5dUEOiuufqWpe9K8kIhAtFqRJh8KqYQGkoT4mkoKc0d8gx5GA1nYyEmj+H Ji5OoaBz3HpAxEzBfat3vKujnSCs3ip4YDQdq0xLGpMzHhMUY+XuiucedZ1mxjDWoR2edimUzj oz8M2uce6MwU0cbNyipDT/yGJPdcuMN8UgS5A/V9X5lW+UFD/uQM5OOurEd/bLlJIMUz2GCywt 9+iw2m4zi3j1ZvprAl9IV/PPreBR+3zfFgyFQjROMFEZQwidBNngVtz378nVAeUe87ac9VY6pb fuQ= X-IronPort-AV: E=Sophos;i="5.72,341,1580803200"; d="scan'208";a="47432566" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 03 Apr 2020 13:12:35 -0800 IronPort-SDR: 6r4ZcOG+rGkW9wCWWDNhjuZMPOTcr66Tk57Mqv004H8kaw6YozrfyPVmimbWeJO8U5eJerS0B9 1kt/hzcPmW2rEe0Ye6z/0rW97AfwVVkiDZKB7SyuZfL68Fln5bIOo79ngusqQcmpLeOfeZeML9 fxKGif9fUe+JUowtfHNgPrizGUZ2BjkPx3FgFWuVU0gnTA4ewJcdYA8yWqhdz+c/vnn8sLa7gA jKki3WzLNTWW7T2pyI8VpqsY2nIbismaPCAwUI0+jiZemA5f4tPQsrhsWcdnY5diJif6UgLytc ze0= Date: Fri, 3 Apr 2020 21:12:30 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Subject: Add GRND_INSECURE from Linux 5.6 to sys/random.h Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-21.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2020 21:12:37 -0000 This patch adds the GRND_INSECURE constant from Linux 5.6 to glibc's sys/random.h. This is also added to the documentation. The constant acts as a no-op for the Hurd implementation (as that doesn't check whether the flags are known), which is semantically fine, while older Linux kernels reject unknown flags with an EINVAL error. Tested for x86_64. Reviewed-by: Adhemerval Zanella diff --git a/manual/crypt.texi b/manual/crypt.texi index c41b911c8f..af23dd7847 100644 --- a/manual/crypt.texi +++ b/manual/crypt.texi @@ -301,6 +301,9 @@ booted and the randomness source has not yet been initialized. @item GRND_NONBLOCK Instead of blocking, return to the caller immediately if no data is available. + +@item GRND_INSECURE +Write random data that may not be cryptographically secure. @end table Unlike @code{getentropy}, the @code{getrandom} function is a diff --git a/stdlib/sys/random.h b/stdlib/sys/random.h index b351ef5c8c..1df6e9b844 100644 --- a/stdlib/sys/random.h +++ b/stdlib/sys/random.h @@ -25,6 +25,7 @@ /* Flags for use with getrandom. */ #define GRND_NONBLOCK 0x01 #define GRND_RANDOM 0x02 +#define GRND_INSECURE 0x04 __BEGIN_DECLS