From nobody Tue Apr 26 16:37:15 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 268EF199B3A1; Tue, 26 Apr 2022 16:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Knnbb61LDz4hqn; Tue, 26 Apr 2022 16:37:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650991036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0uVxNq+04Rd9MJkL1t64jGScyTjp78KN/OJy23IyELs=; b=Du7oi+WqBwos3ejIfk10TutP2hMUqsjzIW4WAi7TB0BYba+2lDb522AbjeooicJUKPn2no BhkR7MKjtPFFRd3sPh4i6sY3Iee/s81CaMRlF58ytSZou7EvdZ9zER21H1h04ZbMKXOW2l iNBLuxGkPIEkH0dk/Eq6o1qP8F473OWt4Go41jwAuekfczIoBieLmyobnuU9u6pe0kbd4Z C62ufq5bhz8b4Q1ibp9njIp8PbT2FLTbJYrg9gPsQ67V6so7UZmuMVj8Fn0K0lHCndE+S0 dqqQQplPy/I+w7wdrnslgPf6gaFhWzbvzLRs7+DoXy5t1rRYvymF+04sJy0ymg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6E58712E28; Tue, 26 Apr 2022 16:37:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23QGbFcL065435; Tue, 26 Apr 2022 16:37:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23QGbFqO065434; Tue, 26 Apr 2022 16:37:15 GMT (envelope-from git) Date: Tue, 26 Apr 2022 16:37:15 GMT Message-Id: <202204261637.23QGbFqO065434@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 5171ed79f6d1 - main - linux(4): Copyout pselect timeout. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5171ed79f6d1fc3948a7ebfb32b02d698224c29b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650991036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0uVxNq+04Rd9MJkL1t64jGScyTjp78KN/OJy23IyELs=; b=qUnpHenjONsRJX/m8AA7AsCU96hfUK6A2+kLupKdD7qBrC13cN8KxOE5a/QRap07029F1O KJ47SCiPAE/RjYel70fWuTOzqF/DFeDOKKE44BetgAyKvwcPwV6rAon8HWSH4qsJCJHHSw n0KBhZLv7fdi7XFAY+pP4wrFK5wuB4em05d4aA29YGwlRSVoBclDN86q4Cx48uqVG1Azij 1uGiFIsw+/MbiF1SKQqHehZZ741etmNwLqVUKumGGmUjeqcBK8XlF0Lik8aARf6J4WlVSj idxKeX2hJ3PBTVoERTZFz3Ks+HKyLjaM8opAsWPCMt1aLiWgWjCJ5GAE0ioALQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650991036; a=rsa-sha256; cv=none; b=bcy5BEm08PIvKP+2l+TOtzKDM7DQvXnHbUccKL3pb3QHIbMsrYOVYG2zXGRVQ6Re63xLqh XxgNqYAwCtXPRyjhsmrvbk8J3YhD0akE0YBsh6/hGKXgysRP02bfXWYi7Lwo/5gImcWIR7 yIkG+qghMbMTtULLGwn6adbvv8yAtJabmFASoRD6VCTwrCuGkDjZrJQrvTnv0RMqQyJdqJ Z1Tkumm9Uq6ccRWo4YdHvMJTRvTVUNivcy1GaPFcZEot+lKw8Vu8EDIlaHHvlYLd536+M2 zfdHbVFMF/vSlhSd9ehUIE2/4oum1A/uYGx5d6YCaDVJT7kC8LdF2hkMvjFLmA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=5171ed79f6d1fc3948a7ebfb32b02d698224c29b commit 5171ed79f6d1fc3948a7ebfb32b02d698224c29b Author: Dmitry Chagin AuthorDate: 2022-04-26 16:35:56 +0000 Commit: Dmitry Chagin CommitDate: 2022-04-26 16:35:56 +0000 linux(4): Copyout pselect timeout. According to pselect6 manual, on error timeout becomes undefined, by fact Linux modifies the timeout and ignore EFAULT error if so. MFC after: 2 weeks --- sys/compat/linux/linux_misc.c | 46 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 252c6e0737c0..8a9e34d6cae3 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -2379,7 +2379,7 @@ linux_pselect6(struct thread *td, struct linux_pselect6_args *args) { struct l_timespec lts; struct timespec ts, *tsp; - int error; + int error, error2; if (args->tsp != NULL) { error = copyin(args->tsp, <s, sizeof(lts)); @@ -2394,13 +2394,11 @@ linux_pselect6(struct thread *td, struct linux_pselect6_args *args) error = linux_common_pselect6(td, args->nfds, args->readfds, args->writefds, args->exceptfds, tsp, args->sig); - if (error != 0) - return (error); if (args->tsp != NULL) { - error = native_to_linux_timespec(<s, tsp); - if (error == 0) - error = copyout(<s, args->tsp, sizeof(lts)); + error2 = native_to_linux_timespec(<s, tsp); + if (error2 == 0) + copyout(<s, args->tsp, sizeof(lts)); } return (error); } @@ -2452,21 +2450,17 @@ linux_common_pselect6(struct thread *td, l_int nfds, l_fd_set *readfds, error = kern_pselect(td, nfds, readfds, writefds, exceptfds, tvp, ssp, LINUX_NFDBITS); - if (error == 0 && tsp != NULL) { - if (td->td_retval[0] != 0) { - /* - * Compute how much time was left of the timeout, - * by subtracting the current time and the time - * before we started the call, and subtracting - * that result from the user-supplied value. - */ - - microtime(&tv1); - timevalsub(&tv1, &tv0); - timevalsub(&utv, &tv1); - if (utv.tv_sec < 0) - timevalclear(&utv); - } else + if (tsp != NULL) { + /* + * Compute how much time was left of the timeout, + * by subtracting the current time and the time + * before we started the call, and subtracting + * that result from the user-supplied value. + */ + microtime(&tv1); + timevalsub(&tv1, &tv0); + timevalsub(&utv, &tv1); + if (utv.tv_sec < 0) timevalclear(&utv); TIMEVAL_TO_TIMESPEC(&utv, tsp); } @@ -2480,7 +2474,7 @@ linux_pselect6_time64(struct thread *td, { struct l_timespec64 lts; struct timespec ts, *tsp; - int error; + int error, error2; if (args->tsp != NULL) { error = copyin(args->tsp, <s, sizeof(lts)); @@ -2495,13 +2489,11 @@ linux_pselect6_time64(struct thread *td, error = linux_common_pselect6(td, args->nfds, args->readfds, args->writefds, args->exceptfds, tsp, args->sig); - if (error != 0) - return (error); if (args->tsp != NULL) { - error = native_to_linux_timespec64(<s, tsp); - if (error == 0) - error = copyout(<s, args->tsp, sizeof(lts)); + error2 = native_to_linux_timespec64(<s, tsp); + if (error2 == 0) + copyout(<s, args->tsp, sizeof(lts)); } return (error); }