From nobody Fri Jun 17 19:39:24 2022 X-Original-To: dev-commits-src-all@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 A7B9085C0CD; Fri, 17 Jun 2022 19:39:25 +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 4LPq9n0XLNz3Qxt; Fri, 17 Jun 2022 19:39:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494765; 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=NF2qE/DMcJORK0tjv8vlkJAQfXET/lBwtnKRiGrc/+U=; b=UagZR0givhuvBkaq+yAEXxB0CwVblWSzHBzGQraDXwLudwz7BX+ZhxCL/0LBCqdB7PTczn A9Y5XL17FaJxEqzUaot3AFCBnKxwdXYQ8vPzouonTbddVKj0FmCE/t9kIvu8s3gHFo4wZB rqChaRGx4fbdaXpO/GxMcxeACkMZM/KO6aBJTwR5SdGuHQdv4E9jgojT2xI1GirU6lsck2 9HxFoy91Lno/N8d611tSyN7ECGBUYvjF1aT+op0S7siuVoupdQJhkQn2E2AKERsb1PfyR2 a1Dei6+9CvTf1LlwB2O2bya1lp/XZIsBgJKKYYxrM1rs7J7Lm+62QQv6QSS+dA== 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 2D40225C54; Fri, 17 Jun 2022 19:39:24 +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 25HJdOD1015961; Fri, 17 Jun 2022 19:39:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJdOQU015960; Fri, 17 Jun 2022 19:39:24 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:39:24 GMT Message-Id: <202206171939.25HJdOQU015960@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: c78e5c4c6ac3 - stable/13 - linux(4): Copyout pselect timeout. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: c78e5c4c6ac358a05195b249b65a1a42c4291c03 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494765; 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=NF2qE/DMcJORK0tjv8vlkJAQfXET/lBwtnKRiGrc/+U=; b=jgfLCfOJ+x447yfRQJginog93EVfMQbZRVLmKpET6vXYT1VWrkxcPANHLvnk6ZSAFEoRxp 4A+2MCj415kyvenGkY7Cs+IEY/H9SVPsFmB0YrqmloPHcHKUYDseP+mYcRMLw87TiNzTRo a4+9feWKgl9P3lrJTVe2QGA86R9XjwlJCW1I+bPJUxsJOX22D+X58jW8pYlStwx0c582Mp 7RYcdkSzDgH2bodYjgmad2eng9igbNYXnkxjOKvVEi7PGb3jsrnrSuzylHxn2sSRXEHHr5 9ewnQ7Pz9D+aO6Ux3qu9iipdVI+GVXnVTAEV57MrTk1lIrOipubq6BFY3J3HBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494765; a=rsa-sha256; cv=none; b=b29X5M4Ix9ahPmCvXDJflHMMtjmtFMRG4RUhpIFadl5stkDJacHayVvOmPOWCO/NE93LQP /Fg5sNDJouOupEy8IqlXJJIv7ixCzCvQkbPY4Up4IJ94AOWY2PBSt4wBWSwT8Z/hIJba86 2DTeD+x6ifNvKRJa02GbIq+AwFx/vfTMwc9OPnnRj4LGg1+phdRCh5WrRqyrNAWMOqD7Vi AoJO2M2bwY3ojwAzbVu9XhVHURRHU0VVipuYwchDjUwGgWll95QLpPGPcK2eKuNjxFUTgr Jk6QQZj64g0q3shj8XxhbdEIVhlBaVvQoCf8xUHvRuRJZBpv345+Qvnpl10E4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c78e5c4c6ac358a05195b249b65a1a42c4291c03 commit c78e5c4c6ac358a05195b249b65a1a42c4291c03 Author: Dmitry Chagin AuthorDate: 2022-04-26 16:35:56 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:34:04 +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 (cherry picked from commit 5171ed79f6d1fc3948a7ebfb32b02d698224c29b) --- 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 096bbcbf0008..ff8c1b26d1d8 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -2386,7 +2386,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)); @@ -2401,13 +2401,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); } @@ -2459,21 +2457,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); } @@ -2487,7 +2481,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)); @@ -2502,13 +2496,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); }