Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 4.13.4 #13

Merged
merged 21 commits into from
Jan 10, 2018
Merged

Update to 4.13.4 #13

merged 21 commits into from
Jan 10, 2018

Conversation

HW42
Copy link
Contributor

@HW42 HW42 commented Oct 2, 2017

This should not be merge but get it's own branch. Creating PR for tracking and discussion.

@marmarek: Should kernel-latest provide kernel-xen-dom0, etc.?

@rtiangha: If you have some time it would be nice if you could have a look at the new config options that have been added since 4.9. Currently it's just a simple yes '' | make oldconfig. For example we might want to consider to set:
CONFIG_SLAB_MERGE_DEFAULT=n
CONFIG_GCC_PLUGIN_STRUCTLEAK=y
CONFIG_GCC_PLUGIN_RANDSTRUCT=y (but requires gcc 4.7)
CONFIG_FORTIFY_SOURCE=y

@rtiangha
Copy link
Contributor

rtiangha commented Oct 2, 2017

@HW42: You're talking about the new KSPP recommended options that have appeared since 4.9 plus CONFIG_FORTIFY_SOURCE? I agree. I actually have them set in my 4.13 config, but I haven't had much time to play around with 4.13 to see how well it works (I still need to recompile it to remove CONFIG_INTEL_ATOMISP). I think the GCC plugin options appeared in 4.11 or 4.12 though, and on my personal machine, I've enabled them and haven't really encountered any issues. Fedora 23 has GCC 5.3 and Debian 8 has GCC 4.9 so if what comes with a default Qubes R3.2 system is the baseline, then enabling the RANDSTRUCT plugin option should be fine.

Another one to consider enabling might be CONFIG_BUG_ON_DATA_CORRUPTION ("Select this option if the kernel should BUG when it encounters data corruption in kernel memory structures when they get checked for validity."). I've had it turned on in 4.11 and 4.12 and I haven't encountered any issues.

As for hardware support, any new PCI/USB network drivers that have appeared since 4.9 and make sense on a desktop or notebook should probably be compiled as modules. The same for any accelerometer, magnetometer, orientation and other sensors that might appear in a notebook computer (some machines rely on them for suspend detection or screen rotation). Any new USB HID driver support that appears should be considered as well, especially when it comes to touchscreens, keyboards or mice. Maybe any new USB camera support as well.

I've also been wondering for a while now if other Kernel Security Module support like TOMOYO or SMACK should be compiled as modules as well for anyone that might want to use them, although I personally don't have experience using those two. Currently, it's AppArmor, SELinux and Yama, and those seem to be working fine for those that use them.

Anyways, those are my comments. I may have more once I've used 4.13 for a longer period of time. But it'd be good to really test 4.13 well so that hopefully the 4.14 LTS kernel testing will be a little bit easier when that gets released.

@marmarek
Copy link
Member

marmarek commented Oct 2, 2017

@marmarek: Should kernel-latest provide kernel-xen-dom0, etc.?

Should not harm, but in practice most of them are unused anyway.

@HW42
Copy link
Contributor Author

HW42 commented Oct 2, 2017

@marmarek: Should kernel-latest provide kernel-xen-dom0, etc.?

Should not harm, but in practice most of them are unused anyway.

Ok. Then the simple name change as done here should be enough.

@HW42
Copy link
Contributor Author

HW42 commented Oct 2, 2017

@HW42: You're talking about the new KSPP recommended options that have appeared since 4.9 plus CONFIG_FORTIFY_SOURCE?

Yes. I just quickly looked at the config diff which options might be interessting. It's also quite possible that I have missed some stuff.

I agree. I actually have them set in my 4.13 config, but I haven't had much time to play around with 4.13 to see how well it works (I still need to recompile it to remove CONFIG_INTEL_ATOMISP). I think the GCC plugin options appeared in 4.11 or 4.12 though, and on my personal machine, I've enabled them and haven't really encountered any issues. Fedora 23 has GCC 5.3 and Debian 8 has GCC 4.9 so if what comes with a default Qubes R3.2 system is the baseline, then enabling the RANDSTRUCT plugin option should be fine.

