Petr Pavlu d24911
SUSE Kernel Repository
Petr Pavlu d24911
======================
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu d24911
Overview
Petr Pavlu 6f0a5c
--------
Petr Pavlu d24911
Petr Pavlu d24911
The kernel-source repository contains sources, configuration files, package
Petr Pavlu d24911
definitions and supporting scripts for the SUSE kernels.
Petr Pavlu d24911
Petr Pavlu d24911
The SUSE kernels are generated from the upstream Linux kernel sources found at
Petr Pavlu bbaa1b
<https://kernel.org/>, on top of which a number of patches are applied. The
Petr Pavlu d24911
expanded kernel source tree is configured and built, resulting in a binary
Petr Pavlu d24911
kernel.
Petr Pavlu d24911
Petr Pavlu d24911
Petr Pavlu 6f0a5c
Getting started
Petr Pavlu 6f0a5c
---------------
Michal Marek bc3577
Petr Pavlu 8b03ad
Make sure you have the git and quilt tools installed.
Michal Marek bc3577
Michal Marek bc3577
Introduce yourself if you haven't done so already:
Petr Pavlu 8b03ad
Michal Marek bc3577
    $ git config --global user.name "Your Name"
Michal Marek bc3577
    $ git config --global user.email your@email
Michal Marek bc3577
Petr Pavlu bbaa1b
If you omit the `--global` option, the setting will only apply to this
Petr Pavlu 8b03ad
repository clone.
Michal Marek bc3577
Petr Pavlu 8b03ad
Set up some Git hooks and helpers:
Michal Marek bc3577
Michal Marek bc3577
    $ ./scripts/install-git-hooks
Michal Marek bc3577
Michal Marek bc3577
To hack on the kernel sources:
Michal Marek bc3577
Petr Pavlu 8b03ad
    $ ./scripts/sequence-patch.sh
Michal Marek bc3577
    $ cd tmp/linux-$version-$branch
Petr Pavlu 8b03ad
    $ quilt new patches.suse/fix-foo-and-bar.patch
Michal Marek bc3577
    $ quilt edit some/file.c
Michal Marek bc3577
    $ ./refresh_patch.sh
Michal Marek bc3577
    $ quilt header -e # see next chapter
Michal Marek bc3577
Petr Pavlu 8b03ad
Refer to the Quilt documentation for details. When you are done, add the new
Petr Pavlu 6b6744
patch to an appropriate place in the `series.conf` file and run `./scripts/log`
Petr Pavlu 6b6744
to commit it. Patches should be named such that they consist of alphanumeric
Petr Pavlu 6b6744
characters, '-' and '.'. Typically, patches are named by filtering the Subject
Petr Pavlu 6b6744
of the patch to a lower-case, dash-separated form like the one in the example
Petr Pavlu 6b6744
above.
Michal Marek bc3577
Petr Pavlu 8b03ad
To build RPM packages:
Michal Marek bc3577
Michal Marek bc3577
    $ ./scripts/tar-up.sh
Michal Marek bc3577
Michal Marek bc3577
This creates a source package in the kernel-source directory. Use
Michal Marek de8dd7
Michal Marek de8dd7
    $ ./scripts/osc_wrapper [kernel-source/kernel-$flavor.spec]
Michal Marek de8dd7
Michal Marek de8dd7
to build a kernel package locally, or
Michal Marek de8dd7
Michal Marek de8dd7
    $ ./scripts/osc_wrapper upload [--ibs]
Michal Marek de8dd7
Petr Pavlu 6b6744
to have all flavors and architectures built by the Open Build Service. The
Petr Pavlu 6b6744
`--ibs` option uses the SUSE internal instance.
Michal Marek bc3577
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Patch headers
Petr Pavlu 6f0a5c
-------------
Michal Marek a6afa1
Petr Pavlu 6b6744
Each patch must have an RFC822-style header that at a minimum describes what the
Petr Pavlu 6b6744
patch does, who wrote it and who inside SUSE can be contacted about problems
Petr Pavlu 6b6744
with the patch. The rules for patch headers are:
Michal Marek a6afa1
Petr Pavlu 6b6744
* Each patch must have a From tag that identifies the author of the patch.
Michal Marek a6afa1
Petr Pavlu 6b6744
* Each patch must have a Subject tag that briefly describes what the patch does.
Petr Pavlu 6b6744
  A brief summary that could appear in a change log makes the most sense in most
Petr Pavlu 6b6744
  cases.
