From owner-svn-src-all@freebsd.org Sun Apr 28 14:08:06 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5995157F5EC; Sun, 28 Apr 2019 14:08:06 +0000 (UTC) (envelope-from dchagin@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5E91994E73; Sun, 28 Apr 2019 14:08:06 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2BFACBA03; Sun, 28 Apr 2019 14:08:06 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3SE85Qf039264; Sun, 28 Apr 2019 14:08:05 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3SE85K9039261; Sun, 28 Apr 2019 14:08:05 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201904281408.x3SE85K9039261@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sun, 28 Apr 2019 14:08:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346835 - in stable/11/sys: amd64/linux amd64/linux32 compat/linux i386/linux X-SVN-Group: stable-11 X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in stable/11/sys: amd64/linux amd64/linux32 compat/linux i386/linux X-SVN-Commit-Revision: 346835 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5E91994E73 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.98)[-0.980,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Apr 2019 14:08:06 -0000 Author: dchagin Date: Sun Apr 28 14:08:05 2019 New Revision: 346835 URL: https://svnweb.freebsd.org/changeset/base/346835 Log: MFC r335515 (by chuck@): Fix the Linux kernel version number calculation The Linux compatibility code was converting the version number (e.g. 2.6.32) in two different ways and then comparing the results. The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2 v = v0 * 1000000 + v1 * 1000 + v2; The LINUX_KERNVER() macro, on the other hand, converted the value with bit shifts. I.e. where major=a, minor=b, and patch=c v = (((a) << 16) + ((b) << 8) + (c)) The Linux kernel uses the later format via the KERNEL_VERSION() macro in include/generated/uapi/linux/version.h Fix is to use the LINUX_KERNVER() macro in linux_map_osrel() as well as in the .trans_osrel functions. PR: 229209 Modified: stable/11/sys/amd64/linux/linux_sysvec.c stable/11/sys/amd64/linux32/linux32_sysvec.c stable/11/sys/compat/linux/linux_mib.c stable/11/sys/i386/linux/linux_sysvec.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/linux/linux_sysvec.c ============================================================================== --- stable/11/sys/amd64/linux/linux_sysvec.c Sun Apr 28 14:06:22 2019 (r346834) +++ stable/11/sys/amd64/linux/linux_sysvec.c Sun Apr 28 14:08:05 2019 (r346835) @@ -794,10 +794,11 @@ linux_trans_osrel(const Elf_Note *note, int32_t *osrel return (false); /* - * For Linux we encode osrel as follows (see linux_mib.c): - * VVVMMMIII (version, major, minor), see linux_mib.c. + * For Linux we encode osrel using the Linux convention of + * (version << 16) | (major << 8) | (minor) + * See macro in linux_mib.h */ - *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3]; + *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); return (true); } Modified: stable/11/sys/amd64/linux32/linux32_sysvec.c ============================================================================== --- stable/11/sys/amd64/linux32/linux32_sysvec.c Sun Apr 28 14:06:22 2019 (r346834) +++ stable/11/sys/amd64/linux32/linux32_sysvec.c Sun Apr 28 14:08:05 2019 (r346835) @@ -993,10 +993,11 @@ linux32_trans_osrel(const Elf_Note *note, int32_t *osr return (false); /* - * For Linux we encode osrel as follows (see linux_mib.c): - * VVVMMMIII (version, major, minor), see linux_mib.c. + * For Linux we encode osrel using the Linux convention of + * (version << 16) | (major << 8) | (minor) + * See macro in linux_mib.h */ - *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3]; + *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); return (true); } Modified: stable/11/sys/compat/linux/linux_mib.c ============================================================================== --- stable/11/sys/compat/linux/linux_mib.c Sun Apr 28 14:06:22 2019 (r346834) +++ stable/11/sys/compat/linux/linux_mib.c Sun Apr 28 14:08:05 2019 (r346835) @@ -149,8 +149,8 @@ linux_map_osrel(char *osrelease, int *osrel) if (osrelease == sep || sep != eosrelease) return (EINVAL); - v = v0 * 1000000 + v1 * 1000 + v2; - if (v < 1000000) + v = LINUX_KERNVER(v0, v1, v2); + if (v < LINUX_KERNVER(1, 0, 0)) return (EINVAL); if (osrel != NULL) Modified: stable/11/sys/i386/linux/linux_sysvec.c ============================================================================== --- stable/11/sys/i386/linux/linux_sysvec.c Sun Apr 28 14:06:22 2019 (r346834) +++ stable/11/sys/i386/linux/linux_sysvec.c Sun Apr 28 14:08:05 2019 (r346835) @@ -960,10 +960,11 @@ linux_trans_osrel(const Elf_Note *note, int32_t *osrel return (false); /* - * For Linux we encode osrel as follows (see linux_mib.c): - * VVVMMMIII (version, major, minor), see linux_mib.c. + * For Linux we encode osrel using the Linux convention of + * (version << 16) | (major << 8) | (minor) + * See macro in linux_mib.h */ - *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3]; + *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); return (true); }