The package is build in Fedora 25 which currently uses gcc 4.6.1. Also with RANDSTRUCT you need to check if the package is properly generated such that one can build out of tree modules. (And of course RANDSTRUCT is quite limited for a binary distribution).

Another one to consider enabling might be CONFIG_BUG_ON_DATA_CORRUPTION ("Select this option if the kernel should BUG when it encounters data corruption in kernel memory structures when they get checked for validity."). I've had it turned on in 4.11 and 4.12 and I haven't encountered any issues.

As for hardware support, any new PCI/USB network drivers that have appeared since 4.9 and make sense on a desktop or notebook should probably be compiled as modules. The same for any accelerometer, magnetometer, orientation and other sensors that might appear in a notebook computer (some machines rely on them for suspend detection or screen rotation). Any new USB HID driver support that appears should be considered as well, especially when it comes to touchscreens, keyboards or mice. Maybe any new USB camera support as well.

If I understand you correctly you already have played with 4.13 and the previouse versions. So do you have a updated config? If yes please open a PR once Marek has created the new branch.

I've also been wondering for a while now if other Kernel Security Module support like TOMOYO or SMACK should be compiled as modules as well for anyone that might want to use them, although I personally don't have experience using those two. Currently, it's AppArmor, SELinux and Yama, and those seem to be working fine for those that use them.

I would keep it as is unless somebody actively request support for those.

@fepitre
Copy link
Member

fepitre commented Oct 3, 2017