Michal Marek a6afa1
Petr Pavlu 7c8a1e
* Unless the author specified in the From tag has a @suse.com, @suse.de or
Petr Pavlu 6b6744
  @suse.cz address, the patch must include a Signed-off-by, Acked-by or
Petr Pavlu 6b6744
  Reviewed-by header which identifies the person in one of these domains who
Petr Pavlu 6b6744
  feels responsible for the patch inside the company.
Michal Marek a6afa1
Petr Pavlu 6b6744
* The patch must include a Patch-mainline tag that identifies where the patch
Petr Pavlu 6b6744
  came from (for backports from mainline) or when it is expected to be added to
Petr Pavlu 6b6744
  mainline. The format is one of:
Benjamin Poirier 2d0738
Petr Pavlu bbaa1b
  For backports from mainline:
Benjamin Poirier 2d0738
Petr Pavlu bbaa1b
      Patch-mainline: <upstream version, for instance, "v6.5-rc7">
Petr Pavlu bbaa1b
      Git-commit: <git hash>
Benjamin Poirier 2d0738
Petr Pavlu 6b6744
  If the commit is from a maintainer repository or some other repository that
Petr Pavlu 6b6744
  isn't Linus's:
Benjamin Poirier 2d0738
Petr Pavlu bbaa1b
      Patch-mainline: Queued in subsystem maintainer repository
Petr Pavlu bbaa1b
      Git-repo: <url>
Petr Pavlu bbaa1b
      Git-commit: <git hash>
Benjamin Poirier 2d0738
Petr Pavlu bbaa1b
  If the patch is not upstream, depending on the situation:
Michal Marek a6afa1
Petr Pavlu bbaa1b
      Patch-mainline: Submitted, <timestamp - destination>
Thomas Zimmermann 097d8f
Petr Pavlu bbaa1b
      Patch-mainline: Not yet, <reason>
Petr Pavlu bbaa1b
Petr Pavlu bbaa1b
      Patch-mainline: Never, <reason>
Petr Pavlu bbaa1b
Petr Pavlu bbaa1b
* The patch should include a References tag that identifies the Bugzilla bug
Petr Pavlu 6b6744
  number, JIRA issue ID, etc. where the patch is discussed. Please prefix
Petr Pavlu 7c8a1e
  bugzilla.suse.com bug numbers with bsc# and JIRA issue IDs with jsc#. Make
Petr Pavlu 7c8a1e
  sure you specify a JIRA Implementation task when referencing JIRA features,
Petr Pavlu 7c8a1e
  not its Epic ID. Have a look at
Petr Pavlu bbaa1b
  <https://en.opensuse.org/openSUSE:Packaging_Patches_guidelines#Current_set_of_abbreviations>
Petr Pavlu bbaa1b
  for a full list of abbreviations.
Petr Pavlu bbaa1b
Petr Pavlu 6b6744
* The patch header should include a more extensive description of what the patch
Petr Pavlu 6b6744
  does, why and how. The idea is to allow others to quickly identify what each
Petr Pavlu 6b6744
  patch is about and to give enough information for reviewing.
Michal Marek a6afa1
Michal Marek a6afa1
More details about valid patch headers can be found in
Petr Pavlu 6b6744
`scripts/patch-tag-template`. The helper script `scripts/patch-tag` can be used
Petr Pavlu 6b6744
for managing these tags. Documentation for `patch-tag` can be found at the top
Petr Pavlu 6b6744
of the script itself.
Michal Marek a6afa1
Petr Pavlu bbaa1b
Example usage of `scripts/patch-tag-template`:
Michal Marek a6afa1
Michal Marek a6afa1
    $ cp scripts/patch-tag-template ~/.patchtag
Petr Pavlu bbaa1b
    [ Edit ~/.patchtag with any default values you want. ]
Michal Marek a6afa1
    $ patch-tag -e file.diff
