)]}'
{
  "commit": "4f0003e2971caf19a29381abfb68d65fd670507b",
  "tree": "5f1cec562d19069ab157bcee9d2c7000145e5432",
  "parents": [
    "adeee381470c0abd89f4789aa0a51a0942ade37a"
  ],
  "author": {
    "name": "Luis R. Rodriguez",
    "email": "mcgrof@kernel.org",
    "time": "Fri Nov 11 10:35:35 2016 -0800"
  },
  "committer": {
    "name": "Luis R. Rodriguez",
    "email": "mcgrof@kernel.org",
    "time": "Thu Dec 08 10:40:48 2016 -0800"
  },
  "message": "kmod: add a sanity check on module loading\n\nkmod has an optimization in place whereby if a some kernel code\nuses request_module() on a module already loaded we never bother\nuserspace as the module already is loaded. This is not true for\nget_fs_type() though as it uses aliases.\n\nAdditionally kmod \u003c\u003d v19 was broken -- it returns 0 to modprobe calls,\nassuming the kernel module is built-in, where really we have a race as\nthe module starts forming. kmod \u003c\u003d v19 has incorrect userspace heuristics,\na userspace kmod fix is available for it:\n\nhttp://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/libkmod/libkmod-module.c?id\u003dfd44a98ae2eb5eb32161088954ab21e58e19dfc4\n\nThis changes kmod to address both:\n\n o Provides the alias optimization for get_fs_type() so modules already\n   loaded do not get re-requested.\n\n o Provides a sanity test to verify modprobe\u0027s work\n\nThis is important given how any get_fs_type() users assert success\nmeans we\u0027re ready to go, and tests with the new test_kmod stress driver\nreveal that request_module() and get_fs_type() might fail for a few\nother reasons. You don\u0027t need old kmod to fail on request_module() or\nget_fs_type(), with the right system setup, these calls *can* fail\ntoday.\n\nAlthough this does get us in the business of keeping alias maps in\nkernel, the the work to support and maintain this is trivial.\nAditionally, since it may be important get_fs_type() should not fail on\ncertain systems, this tightens things up a bit more.\n\nThe TL;DR:\n\nkmod \u003c\u003d v19 will return 0 on modprobe calls if you are built-in,\nhowever its heuristics for checking if you are built-in were broken.\n\nIt assumed that having the directory /sys/module/module-name\nbut not having the file /sys/module/module-name/initstate\nis sufficient to assume a module is built-in.\n\nThe kernel loads the inittstate attribute *after* it creates the\ndirectory. This is an issue when modprobe returns 0 for kernel calls\nwhich assumes a return of 0 on request_module() can give you the\nright to assert the module is loaded and live.\n\nWe cannot trust returns of modprobe as 0 in the kernel, we need to\nverify that modules are live if modprobe return 0 but only if modules\n*are* modules. The kernel heuristic we use to determine if a module is\nbuilt-in is that if modprobe returns 0 we know we must be built-in or\na module, but if we are a module clearly we must have a lingering kmod\ndangling on our linked list. If there is no modules there we are *somewhat*\ncertain the module must be built in.\n\nThis is not enough though... we cannot easily work around this since the\nkernel can use aliases to userspace for modules calls. For instance\nfs/namespace.c uses fs-modulename for filesystesms on get_fs_type(), so\nthese need to be taken into consideration as well.\n\nUsing kmod \u003c\u003d 19 will give you a NULL get_fs_type() return even though\nthe module was loaded... That is a corner case, there are other failures\nfor request_module() though -- the other failures are not easy to\nreproduce though but fortunately we have a stress test driver to help\nwith that now. Use the following tests:\n\n # tools/testing/selftests/kmod/kmod.sh -t 0008\n # tools/testing/selftests/kmod/kmod.sh -t 0009\n\nYou can more easily see this error if you have kmod \u003c\u003d v19 installed.\n\nYou will need to install kmod \u003c\u003d v19, be sure to install its modprobe\ninto /sbin/ as by default the \u0027make install\u0027 target does not replace\nyour own.\n\nThis test helps cure test_kmod cases 0008 0009 so enable them.\n\nReported-by: Martin Wilck \u003cmartin.wilck@suse.com\u003e\nReported-by: Randy Wright \u003crwright@hpe.com\u003e\nSigned-off-by: Luis R. Rodriguez \u003cmcgrof@kernel.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "a0f449f77ed73c376c8e6de352b1e718ce378c4e",
      "old_mode": 33188,
      "old_path": "kernel/kmod.c",
      "new_id": "6bf0feab41d10588e704ab0ecac2c07b93cb55ad",
      "new_mode": 33188,
      "new_path": "kernel/kmod.c"
    },
    {
      "type": "modify",
      "old_id": "07b735eed5b9c912ab9191b8f5f95e1d5b9337de",
      "old_mode": 33188,
      "old_path": "kernel/module.c",
      "new_id": "5c9f6d3d31ea34d33cf73f142e308c668b083019",
      "new_mode": 33188,
      "new_path": "kernel/module.c"
    }
  ]
}
