From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 755A23858401 for ; Wed, 3 Apr 2024 17:26:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 755A23858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 755A23858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712165207; cv=none; b=Gjp3meCU8GtSTiq0xJXx1YbDKqyyjxzR9mQGeCbfcCOf/XTPlHPK1hM0FXX46FtrveI3i3nxkPvFjDqaUduhp4qKAktwB5rs3JQV0sebixaWZchFpiLKGzZNYo49K7Y9HgWJPDLk36HrpRshpJw1r6WZW+VZNpxz7IcfehS5BqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712165207; c=relaxed/simple; bh=q1SeVFDnk4U8qmGtDq002jcW5E7wQrJmsToVWYdYjw0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=b73tiUuV8c/9hF6vKF6N+ao1BWjJYtWhlWwJt/WXIdwWKEj3FJLSSHZiHzFPR0uKdVTYDDAHpb/IemFVIOw3RbQ4cdPsVCyZPNLlrZvFYSCTp9nl8JEMnUPLCZkPunZpFUlfz/IMvOADuA6m5aQRgsBC1yCmrQNm3HEXCPodxew= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e6afb754fcso15542b3a.3 for ; Wed, 03 Apr 2024 10:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712165202; x=1712770002; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=SQFpgVKjKbaHyu99xbJG0mQC0HDVGLipM/RcbGpv4T8=; b=Fin8n0gdjGT8d2NWQ8SqLuZWzkKz44N3oS2v0dJ6/3Gc1eSSKuRFVSxKL2kCGjD9Jt LIX6TpBrcqcbrllX7ROYwPjKkrq8FypzuX1v2MvnLdCVCnQy957Z3nNpwOlqhaWLpTUB C+O3vJmNdCaTl61mbIPOGNpSHlcZQ71JvqgvCezAJ+sOfyyKieTppizowqgen8bvGEhZ 2TJqYOsenYy1uHLkLU7KnU7cNrERaYww2k2/BL6/eNXc28EEo02uyw0+aXDvKkGeIW0K cwnqIZfB0XheMZxsk1GkJrTBa9TUaMt1rW3GBhN/LdDGTRBGFuyzgA2YJofVSMhE12d0 DJhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712165202; x=1712770002; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SQFpgVKjKbaHyu99xbJG0mQC0HDVGLipM/RcbGpv4T8=; b=r6V0eMBFdPs8myzwBZZDn5B6NHuVbOWP+2QMx5+WB1HO5So8PiToixKrGi9wx6XoM+ +oS4cbwt+vFGsmNKf5wodt/f+yVsqFfVYDmDxCmrf0RJUHcVY9+iQMP9P3DeWS/8OvIO aNHTMmx5xQ0//GP3K1jMu3Tooua1Ha4pxXN1TwyO2LSNzOmmfdC8TNW6Yf5Ez0ZWMW1T 1C98EJMVsbG7wcPYXYYNL4jqOVNtYrGf7F7E2hW43vGBS2n4380iwHEP0Hj7U+yvSN8X wl93ejoLYPtxorhG/cvGjOoTRBqi7ZjWlUr6L+p9REOJoGBt256UPpqfuxnjy9R7Dolz 1yNQ== X-Forwarded-Encrypted: i=1; AJvYcCXJ/dD6XfTEBJ+8xkWr0N1WmIDu1o0y3J8jVKFCcLn22Bmp+5fUSoaYkH/zOqU0wgpmC77XHVyBJo0koZ101WFW7ssFSvR8UMwB X-Gm-Message-State: AOJu0YxaPcFdyttqZLVhXsIb9a1E8SbPfNteXRpss4viuPyU0g7TCXnG 8oXNeoyAaAV70nV3gr6axrMoPRd3aG0QXjjiIgD6KnAxeNINTRvf9lL9U29Ipatl/LbGNYwWdXI e X-Google-Smtp-Source: AGHT+IEiDUgCoIDiZrkzxGZMNg8dd/2fR6SkcANQ4jjWYSIZgu+UNERO2maS8R44gf12dCUsqzHBCQ== X-Received: by 2002:a05:6a00:6c8c:b0:6ea:8604:cb1e with SMTP id jc12-20020a056a006c8c00b006ea8604cb1emr196545pfb.19.1712165202371; Wed, 03 Apr 2024 10:26:42 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c3:b18e:40af:99bf:ac4a:d5af? ([2804:1b3:a7c3:b18e:40af:99bf:ac4a:d5af]) by smtp.gmail.com with ESMTPSA id k17-20020aa788d1000000b006e5af565b1dsm11959490pff.201.2024.04.03.10.26.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 10:26:41 -0700 (PDT) Message-ID: Date: Wed, 3 Apr 2024 14:26:39 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arc4random: fix getrandom fallback to /dev/urandom To: Anthony Iliopoulos , libc-alpha@sourceware.org References: <20240403165523.23129-1-ailiop@suse.com> Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20240403165523.23129-1-ailiop@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 03/04/24 13:55, Anthony Iliopoulos wrote: > arc4random_buf relies on the errno of getrandom_nocancel to fallback to > /dev/urandom, but getrandom_nocancel returns a status code instead of > the syscall errno (-ENOSYS) so it breaks the expectation and thus the > fallback in cases where a kernel does not support the getrandom syscall. > > Commit 609c9d0951da ("malloc: Do not clobber errno on __getrandom_nocancel > (BZ #29624)") changed __getrandom_nocancel from INLINE_SYSCALL_CALL to > INTERNAL_SYSCALL_CALL and modified arc4random_buf to rely on the return > status instead of errno. > > Commit 5a85786a9005 ("Make __getrandom_nocancel set errno and add a > _nostatus version") changed __getrandom_nocancel back to > INLINE_SYSCALL_CALL and added a __getrandom_nocancel_nostatus variant > that calls via INTERNAL_SYSCALL_CALL, but this broke the fallback of > arc4random on kernels where the getrandom syscall is not available. > > Fix it by calling __getrandom_nocancel_nostatus from arc4random_buf so > that the fallback works again. > > Signed-off-by: Anthony Iliopoulos > Fixes: 5a85786a9005 ("Make __getrandom_nocancel set errno and add a _nostatus version") It is a user-visible change, could you open a bug report so we can backport it 2.39? The patch looks good to me. > --- > stdlib/arc4random.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/stdlib/arc4random.c b/stdlib/arc4random.c > index 3ae8fc130234..9b6a6ee85150 100644 > --- a/stdlib/arc4random.c > +++ b/stdlib/arc4random.c > @@ -42,7 +42,7 @@ __arc4random_buf (void *p, size_t n) > > for (;;) > { > - l = TEMP_FAILURE_RETRY (__getrandom_nocancel (p, n, 0)); > + l = TEMP_FAILURE_RETRY (__getrandom_nocancel_nostatus (p, n, 0)); > if (l > 0) > { > if ((size_t) l == n)