Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp581427imn; Tue, 26 Jul 2022 04:11:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uO3bJGoxOitsmFLpu8QfEYrocawtSbdKuSFV3SjWK0epBZ3e8DjOLll5fw9ih4pRiz8ejI X-Received: by 2002:a17:906:cc48:b0:72a:ff94:d5df with SMTP id mm8-20020a170906cc4800b0072aff94d5dfmr13502684ejb.693.1658833883596; Tue, 26 Jul 2022 04:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658833883; cv=none; d=google.com; s=arc-20160816; b=gssKEFcMF4VK1d9POWsHOoTBSYXUgHprajYtzCwHbWZ3iwokkztHRLPo/4aku0Nu4F rASh9pX9FKjIXc6r06xMHxh2GbvDiEs6lz+sZCG7ZOdFrS5EM+JeiUUMW1cF0tzBaNNi C4RsIA7VRbqr4m3k+OgaLpywimj19uwLBwfPKvlJAti++jPCNiQxZcJYh7qDlsKUhamm Kb6QBuS4VmK58vpuWFEWSI4Mz8+suKcyegO+8DRG6aa4sn8vs3Xov7bLEA2M1AacnUMb n3nYBAMo+BlN71GSoOx7+F/Dtwt8NpAHlWOrti06cKyqoxkoUKjjG7+xmM2GfQt+6Ui0 FjEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=DlwwH6JhaE6dOJB4zz8d3PCKM7SP103SiMtUfD5qxKo=; b=DKAakQgxdrHpzNz2J6L6yUhdqhhIcVycuo/oXrLazZr3sPLbx9JMZHhpCv2L5pLNxn s75uvYKH32mHHzxvBo8PvaxNgblhe3GgzKyu4LziLFEIhemHHV49pPRxr/ZeLdc3gX/+ CdxVJAMaHXGCr/KHwd7FsI59wqySAP/WGIkYlPzWDfiEU8p6IlyF6jIRE61blpys+iuX jKw9WzjCO+7dKOlYmCcKfu5f1btUEykVyYaHN9lF4FTM5tkF/UvOe6+CW3oOGKN5XCIs 2geRhgQ5du25CDxdG1cKFp0u4jthz5aeMvXNfPL03t/6hV8NAkPO43g+mnJW+EjfVpED Y4yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NTMhhs0O; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a1709064e5200b0072a431211a5si13070147ejw.440.2022.07.26.04.10.53; Tue, 26 Jul 2022 04:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NTMhhs0O; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238572AbiGZLGh (ORCPT + 99 others); Tue, 26 Jul 2022 07:06:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231335AbiGZLGh (ORCPT ); Tue, 26 Jul 2022 07:06:37 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 941FF2F00E for ; Tue, 26 Jul 2022 04:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658833595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DlwwH6JhaE6dOJB4zz8d3PCKM7SP103SiMtUfD5qxKo=; b=NTMhhs0OyQ1HdFK3ldgkkJV+9fLYA1LMxtOKzbXhenZKP8VA4FrEjths140AwMkrraEqkI W3I0b/RLwXkIJq0ed4VQc53rlsVhg/mvND6RYVZoa6rmWAz0cvTn+nW7MVFb81hhAbPOr4 wcUnrZ4DNVOKJyAatWaCgsQgDDPto+8= 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-272-aLGBITHRNXKWI2wEyPYLVQ-1; Tue, 26 Jul 2022 07:06:34 -0400 X-MC-Unique: aLGBITHRNXKWI2wEyPYLVQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 019B23C22880; Tue, 26 Jul 2022 11:06:34 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.56]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A296401473; Tue, 26 Jul 2022 11:06:32 +0000 (UTC) From: Florian Weimer To: "Jason A. Donenfeld" Cc: Mark Harris , libc-alpha@sourceware.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH v2] arc4random: simplify design for better safety References: <20220725225728.824128-1-Jason@zx2c4.com> <20220725232810.843433-1-Jason@zx2c4.com> Date: Tue, 26 Jul 2022 13:06:31 +0200 In-Reply-To: (Jason A. Donenfeld's message of "Tue, 26 Jul 2022 12:41:13 +0200") Message-ID: <87bktci154.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham 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-crypto@vger.kernel.org * Jason A. Donenfeld: > Not in current kernels, where it always returns at least PAGE_SIZE bytes > before checking for pending signals. In older kernels, if there was a > signal pending at the top, it would do no work and return -ERESTARTSYS, > which I believe should then get restarted by glibc's syscaller? glibc does not handle ERESTARTSYS, it's a kernel-internal error code that's not exported in UAPI headers and must not leak to userspace (except perhaps via ptrace). I believe restarts are handled in the kernel signal code, by tweaking the program counter. Looking at that, ERESTARTSYS gets translated to EINTR for !SA_RESTART system calls: /* Are we from a system call? */ if (syscall_get_nr(current, regs) != -1) { /* If so, check system call restarting.. */ switch (syscall_get_error(current, regs)) { case -ERESTART_RESTARTBLOCK: case -ERESTARTNOHAND: regs->ax = -EINTR; break; case -ERESTARTSYS: if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { regs->ax = -EINTR; break; } fallthrough; case -ERESTARTNOINTR: regs->ax = regs->orig_ax; regs->ip -= 2; break; } } (arch/x86/kernel/signal.c) Thanks, Florian