On my side, kernel 4.12.14 is stable thanks to disabling CONFIG_INTEL_ATOMISP (see my post https://groups.google.com/d/msg/qubes-users/yBeUJPwKwHM/1-_pseZPBgAJ) but kernel 4.13.4 seems to make Ryzen platform crashing (it is my case and also another user).

@marmarek
Copy link
Member

marmarek commented Oct 3, 2017

4.12 is already EOL...

@fepitre
Copy link
Member

fepitre commented Oct 3, 2017

Ooh, I have not paid attention that it was already EOL... I will test the last rc of 4.14 to see if the problem on 4.13 still happen.

@rtiangha
Copy link
Contributor

rtiangha commented Oct 5, 2017

The package is build in Fedora 25 which currently uses gcc 4.6.1. Also with RANDSTRUCT you need to check if the package is properly generated such that one can build out of tree modules. (And of course RANDSTRUCT is quite limited for a binary distribution).

Wait, so is the build environment different than the one that ships for the various Fedoras used in dom0? I just assumed that the build system used the same gcc versions as those used in the various Release targets when they compiled the release-specific packages. I wonder if mismatched gcc versions causes issues when new kernel modules are compiled by users after installation.

If I understand you correctly you already have played with 4.13 and the previous versions. So do you have a updated config? If yes please open a PR once Marek has created the new branch.

I do. @fepitre's devel-4.13 branch is probably closest to what I have locally since it inherits all the changes from 4.9-4.12, but I haven't diff'ed his version and mine to see if we made different choices when migrating from 4.12 to 4.13. But part of me really wants to rebase off of Fedora's 4.13 config once it's finished its testing phase and is officially released instead, then add in the KSPP settings and other hardening features on top of that. Some users have raised issues with the 4.9 kernel that work perfectly under 4.4 and as all things seem to look fine on the surface comparing the two, the troubleshooting has become difficult. So maybe some obscure setting was missed during the 4.4 to 4.9 migration, and if the hardware works under a stock Fedora kernel, then maybe a 4.13 kernel config rebase might be worthwhile trying to see if that fixes things. If not, it might be a side effect of the extra hardening.

I would keep it as is unless somebody actively request support for those.

Works for me.

@rtiangha
Copy link
Contributor

rtiangha commented Oct 5, 2017

Ooh, I have not paid attention that it was already EOL... I will test the last rc of 4.14 to see if the problem on 4.13 still happen.

If you haven't tried it yet, you may need to alter the build script to work with the RC nomenclature. The build scripts expect the kernel uname to be of the form X.Y.Z and if it isn't in that format, it fails (so for example, kernel 4.13 would have failed in its build but 4.13.1 would have worked fine; I suspect 4.14-rc3 will fail by default).

@marmarek
Copy link
Member

marmarek commented Oct 5, 2017

Wait, so is the build environment different than the one that ships for the various Fedoras used in dom0? I just assumed that the build system used the same gcc versions as those used in the various Release targets when they compiled the release-specific packages. I wonder if mismatched gcc versions causes issues when new kernel modules are compiled by users after installation.

No, kernel packages for dom0 are build in the same env as other packages for dom0. This also cause some issues (QubesOS/qubes-issues#2844)...

@marmarek
Copy link
Member

marmarek commented Oct 5, 2017

But part of me really wants to rebase off of Fedora's 4.13 config once it's finished its testing phase and is officially released instead, then add in the KSPP settings and other hardening features on top of that.

It is there:
https://bodhi.fedoraproject.org/updates/?builds=kernel-4.13.4-200.fc26

Some users have raised issues with the 4.9 kernel that work perfectly under 4.4 and as all things seem to look fine on the surface comparing the two, the troubleshooting has become difficult. So maybe some obscure setting was missed during the 4.4 to 4.9 migration, and if the hardware works under a stock Fedora kernel, then maybe a 4.13 kernel config rebase might be worthwhile trying to see if that fixes things. If not, it might be a side effect of the extra hardening.

What do you think about doing the same with 4.9? It is LTS, so it's going to be around for a while. It looks like the latest Fedora's 4.9 is 4.9.17 for fc24.

@rtiangha
Copy link
Contributor

rtiangha commented Oct 5, 2017

Yeah, I think I might do that. I'll try to get that done by this weekend so that it can be tested in time for R4.0 rc2. It's around time for a new update roll up anyway.

@rtiangha
Copy link
Contributor

rtiangha commented Oct 8, 2017

I'm almost done (at least with the 4.9 branch; haven't had a chance yet to look at 4.13), but I had a question about the Qubes policy when it comes to the Fedora kernel patches that are included in the src rpm. There are a lot here, and while I haven't delved too deeply to see what they do, just running 'make prep' to see what patched in and what didn't, here are the ones that patched in cleanly against 4.9.54:

patches.fedora/0001-iio-Use-event-header-from-kernel-tree.patch
patches.fedora/acpi-Ignore-acpi_rsdp-kernel-parameter-when-module-l.patch
patches.fedora/ACPI-Limit-access-to-custom_method.patch
patches.fedora/Add-an-EFI-signature-blob-parser-and-key-loader.patch
patches.fedora/Add-EFI-signature-data-types.patch
patches.fedora/Add-secure_modules-call.patch
patches.fedora/Add-sysrq-option-to-disable-secure-boot-mode.patch
patches.fedora/AllWinner-net-emac.patch
patches.fedora/arm64-mm-Fix-memmap-to-be-initialized-for-the-entire-section.patch
patches.fedora/ARM-Drop-fixed-200-Hz-timer-requirement-from-Samsung-platforms.patch
patches.fedora/arm-revert-mmc-omap_hsmmc-Use-dma_request_chan-for-reque.patch
patches.fedora/ARM-tegra-usb-no-reset.patch
patches.fedora/asus-wmi-Restrict-debugfs-interface-when-module-load.patch
patches.fedora/ath9k-rx-dma-stop-check.patch
patches.fedora/bcm2837-initial-support.patch
patches.fedora/crash-driver.patch
patches.fedora/criu-no-expert.patch
patches.fedora/die-floppy-die.patch
patches.fedora/disable-i8042-check-on-apple-mac.patch
patches.fedora/drm-i915-hush-check-crtc-state.patch
patches.fedora/drm-vc4-Fix-OOPSes-from-trying-to-cache-a-partially-constructed-BO..patch
patches.fedora/efi-Add-SHIM-and-image-security-database-GUID-defini.patch
patches.fedora/firmware-Drop-WARN-from-usermodehelper_read_trylock-.patch
patches.fedora/geekbox-v4-device-tree-support.patch
patches.fedora/hibernate-Disable-in-a-signed-modules-environment.patch
patches.fedora/imx6sx-Add-UDOO-Neo-support.patch
patches.fedora/input-kill-stupid-messages.patch
patches.fedora/Input-synaptics-pin-3-touches-when-the-firmware-repo.patch
patches.fedora/Kbuild-Add-an-option-to-enable-GCC-VTA.patch
patches.fedora/kexec-Disable-at-runtime-if-the-kernel-enforces-modu.patch
patches.fedora/kexec-uefi-copy-secure_boot-flag-in-boot-params.patch
patches.fedora/KEYS-Add-a-system-blacklist-keyring.patch
patches.fedora/lib-cpumask-Make-CPUMASK_OFFSTACK-usable-without-deb.patch
patches.fedora/lis3-improve-handling-of-null-rate.patch
patches.fedora/mm-alloc_contig-re-allow-CMA-to-compact-FS-pages.patch
patches.fedora/MODSIGN-Import-certificates-from-UEFI-Secure-Boot.patch
patches.fedora/MODSIGN-Support-not-importing-certs-from-db.patch
patches.fedora/netfilter-x_tables-deal-with-bogus-nextoffset-values.patch
patches.fedora/no-pcspkr-modalias.patch
patches.fedora/nouveau-add-maxwell-to-backlight-init.patch
patches.fedora/qcom-QDF2432-tmp-errata.patch
patches.fedora/Restrict-dev-mem-and-dev-kmem-when-module-loading-is.patch
patches.fedora/rt2800-warning.patch
patches.fedora/scsi-sd_revalidate_disk-prevent-NULL-ptr-deref.patch
patches.fedora/selinux-namespace-fix.patch
patches.fedora/silence-fbcon-logo.patch
patches.fedora/usb-phy-tegra-Add-38.4MHz-clock-table-entry.patch
patches.fedora/vc4-fix-vblank-cursor-update-issue.patch
patches.fedora/x86-Lock-down-IO-port-access-when-module-security-is.patch
patches.fedora/x86-Restrict-MSR-access-when-module-loading-is-restr.patch
patches.fedora/xen-pciback-Don-t-disable-PCI_COMMAND-on-PCI-device-.patch

these are the ones that may need a little work to be migrated to the latest 4.9 version:

patches.fedora/Add-option-to-automatically-enforce-module-signature.patch
patches.fedora/bcm283x-mmc-imp-speed.patch
patches.fedora/efi-Add-EFI_SECURE_BOOT-bit.patch
patches.fedora/efi-Disable-secure-boot-if-shim-is-in-insecure-mode.patch
patches.fedora/MODSIGN-Don-t-try-secure-boot-if-EFI-runtime-is-disa.patch
patches.fedora/PCI-Lock-down-BAR-access-when-module-security-is-ena.patch

these are the ones that have already been merged upstream:

patches.fedora/1-2-media-cxusb-Use-a-dma-capable-buffer-also-for-reading.patch
patches.fedora/2-2-media-dvb-usb-firmware-don-t-do-DMA-on-stack.patch
patches.fedora/kvm-fix-page-struct-leak-in-handle_vmon.patch
patches.fedora/sctp-deny-peeloff-operation-on-asocs-with-threads-sl.patch

and these are the ones that don't patch in but are probably not applicable (different architecture):

patches.fedora/arm64-pcie-quirks.patc

Should these be included in the Qubes kernel? How has this been dealt with in the past? And if they were to be merged in, how would it run on different distro templates like Debian or Archlinux? Would there be any issues?

@marmarek
Copy link
Member

marmarek commented Oct 8, 2017

Generally the policy is to have mostly vanilla kernel. Exceptions include things specific to Qubes OS (but it applies mostly/only to dom0), or critical fixes (like security patches, until included in upstream version). In other cases, patches should go through upstream.

@marmarek
Copy link
Member

I've created branch devel-latest (on my account) with adjustments to config based on @rtiangha devel-4.12 branch. Once we agree on the final config (which may be the current one, or original from this PR), I'll create stable-latest branch on @QubesOS. I don't want to force-push to any of branches on @QubesOS, so devel branches are only on my account.

@fepitre
Copy link
Member

fepitre commented Oct 11, 2017

Don't forget to not setting CONFIG_INTEL_ATOMISP (see in my devel-4.12 for detail)

@marmarek
Copy link
Member

@rtiangha I have some questions about config options in your stable-4.9 branch:

  • disabled CONFIG_PARAVIRT_SPINLOCKS (disabling will have performance impact on Xen)
  • disabled CONFIG_IKCONFIG (no hard opinion, but IMO useful)
  • enabled CONFIG_IRQ_TIME_ACCOUNTING (according to help, have performance impact)
  • enabled CONFIG_KVM_GUEST (for what?)
  • enabled CONFIG_HOTPLUG_PCI - it was disabled intentionally, see #1673
  • various VMWARE options - for what?
  • whole section of "SoC Audio for Freescake CPUs" ?
  • USB controller drivers as built it - should be module, to ease blacklisting when desired, and allow unloading for suspend (apparently necessary, otherwise sys-usb crashes)
  • CONFIG_USB_GADGET is required for client-side USB/IP (CONFIG_USBIP_VUDC), which is used by qvm-usb
  • disabled CONFIG_EFI_VARS ? doesn't it break efibootmgr (so, unable to install in EFI mode)?
  • CONFIG_QUOTA_DEBUG ?

This is the first pass of validation after rebasing on Fedora config. Probably require additional one.

@rtiangha
Copy link
Contributor

rtiangha commented Oct 11, 2017

@marmarek Actually, the 4.12 branch on my account hasn't been rebased on Fedora's 4.9; I haven't even touched it. It was based of off @fepitre's work and I just copied his branch in its entirety and bumped it up to 4.12.14. I hadn't had a chance to rebase it, either using a migrated 4.9 config or Fedora's 4.12 (or even take out CONFIG_INTEL_ATOMISP). My intent was to migrate that to a 4.13 branch, but I got stuck on the vm kernel panic issue due to INTEL_ATOMISP and wasn't able to solve it fast enough before I had to go and work on other things.

I did do a pass on my 4.9 branch using Fedora's version, but my rational was to not disable anything except for what KSPP recommended to disable, and maybe one or two other obvious things. After that, it was add in hardware support, but I didn't look too closely at each driver. But I appreciate the validation pass regardless of the lineage; it is good to debate the merits of each option.

As for the hypervisor stuff like VMware and KVM, in my original 4.4 migrated config, I had disabled them. When using Fedora's 4.9 config (it and the modifications I made are currently on my stable-4.9 branch so that's the one I'll be talking about), I left them as is, even though I personally disable all hypervisor support except for Xen on the machines I run, mainly because this page states that nested hypervisors may actually work depending on the version of Xen you're running (4.8+ obviously having better support for Windows/VMware than 4.6). I don't feel strongly either way including other hypervisor support in this kernel, though.

Everything else (including the Freescale support) was a Fedora 4.9 default. I hadn't had a chance to look at all of them in depth, but I agree 100% with your comments. I guess this new config will need another pass or two to ensure what needs to be enabled is actually enabled, and what doesn't need to be there isn't (like anything that applies to ARM-only stuff, for example).

@rtiangha
Copy link
Contributor

Ugh. For example, explicitly disabling by default various KSMs like Selinux and Apparmor. I just made a new 4.9 commit for that, but yeah, looks like some more customization may be needed.

@rtiangha
Copy link
Contributor

Edit: Actually, I may have read those tables wrong and misinterpreted nested hypervisor support. It looks like it's getting worse the higher the Xen version is. If that's truly the case, then there really is no reason to include support for other hypervisors in the kernel. But they still sort of work with Xen 4.6 though. Again, I don't feel strongly either way.

@marmarek
Copy link
Member

FWIW, we don't provide easy way to enable nested virtualization, on purpose.

@marmarek
Copy link
Member

This is offtopic here, but I'm going to upload 4.9.54 to current-testing (with #12 merged), but without this config rebase, yet.

HW42 added 2 commits December 15, 2017 10:08
The config is now generated based on Fedora's config. This way we need
to only track qubes specific changes and can quickly update to never
Fedora configs.
@marmarek
Copy link
Member

VM crash on boot with this 4.14.6 kernel: https://gist.github.com/marmarek/ad6ace847c3ac073fe12d6327e57e713

HW42 added 6 commits January 5, 2018 20:45
By writing '-latest' or '' in the 'suffix' file we can now easily switch
between the two variants.
The minimal config is not used by the package itself, but is useful when
testing different kernel versions (git bisect, etc.), so store it here.
@HW42
Copy link
Contributor Author

HW42 commented Jan 6, 2018

The crash should be fixed now.

Currently the kernel-latest package and the kernel package use the same paths for the kernels. So we could run into conflicts. Do we want to keep this?

@fepitre
Copy link
Member

fepitre commented Jan 6, 2018

Another option, when kernel-latest will be the latest kernel, we could make obsolete and require remove the related kernel-latest version to have proper install directories. No?

@HW42
Copy link
Contributor Author

HW42 commented Jan 6, 2018

@fepitre:

Another option, when kernel-latest will be the latest kernel, we could make obsolete and require remove the related kernel-latest version to have proper install directories. No?

Not sure I understand what you wrote. I think the easiest solution is to add (to kernel):

Conflicts: kernel-latest = %{epoch}:%{version}-%{release}

And the equivalent for the qubes-vm packages.

My question was more targeted at if we prefer this, or using separate paths?

@marmarek
Copy link
Member

marmarek commented Jan 6, 2018

I think conflict is ok. In practice this will happen only when new LTS kernel will be released. And we can delay either package then.

@fepitre
Copy link
Member

fepitre commented Jan 6, 2018

@HW42: yes this is why I meant. Sorry for my bad sentence.

@fepitre
Copy link
Member

fepitre commented Jan 6, 2018

@marmarek: indeed, but just to be sure to not have duplicates files.

@marmarek
Copy link
Member

marmarek commented Jan 9, 2018

I've reviewed new config one more time. Things to consider:

  • switch USB controller drivers (uhci, ohci, ehci, xhci) to modules, so it will be possible to catch USB controllers by xen-pciback before touching any USB device.
  • enable USB gadgets (as modules) - we use it for testing qvm-usb

HW42 added 2 commits January 9, 2018 05:08
This should allow to assign usb device to pciback in initramfs before
thos modules get loaded.
@HW42
Copy link
Contributor Author

HW42 commented Jan 9, 2018

I've reviewed new config one more time. Things to consider:

  • switch USB controller drivers (uhci, ohci, ehci, xhci) to modules, so it will be possible to catch USB controllers by xen-pciback before touching any USB device.

Changed.

  • enable USB gadgets (as modules) - we use it for testing qvm-usb

Hope the added options are enough for the test.

Those two config changes are NOT tested yet (build running ...).

@marmarek
Copy link
Member

Those two config changes are NOT tested yet (build running ...).

And?
I'd like to upload this to testing repository...

This is also needed by the qvm-usb tests.
@HW42
Copy link
Contributor Author

HW42 commented Jan 10, 2018

Works fine. With the new commit the test can create the dummy device.

But the test file is broken in R3.2 (installed for python3.4 instead of 2.7) and the driver has slightly changed so the usbproxy code needs an update (changed paths, status format (and it seems to support USB 3.0 now)).

@marmarek marmarek changed the base branch from stable-4.9 to master January 10, 2018 14:42
@marmarek marmarek merged commit 984ffdc into QubesOS:master Jan 10, 2018
@marmarek
Copy link
Member

Part of QubesOS/qubes-issues#3460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants