From nobody Mon May 09 18:17:10 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 AEC431ADF7DF; Mon, 9 May 2022 18:17:10 +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 4KxqBt3ZyYz3JCh; Mon, 9 May 2022 18:17:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652120230; 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=dQu5DA7qQn7OG9IVdomr2epPLgi6Cwks7l8Ue+M/7NA=; b=aXnH+LCN7Tzku4tXhYlhuo3jw+LIPZuz+w73v+0C7Zd+Qvd/nwWwCmg3W0rox7UMol4uRj EEerywfVhKrexBhXzcJylj3s5aQuIax/Nl8YKMMevqoUi6K28OONUkswlOBKpLg7qGvURo 827VfdNMO5EOC6EpdP6bnYLTxkwG4vTIX2zLGgGzkxz7QNfhGG6k4mvXhmRx+J3ovBv/io xo7WJlPFjkBeKgSf7VMO3iwxQBP2h/smsxpzSJErrSIwFifZt0xUEMFDWm0hWyTU2Nq5jF M5uLqix3yR+KzM9M7XizZb5LxP2rUGNgIN5/G2eB8ih2f8vnim8U4sXIzhhEAg== 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 23A2116087; Mon, 9 May 2022 18:17:10 +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 249IHALF090521; Mon, 9 May 2022 18:17:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 249IHAG7090520; Mon, 9 May 2022 18:17:10 GMT (envelope-from git) Date: Mon, 9 May 2022 18:17:10 GMT Message-Id: <202205091817.249IHAG7090520@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: b17446281d21 - main - linux(4): Fixed offset miscalculation in the preadv/pwritev syscalls. 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: b17446281d21311cc4f9d522c5d18337a9f786bc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652120230; 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=dQu5DA7qQn7OG9IVdomr2epPLgi6Cwks7l8Ue+M/7NA=; b=wQVxAawrhsHwN0rYivZD8lmKITzR55SzaoayqMPVgbzY2ZjSJu+t2A56krM/dbyBv4VhqN YbBoCat0uRg0Z9gT3Z4nzG6S2nEvY2c03zNlE1TYYM5w0frOKP8HIMwic7P1JvsdgsCbQh tUZrXEoYap0pgpGVm3Nbta84i6cJHIGZUG5iwKRPKyMdb/hvhXHIlSbS6nnK3PkXsOmIhU ITeEQNKPSlf8MF+HDLC4iE02T0DotN4QDEbLxqgaaGYD9qY4Nio2uEx6uJCeAVeSWLRyO1 gZOaBgtFgBiaMWX77jdGPPip7KZ9sMQyDpNkEa9owMl0H8jMN4UonmQFQUgiTw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652120230; a=rsa-sha256; cv=none; b=PY3Hr5rpiHgTj5tUy+gufUwncO/3cbFSDtTsm1S2vh/HZE+GVx0Zs5E0TplD40BaGt7KB+ pFVR5WiVYhP4mK07+o+vlG7qtITKw9M9oDGwl6+FdgdBraOHti1DUmoK8jRgglxsvBcHvM bsPwhA30uF39e+VNPAMyTthAFWkcaH8moYTfZNX80rHLezZCiNvGCEnqWVfunV4CnCOg2P pkBZXA0dd23ihbsYVUys832hqTIlhghxdTaUWouHIrQeGQTHCHlp9Q8ZEtDLpYkqBXdkKP viScTYmMW5KmJFkhF8KDqlst5ZtOkE87ancBe8OGh0eIuI44Ih8H8pEDMWpjQw== 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=b17446281d21311cc4f9d522c5d18337a9f786bc commit b17446281d21311cc4f9d522c5d18337a9f786bc Author: Dmitry Chagin AuthorDate: 2022-05-09 18:11:37 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-09 18:11:37 +0000 linux(4): Fixed offset miscalculation in the preadv/pwritev syscalls. MFC after: 2 weeks --- 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