From nobody Fri Jun 17 19:40:13 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 228FC85CC12; Fri, 17 Jun 2022 19:40: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 4LPqBk6wZTz3hKL; Fri, 17 Jun 2022 19:40:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494815; 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=AQnW3WPlohWb+RQnSde1kWzSFxFNpdWqmpiIjwJX7YU=; b=F4mrBThDqGCWQUFwBi9MgCVNBojkqqDTenfkppWFZ+NiuDHM59Wc0qK5ZL3ILLy5mgaHyB F376gxywl7uSOAAL7l0PoOkyRCd2QwgaJTfVNA65fnGfxAUYUXdXZrQW37XWerMb1q9kVU F5tCFExuUQCMnhB559RbxL8rTJ/vuH4LGVlFxggJoRqmE8XUwzR+Uftzu/bxkfmEnu3CHa WKdvezndO8H7B/jfg/FtC3QFympzVSuqW/1UIg3w1utVEhTCfwHppklPqXxkxakFhPrWgf YwPAzPCNpyHwqpmXPkKSShZdtCR3BuIyVp23z39/JWVFx8DsVKYWLQkDFpxN4g== 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 A27DC25D99; Fri, 17 Jun 2022 19:40:13 +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 25HJeDCZ021623; Fri, 17 Jun 2022 19:40:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJeD7s021617; Fri, 17 Jun 2022 19:40:13 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:40:13 GMT Message-Id: <202206171940.25HJeD7s021617@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: 800b5aafa3a8 - stable/13 - linux(4): Fixed offset miscalculation in the preadv/pwritev syscalls. 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: 800b5aafa3a801fe3a7bf3f0dd78fbc33e7e6ba1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494815; 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=AQnW3WPlohWb+RQnSde1kWzSFxFNpdWqmpiIjwJX7YU=; b=aIFhpQdIZBpDhT3uHqwhMngth97CpWYPf+Jjl74e0riyfYVo1MW1pY/JTkxchOBkR2YvEY 9rNZ8VuqUnuw3271bR3rwhC+ZdNeI1MNGWL+0Z4zgQjqqgguNfX34JkLUEN7lkPGMXYR7I AbKtl0jTX20CmqwpNCsJ+Io0GuPRYC15TEsm6Ee6ZwZ+MvmB+9oaf6B0BCFJyUltq7wkzs 9/0zn3z0G18yIVnUpEgiLp+fOkt/FTRzhxQ+WgkIj8CiRKQpmEM8hSizBJui83K5xqdT+Y l65nx5oILC598ONNN25Pp5vwAD7/TMOhakVdb2hic9Or/VNDTkFYDfRjpNlc/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494815; a=rsa-sha256; cv=none; b=J+jxWXvId3X9npvIOFWwwJA7g9FlxEsk9cyQ8areuIuRHlTSlexI1tsNCpBVm3VozW/ryL 91/bkx/RWDIyj+WnRiet0e4ul04CJ7KT0RBQSFzc6NrG+9YF/q/a9yJZl3QsS268HbIIvn sqXvBnKFsV2JNbebkjRhljRX0gfoxxg61T6NObkd4e7HIoCYARgyFmWnAXcrnMSgAWxpps QYMPbfTlS7MHZQZhuwus/BPfDfMCY+xNvRUQCwpj4eL3caBsEHAE+xTjauPY8U1NL96MNf 73Kbu8E5KPYsY/3aUQHbSLqFFvSQSn+CgVLRbNJWfF+5vzybOI0nVxToe/JZvw== 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=800b5aafa3a801fe3a7bf3f0dd78fbc33e7e6ba1 commit 800b5aafa3a801fe3a7bf3f0dd78fbc33e7e6ba1 Author: Dmitry Chagin AuthorDate: 2022-05-09 18:11:37 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:06 +0000 linux(4): Fixed offset miscalculation in the preadv/pwritev syscalls. MFC after: 2 weeks (cherry picked from commit b17446281d21311cc4f9d522c5d18337a9f786bc) --- sys/compat/linux/linux_file.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 8926e760fc39..199bed80d92a 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1268,6 +1268,15 @@ linux_pwrite(struct thread *td, struct linux_pwrite_args *uap) return (kern_pwrite(td, uap->fd, uap->buf, uap->nbyte, offset)); } +#define HALF_LONG_BITS ((sizeof(l_long) * NBBY / 2)) + +static inline off_t +pos_from_hilo(unsigned long high, unsigned long low) +{ + + return (((off_t)high << HALF_LONG_BITS) << HALF_LONG_BITS) | low; +} + int linux_preadv(struct thread *td, struct linux_preadv_args *uap) { @@ -1280,8 +1289,7 @@ linux_preadv(struct thread *td, struct linux_preadv_args *uap) * pos_l and pos_h, respectively, contain the * low order and high order 32 bits of offset. */ - offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) << - (sizeof(offset) * 4)) | uap->pos_l; + offset = pos_from_hilo(uap->pos_h, uap->pos_l); if (offset < 0) return (EINVAL); #ifdef COMPAT_LINUX32 @@ -1308,8 +1316,7 @@ linux_pwritev(struct thread *td, struct linux_pwritev_args *uap) * pos_l and pos_h, respectively, contain the * low order and high order 32 bits of offset. */ - offset = (((off_t)uap->pos_h << (sizeof(offset) * 4)) << - (sizeof(offset) * 4)) | uap->pos_l; + offset = pos_from_hilo(uap->pos_h, uap->pos_l); if (offset < 0) return (EINVAL); #ifdef COMPAT_LINUX32