Michal Marek a6afa1
Michal Marek a6afa1
Example patch header:
Michal Marek a6afa1
Petr Pavlu bbaa1b
```
Petr Pavlu bbaa1b
From: Pablo Neira Ayuso <pablo@netfilter.org>
Petr Pavlu bbaa1b
Date: Tue, 15 Aug 2023 15:39:01 +0200
Petr Pavlu bbaa1b
Subject: netfilter: nf_tables: GC transaction race with netns dismantle
Petr Pavlu bbaa1b
Patch-mainline: v6.5-rc7
Petr Pavlu bbaa1b
Git-commit: 02c6c24402bf1c1e986899c14ba22a10b510916b
Petr Pavlu bbaa1b
References: CVE-2023-4563 bsc#1214727
Petr Pavlu bbaa1b
Petr Pavlu bbaa1b
Use maybe_get_net() since GC workqueue might race with netns exit path.
Petr Pavlu bbaa1b
Petr Pavlu bbaa1b
Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
Petr Pavlu bbaa1b
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Petr Pavlu bbaa1b
Signed-off-by: Florian Westphal <fw@strlen.de>
Petr Pavlu bbaa1b
Acked-by: Michal Kubecek <mkubecek@suse.cz>
Petr Pavlu bbaa1b
```
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Benjamin Poirier 636f80
Patch sorting
Petr Pavlu 6f0a5c
-------------
Benjamin Poirier 636f80
Petr Pavlu bbaa1b
Patches added to the "sorted patches" section of `series.conf` must be sorted
Petr Pavlu 7c8a1e
according to the upstream order of the commits that they backport.
Benjamin Poirier 636f80
Petr Pavlu 6b6744
After you've added a patch file to the main `patches.suse/` or a different patch
Petr Pavlu 6b6744
directory, and supplemented the required tags described in the section [Patch
Petr Pavlu 6b6744
headers](#patch-headers), run
Benjamin Poirier 636f80
Benjamin Poirier 636f80
    $ ./scripts/git_sort/series_insert.py <patch>
Benjamin Poirier 636f80
Petr Pavlu bbaa1b
to insert an entry for a new patch file to the sorted section of `series.conf`.
Benjamin Poirier 636f80
Petr Pavlu bbaa1b
For more information, please read `scripts/git_sort/README.md`.
Benjamin Poirier 636f80
Petr Pavlu 6f0a5c
Petr Pavlu 6f0a5c
Before you commit -- things to check
Petr Pavlu 6f0a5c
------------------------------------
Michal Marek a6afa1
Petr Pavlu 6b6744
Make sure that all patches still apply after your changes. One way of doing this
Petr Pavlu 6b6744
is using `scripts/sequence-patch.sh`:
Michal Marek a6afa1
Michal Marek a6afa1
    $ export SCRATCH_AREA=/var/tmp/scratch
Petr Pavlu 05796c
    $ ./scripts/sequence-patch.sh
Petr Pavlu 05796c
    Creating tree in /var/tmp/scratch/linux-5.14-SLE15-SP5
Michal Suchanek b70c29
    Cleaning up from previous run
Petr Pavlu 05796c
    Linking from /var/tmp/scratch/linux-5.14.orig
Petr Pavlu 05796c
    ...
Petr Pavlu 05796c
    [ Tree: /var/tmp/scratch/linux-5.14-SLE15-SP5 ]
Michal Suchanek b70c29
    [ Generating Module.supported ]
Michal Suchanek b70c29
    [ Copying config/x86_64/default ]
Michal Suchanek b70c29
Petr Pavlu 6b6744
Note the "Tree:" line output by the `sequence-patch.sh` script which specifies
Petr Pavlu 6b6744
the location of the expanded kernel tree that is configured for local build.
Petr Pavlu 6b6744
Please test-compile the kernel or even test-build kernel packages, depending on
Petr Pavlu 6b6744
the impact of your changes. Use `scripts/tar-up.sh` for creating an OBS package
Petr Pavlu 6b6744
directory.
Michal Marek a6afa1
Petr Pavlu bbaa1b
The kernel source tree that `scripts/sequence-patch.sh` creates can be
Petr Pavlu 6b6744
test-compiled. Before that, make sure all prerequisites are installed. These
Petr Pavlu 6b6744
include libopenssl-devel, libelf-devel and dwarves. Have a look into
Petr Pavlu 6b6744
`rpm/kernel-binary.spec.in` for a complete list. Then, the compilation can be
Petr Pavlu 6b6744
done as follows:
Michal Marek a6afa1
Petr Pavlu 05796c
    $ cd /var/tmp/scratch/linux-5.14-SLE15-SP5
Michal Marek a6afa1
    $ make oldconfig
Michal Marek a6afa1
    $ make
Michal Marek a6afa1
Petr Pavlu 6b6744
When committing a patch series, try to make the series easily bisectable. In
Petr Pavlu 6b6744
other words, when applying only the first x patches (1 <= x <= n, n being the
Petr Pavlu 05796c
number of patches in the series), the kernel should be still buildable and
Juergen Gross c8c419
functional.
Juergen Gross c8c419
Petr Pavlu 6b6744
This means especially that just adding upstream patches unmodified to a series
Petr Pavlu 6b6744
and doing a cleanup patch at the end of the series to ensure the kernel is
Petr Pavlu 6b6744
buildable and functional is to be avoided. Each patch from upstream should be
Petr Pavlu 6b6744
modified as required to fit into the kernel it is backported to, both for build
Petr Pavlu 6b6744
time and runtime.
Juergen Gross c8c419
Petr Pavlu bbaa1b
Applying all patches in the tree with `scripts/sequence-patch.sh` can take
Petr Pavlu bbaa1b
a significant amount of time. The `--rapid` option is present to speed up the
Petr Pavlu 05796c
process and tells the script to use Rapidquilt instead of the regular Quilt.
Petr Pavlu 05796c
The Rapidquilt implementation applies patches in parallel and typically produces
Petr Pavlu 05796c
an expanded tree in a fraction of the original time. A Rapidquilt package can be
Petr Pavlu bbaa1b
obtained from <https://download.opensuse.org/repositories/Kernel:/tools/>.
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Petr Pavlu 6f0a5c
Config option changes
Petr Pavlu 6f0a5c
---------------------
Michal Marek a6afa1
Petr Pavlu 6b6744
SUSE kernel packages for various architectures and configurations are built from
Petr Pavlu 6b6744
the same sources. Each such kernel has its own configuration file in
Petr Pavlu 6b6744
`config/$ARCH/$FLAVOR`. Checks are in place that abort the kernel build when
Petr Pavlu 6b6744
those configuration files are missing necessary config options.
Michal Marek a6afa1
Petr Pavlu 5494c9
When adding patches that introduce new kernel config options, please also update
Michal Marek a6afa1
all config files as follows:
Michal Marek a6afa1
Petr Pavlu 7c8a1e
    $ ./scripts/sequence-patch.sh
Petr Pavlu 5494c9
    $ cd /var/tmp/scratch/linux-5.14-SLE15-SP5
Petr Pavlu 7c8a1e
    $ ./patches/scripts/run_oldconfig.sh
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Committing and log messages
Petr Pavlu 6f0a5c
---------------------------
Michal Marek a6afa1
Petr Pavlu 2dcbfb
Every commit to the kernel source repository should be properly documented.
Petr Pavlu bbaa1b
Tool `scripts/tar-up.sh` obtains change descriptions from a Git commit log and
Petr Pavlu bbaa1b
automatically produces `.changes` files for use by the target RPM packages. All
Petr Pavlu 2dcbfb
commits which affect the kernel package have their description collected, only
Petr Pavlu 2dcbfb
changes modifying internals of the repository such as helper scripts are
Petr Pavlu 2dcbfb
skipped.
Petr Pavlu 2dcbfb
Petr Pavlu 6b6744
When recording your changes to the repository, you should use `scripts/log`
Petr Pavlu 6b6744
rather than running `git commit` directly in order to produce a commit
Petr Pavlu 6b6744
description in the expected format.
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu 6f0a5c
What is the kernel ABI?
Petr Pavlu 6f0a5c
-----------------------
Michal Marek a6afa1
Petr Pavlu 6b6744
All symbols that the kernel exports for use by modules and all symbols that
Petr Pavlu 6b6744
modules export for use by other modules are associated with a so-called
Petr Pavlu 6b6744
modversion. It is a checksum of the type of the symbol, including all sub-types
Petr Pavlu 6b6744
involved. Symbols that a module imports are associated with the identical
Petr Pavlu 6b6744
checksum.
Michal Marek a6afa1
Petr Pavlu 6b6744
When a module is loaded, the kernel makes sure that the checksums of the symbols
Petr Pavlu 6b6744
imported by the module match the checksums of the target symbols. In case of
Petr Pavlu 6b6744
a mismatch, the kernel rejects to load the module.
Petr Pavlu 7a70ee
Petr Pavlu 7a70ee
Kernel packages additionally set an RPM dependency in the form
Petr Pavlu bbaa1b
`ksym($FLAVOR:$SYMBOL) = $CHECKSUM` for every exported/imported symbol.
Petr Pavlu 7a70ee
A Provides dependency is present for each symbol exported by kernel binaries in
Petr Pavlu 7a70ee
the package and a Requires dependency is recorded for each imported symbol. This
Petr Pavlu 7a70ee
mechanism allows checking module dependencies early at the package installation
Petr Pavlu 7a70ee
time.
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Kernel ABI changes
Petr Pavlu 6f0a5c
------------------
Michal Marek a6afa1
Petr Pavlu 1d9753
SUSE kernels maintain stable kABI during a lifetime of each service pack. An
Petr Pavlu 1d9753
exported symbol can be changed only if a strong reason arises.
Michal Marek a6afa1
Petr Pavlu 1d9753
When building an RPM kernel package, the build logic checks the modversions of
Petr Pavlu 1d9753
the resulting kernel and compares them against the reference stored in
Petr Pavlu 6b6744
`kabi/$ARCH/symvers-$FLAVOR` and `kabi/$ARCH/symtypes-$FLAVOR`. If any updated
Petr Pavlu 6b6744
or removed symbol is found, the build reports an error and aborts. Symbols
Petr Pavlu bbaa1b
explicitly ignored in `kabi/severities` are excluded from this check. See
Petr Pavlu bbaa1b
`rpm/kabi.pl` for details.
Michal Marek a6afa1
Petr Pavlu bbaa1b
To update the reference files, use `scripts/update-symvers`:
Michal Marek a6afa1
Petr Pavlu 1d9753
    $ ./scripts/update-symvers kernel-default-5.14.21-150500.55.31.1.x86_64.rpm \
Petr Pavlu 1d9753
          kernel-default-devel-5.14.21-150500.55.31.1.x86_64.rpm ...
Michal Marek a6afa1
Petr Pavlu 1d9753
Updating the kabi files is typically done by the branch maintainers. Please
Petr Pavlu 1d9753
always ask them for permission before touching these files.
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Ignoring kernel ABI changes
Michal Marek a6afa1
---------------------------
Michal Marek a6afa1
Petr Pavlu 61dabd
It might sometimes be needed to tolerate particular kernel ABI changes and not
Petr Pavlu 6b6744
abort the build. At the same time, you may not want to update the reference
Petr Pavlu 6b6744
symvers and symtypes files in order to monitor the relative changes.
Petr Pavlu 61dabd
Petr Pavlu 6b6744
A specific kernel can be marked so that kernel ABI changes are ignored. This is
Petr Pavlu 6b6744
done by creating a `kabi/$ARCH/ignore-$FLAVOR` file, for example,
Petr Pavlu 6b6744
`kabi/x86_64/ignore-default`. The kernel ABI checks are still performed, but the
Petr Pavlu 6b6744
build does not abort if a problem is found. The content of the ignore file does
Petr Pavlu 6b6744
not matter.
Michal Marek a6afa1
Petr Pavlu 6b6744
All kernel ABI changes in all kernel packages can be ignored by creating a file
Petr Pavlu 6b6744
called `IGNORE-KABI-BADNESS` in the `kernel-source/` sub-directory of the
Petr Pavlu 6b6744
repository that `scripts/tar-up.sh` creates. Doing this may occasionally be
Petr Pavlu 6b6744
necessary for PTF kernels.
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Embargoed patches
Petr Pavlu 6f0a5c
-----------------
Michal Marek a6afa1
Petr Pavlu 6b6744
At certain times during development, the kernel may include "embargoed" patches,
Petr Pavlu 6b6744
which are patches that must not be made available to parties outside of SUSE
Petr Pavlu 6b6744
before an agreed-upon time. Such patches usually have a date of publication that
Petr Pavlu 6b6744
has been coordinated among Linux distributors and other stakeholders. These
Petr Pavlu 6b6744
patches must not be committed to the usual branches, because these are pushed to
Petr Pavlu 6b6744
a public mirror, but instead to a branch named with an \_EMBARGO suffix, for
Petr Pavlu 6b6744
example, SLE15-SP5\_EMBARGO. The KOTD scripts will testbuild such branches but
Petr Pavlu 6b6744
won't publish them. Once the fix becomes public, the branch needs to be merged
Petr Pavlu 6b6744
back info the "mainline" branch.
Michal Marek a6afa1
Michal Marek a6afa1
Petr Pavlu 6f0a5c
Related information
Petr Pavlu 6f0a5c
-------------------
Michal Marek a6afa1
Michal Marek 66f9d2
Internal:
Petr Pavlu bbaa1b
Petr Pavlu 7c8a1e
* <https://wiki.suse.net/index.php/SUSE-Labs_Publications/Kernel_Building>,
Petr Pavlu 7c8a1e
* <https://wiki.suse.net/index.php/SUSE-Labs_Publications/kernel_patches_rules>.
Michal Marek 66f9d2
Michal Marek 66f9d2
Public:
Petr Pavlu bbaa1b
Petr Pavlu 7c8a1e
* <https://kernel.suse.com/>,
Petr Pavlu 7c8a1e
* <https://en.opensuse.org/Kernel>.