From patchwork Tue Dec 17 18:29:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 1211630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108156-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jrtc27.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="k+l4AaBC"; dkim=pass (1024-bit key; unprotected) header.d=jrtc27.com header.i=@jrtc27.com header.b="C3sag9fj"; 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 47cmrp4H2fz9sPK for ; Wed, 18 Dec 2019 05:29:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=oA/ fuC94dgThPztBkUMpFK5lshiIIyD96hPBPGL9YMoH6af6EIrEMXHu3YBaI2v5+KQ kBgQFPskshG2pQaDZCIP8e17K6vq8C95XQvuDl+JnmDgLzKvrNDvnsumECCtSbfN 5rTrs4WkGgbS8rqrkGOSkHhPXTb6vfanT+RpX7Uw= 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:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=m15opay4q jSPh0INDg9zOY8Piak=; b=k+l4AaBCkAhpMZj3JKeOZAVR5mEMHJ/a8Pa/6aF+t OCuZeqZLpfcBe6hjsMCCQNZnx5yZWOmMRXF4vFmRjW4VHxIDEYJ1xse6DbvjOn+F Lh//4iB49tjecH8HxaouPFCZu68s/Tt+yaCsANDmc/szeVU5A6sUz0gbsqhXYW7h Uo= Received: (qmail 41215 invoked by alias); 17 Dec 2019 18:29:38 -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 41204 invoked by uid 89); 17 Dec 2019 18:29:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 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 autolearn=ham version=3.3.1 spammy=HX-Gm-Message-State:APjAAAVJ, HContent-Transfer-Encoding:8bit X-HELO: mail-wr1-f67.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7V1aHGzS9PQkxu8iCN6IrwBY5y11ZvAW1/JLaBdVXLI=; b=C3sag9fjJVw7Ch6fhpJReOSckSqOwD5yhAnKuhSjv6IPcANmEjq5ur8gufVTne3FWu /WS8Rp6sNUbiQ91SZ363jBOX1ADnoQNJTo++0IjOzdGsKltst/j/F1gYqczGauSV+UMJ EHqUy2gfuyBw8wXmAUena8uhxMxyZlDgucOCU= From: James Clarke To: libc-alpha@sourceware.org Cc: James Clarke , Samuel Thibault Subject: [PATCH] hurd: Make getrandom honour GRND_NONBLOCK Date: Tue, 17 Dec 2019 18:29:29 +0000 Message-Id: <20191217182929.90989-1-jrtc27@jrtc27.com> MIME-Version: 1.0 * sysdeps/mach/hurd/getrandom.c (__getrandom): Open the random source with O_NONBLOCK when the GRND_NONBLOCK flag is provided. --- sysdeps/mach/hurd/getrandom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/sysdeps/mach/hurd/getrandom.c b/sysdeps/mach/hurd/getrandom.c index 8bf42aa40d..aac9c6f8c6 100644 --- a/sysdeps/mach/hurd/getrandom.c +++ b/sysdeps/mach/hurd/getrandom.c @@ -27,13 +27,17 @@ ssize_t __getrandom (void *buffer, size_t length, unsigned int flags) { const char *random_source = "/dev/urandom"; + int open_flags = O_RDONLY | O_CLOEXEC; size_t amount_read; int fd; if (flags & GRND_RANDOM) random_source = "/dev/random"; - fd = __open_nocancel(random_source, O_RDONLY | O_CLOEXEC); + if (flags & GRND_NONBLOCK) + open_flags |= O_NONBLOCK; + + fd = __open_nocancel(random_source, open_flags); if (fd == -1) return -1;