-
Notifications
You must be signed in to change notification settings - Fork 53.4k
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
lab04: exercises: fixed access variable reset #535
Conversation
The Linux kernel labs documentation is a collection of "labs" for various device driver topics. For each topic there are two parts: a walk-through which explain the basic concepts and a hands-on part which contains a few exercises. This commit also adds the labs infrastructure which allows us to build and test kernel modules in a qemu environment. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add the documentation and templates for the kernel modules lab which focuses on: creating simple modules; describing the process of kernel module compilation; presenting how a module can be used with a kernel; simple kernel debugging methods Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add the documentation and templates for the kernel modules lab which focuses on: familiarizing with the basic Linux kernel API, describing memory allocation and locking mechanism. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the device drivers labs which focuses on: understanding the concepts behind character device drivers; understading the various operations that can be performed on character device drivers; working with waiting queues. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the I/O access and interrupts lab which focuses on: communication with pheripheral devices; implementing interrupt handlers; synchronizing interrupts with process context. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the deffered work lab which focuses on: understanding deffered work; implementation of common tasks that use deferred work; understanding the peculiarities of synchronization for deferred work. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the memory mapping lab which focuses on: understanding the address space mapping mechanism; learn about the most important structures related to memory mapping. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentationa and templates for the Linux device module lab which focuses on understanding the main Linux abstraction that deals with devices: devices, buses, drivers, subsystems and classes. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
The Linux kernel labs documentation is a collection of "labs" for various device driver topics. For each topic there are two parts: a walk-through which explain the basic concepts and a hands-on part which contains a few exercises. This commit also adds the labs infrastructure which allows us to build and test kernel modules in a qemu environment. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add the documentation and templates for the kernel modules lab which focuses on: creating simple modules; describing the process of kernel module compilation; presenting how a module can be used with a kernel; simple kernel debugging methods Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add the documentation and templates for the kernel modules lab which focuses on: familiarizing with the basic Linux kernel API, describing memory allocation and locking mechanism. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the device drivers labs which focuses on: understanding the concepts behind character device drivers; understading the various operations that can be performed on character device drivers; working with waiting queues. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the I/O access and interrupts lab which focuses on: communication with pheripheral devices; implementing interrupt handlers; synchronizing interrupts with process context. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the deffered work lab which focuses on: understanding deffered work; implementation of common tasks that use deferred work; understanding the peculiarities of synchronization for deferred work. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentation and templates for the memory mapping lab which focuses on: understanding the address space mapping mechanism; learn about the most important structures related to memory mapping. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Add documentationa and templates for the Linux device module lab which focuses on understanding the main Linux abstraction that deals with devices: devices, buses, drivers, subsystems and classes. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro> Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Kernel labs v4.15
Since we are going to add lectures change the top level directory name from labs to teaching/labs. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Enable hieroglyph extension if it is installed on the host and add a slides documentation target. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
This is based on the psphinxcontrib.ditaa pip package and we add it localy since we need some fixes to properly render images in hieroglpyh slides. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Add reqirements.txt and run pip in the doc target to make sure we have all required sphinx dependencies. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
This is split into two parts: one the is specific to cs.pub.ro and another one that is generic. Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Lklabs lectures intro
Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Add docs building and publishing support via Circle CI
The conf.py needs to be at the top of the namespace directory so move it where it belongs. And since we now have multiple subdirectories and includes are relative to current file directory, the common substitution will not longer work for all files. To fix this, just move the contents of subst.hrst directly to rst_epilog in conf.py. Fixes the following errors: deferred_work.rst:721: ERROR: Undefined substitution referenced: "LXR". deferred_work.rst:721: ERROR: Unknown target name: "lxr". interrupts.rst:688: ERROR: Undefined substitution referenced: "LXR". interrupts.rst:688: ERROR: Unknown target name: "lxr". kernel_api.rst:739: ERROR: Unexpected indentation. kernel_api.rst:582: ERROR: Undefined substitution referenced: "LXR". kernel_api.rst:582: ERROR: Unknown target name: "lxr". kernel_modules.rst:810: ERROR: Undefined substitution referenced: "LXR". kernel_modules.rst:939: ERROR: Undefined substitution referenced: "LXR". kernel_modules.rst:810: ERROR: Unknown target name: "lxr". kernel_modules.rst:939: ERROR: Unknown target name: "lxr". Signed-off-by: Octavian Purdila <tavi@cs.pub.ro>
Documentation: move teaching/labs/conf.py to teaching/
Introduction lab presents few ways to navigate the kernel source code (LXR and cscope) and how to perform static and dynamic kernel analysis using gdb, vmlinux and /proc/kcore.
* update links to point to 4.15.7 kernel API * use c constructs (:c:type:``, :c:macro:`` etc) to highlight structures, macros etc Signed-off-by: Anda Nicolae <nicolae.anda@gmail.com>
teaching: labs: introduction: Fix typos
* removed links to lxr kernel API * used :c:type:``, :c:data:``, :c:func:``, etc in all lab, when appropriate * reformulated documentation when needed * added missing list evolution image Signed-off-by: Anda Nicolae <nicolae.anda@gmail.com>
lab03: kernel_api: update exercises requirements
Signed-off-by: Daniel Baluta <daniel.baluta@gmail.com>
Documentation: lectures: Add draft 'Interrupts' lecture
lab04: exercises: Fix TODO numbers.
Add tracer assignment
Hi @crmares! Thanks for your contribution to the Linux kernel! Linux kernel development happens on mailing lists, rather than on GitHub - this GitHub repository is a read-only mirror that isn't used for accepting contributions. So that your change can become part of Linux, please email it to us as a patch. Sending patches isn't quite as simple as sending a pull request, but fortunately it is a well documented process. Here's what to do:
How do I format my contribution?The Linux kernel community is notoriously picky about how contributions are formatted and sent. Fortunately, they have documented their expectations. Firstly, all contributions need to be formatted as patches. A patch is a plain text document showing the change you want to make to the code, and documenting why it is a good idea. You can create patches with Secondly, patches need 'commit messages', which is the human-friendly documentation explaining what the change is and why it's necessary. Thirdly, changes have some technical requirements. There is a Linux kernel coding style, and there are licensing requirements you need to comply with. Both of these are documented in the Submitting Patches documentation that is part of the kernel. Note that you will almost certainly have to modify your existing git commits to satisfy these requirements. Don't worry: there are many guides on the internet for doing this. Who do I send my contribution to?The Linux kernel is composed of a number of subsystems. These subsystems are maintained by different people, and have different mailing lists where they discuss proposed changes. If you don't already know what subsystem your change belongs to, the
Make sure that your list of recipients includes a mailing list. If you can't find a more specific mailing list, then LKML - the Linux Kernel Mailing List - is the place to send your patches. It's not usually necessary to subscribe to the mailing list before you send the patches, but if you're interested in kernel development, subscribing to a subsystem mailing list is a good idea. (At this point, you probably don't need to subscribe to LKML - it is a very high traffic list with about a thousand messages per day, which is often not useful for beginners.) How do I send my contribution?Use For more information about using How do I get help if I'm stuck?Firstly, don't get discouraged! There are an enormous number of resources on the internet, and many kernel developers who would like to see you succeed. Many issues - especially about how to use certain tools - can be resolved by using your favourite internet search engine. If you can't find an answer, there are a few places you can turn:
If you get really, really stuck, you could try the owners of this bot, @daxtens and @ajdlinux. Please be aware that we do have full-time jobs, so we are almost certainly the slowest way to get answers! I sent my patch - now what?You wait. You can check that your email has been received by checking the mailing list archives for the mailing list you sent your patch to. Messages may not be received instantly, so be patient. Kernel developers are generally very busy people, so it may take a few weeks before your patch is looked at. Then, you keep waiting. Three things may happen:
Further information
Happy hacking! This message was posted by a bot - if you have any questions or suggestions, please talk to my owners, @ajdlinux and @daxtens, or raise an issue at https://github.com/ajdlinux/KernelPRBot. |
When VMA based swap readahead is used, which is default if all swap devices are SSD, swapoff will trigger general protection fault as follow, because vmf->pmd isn't initialized when calling swapin_readahead(). This fix could be folded into the patch: mm, swap: rid swapoff of quadratic complexity in -mm patchset. general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC CPU: 3 PID: 352 Comm: swapoff Not tainted 4.20.0-rc5-mm1-kvm+ torvalds#535 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-1.fc28 04/01/2014 RIP: 0010:swapin_readahead+0xb7/0x39b Code: ff 01 00 00 40 f6 c7 80 49 0f 45 d0 48 21 d7 48 ba 00 00 00 00 80 88 ff ff 48 8d 14 f2 48 01 d7 48 ba ff ff ff ff ff ff ff ef <48> 39 17 0f 87 5d 01 00 00 49 8b 95 b0 00 00 00 48 85 d2 75 05 ba RSP: 0018:ffffc900004c3ca0 EFLAGS: 00010207 RAX: 000055de5d252000 RBX: 000000055de5d252 RCX: 0000000000000003 RDX: efffffffffffffff RSI: 0000000000000052 RDI: 000f0bc11c600290 RBP: ffffc900004c3d30 R08: 000fffffffe00000 R09: ffffc900004c3ea0 R10: ffffc900004c3d50 R11: 0000000000000002 R12: ffffc900004c3da8 R13: ffff88803b71d780 R14: 0000000000000001 R15: ffff88803b71d780 FS: 00007f87c20e02c0(0000) GS:ffff88803e800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055a439825398 CR3: 000000003b49a004 CR4: 0000000000360ea0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? list_add_tail_rcu+0x19/0x31 ? __lock_acquire+0xd61/0xe1c ? find_held_lock+0x2b/0x6e ? unuse_pte_range+0xe9/0x429 unuse_pte_range+0xe9/0x429 ? find_held_lock+0x2b/0x6e ? __lock_is_held+0x40/0x71 try_to_unuse+0x311/0x54b __do_sys_swapoff+0x254/0x625 ? lockdep_hardirqs_off+0x29/0x86 ? do_syscall_64+0x12/0x65 do_syscall_64+0x57/0x65 entry_SYSCALL_64_after_hwframe+0x49/0xbe Link: http://lkml.kernel.org/r/20181211084609.19553-1-ying.huang@intel.com Signed-off-by: "Huang, Ying" <ying.huang@intel.com> Cc: Vineeth Remanan Pillai <vpillai@digitalocean.com> Cc: Kelley Nielsen <kelleynnn@gmail.com> Cc: Rik van Riel <riel@surriel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Hugh Dickins <hughd@google.com> Cc: William Kucharski <william.kucharski@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
When VMA based swap readahead is used, which is default if all swap devices are SSD, swapoff will trigger general protection fault as follow, because vmf->pmd isn't initialized when calling swapin_readahead(). This fix could be folded into the patch: mm, swap: rid swapoff of quadratic complexity in -mm patchset. general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC CPU: 3 PID: 352 Comm: swapoff Not tainted 4.20.0-rc5-mm1-kvm+ torvalds#535 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-1.fc28 04/01/2014 RIP: 0010:swapin_readahead+0xb7/0x39b Code: ff 01 00 00 40 f6 c7 80 49 0f 45 d0 48 21 d7 48 ba 00 00 00 00 80 88 ff ff 48 8d 14 f2 48 01 d7 48 ba ff ff ff ff ff ff ff ef <48> 39 17 0f 87 5d 01 00 00 49 8b 95 b0 00 00 00 48 85 d2 75 05 ba RSP: 0018:ffffc900004c3ca0 EFLAGS: 00010207 RAX: 000055de5d252000 RBX: 000000055de5d252 RCX: 0000000000000003 RDX: efffffffffffffff RSI: 0000000000000052 RDI: 000f0bc11c600290 RBP: ffffc900004c3d30 R08: 000fffffffe00000 R09: ffffc900004c3ea0 R10: ffffc900004c3d50 R11: 0000000000000002 R12: ffffc900004c3da8 R13: ffff88803b71d780 R14: 0000000000000001 R15: ffff88803b71d780 FS: 00007f87c20e02c0(0000) GS:ffff88803e800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055a439825398 CR3: 000000003b49a004 CR4: 0000000000360ea0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? list_add_tail_rcu+0x19/0x31 ? __lock_acquire+0xd61/0xe1c ? find_held_lock+0x2b/0x6e ? unuse_pte_range+0xe9/0x429 unuse_pte_range+0xe9/0x429 ? find_held_lock+0x2b/0x6e ? __lock_is_held+0x40/0x71 try_to_unuse+0x311/0x54b __do_sys_swapoff+0x254/0x625 ? lockdep_hardirqs_off+0x29/0x86 ? do_syscall_64+0x12/0x65 do_syscall_64+0x57/0x65 entry_SYSCALL_64_after_hwframe+0x49/0xbe Link: http://lkml.kernel.org/r/20181211084609.19553-1-ying.huang@intel.com Signed-off-by: "Huang, Ying" <ying.huang@intel.com> Cc: Vineeth Remanan Pillai <vpillai@digitalocean.com> Cc: Kelley Nielsen <kelleynnn@gmail.com> Cc: Rik van Riel <riel@surriel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Hugh Dickins <hughd@google.com> Cc: William Kucharski <william.kucharski@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
When VMA based swap readahead is used, which is default if all swap devices are SSD, swapoff will trigger general protection fault as follow, because vmf->pmd isn't initialized when calling swapin_readahead(). This fix could be folded into the patch: mm, swap: rid swapoff of quadratic complexity in -mm patchset. general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC CPU: 3 PID: 352 Comm: swapoff Not tainted 4.20.0-rc5-mm1-kvm+ torvalds#535 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-1.fc28 04/01/2014 RIP: 0010:swapin_readahead+0xb7/0x39b Code: ff 01 00 00 40 f6 c7 80 49 0f 45 d0 48 21 d7 48 ba 00 00 00 00 80 88 ff ff 48 8d 14 f2 48 01 d7 48 ba ff ff ff ff ff ff ff ef <48> 39 17 0f 87 5d 01 00 00 49 8b 95 b0 00 00 00 48 85 d2 75 05 ba RSP: 0018:ffffc900004c3ca0 EFLAGS: 00010207 RAX: 000055de5d252000 RBX: 000000055de5d252 RCX: 0000000000000003 RDX: efffffffffffffff RSI: 0000000000000052 RDI: 000f0bc11c600290 RBP: ffffc900004c3d30 R08: 000fffffffe00000 R09: ffffc900004c3ea0 R10: ffffc900004c3d50 R11: 0000000000000002 R12: ffffc900004c3da8 R13: ffff88803b71d780 R14: 0000000000000001 R15: ffff88803b71d780 FS: 00007f87c20e02c0(0000) GS:ffff88803e800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055a439825398 CR3: 000000003b49a004 CR4: 0000000000360ea0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? list_add_tail_rcu+0x19/0x31 ? __lock_acquire+0xd61/0xe1c ? find_held_lock+0x2b/0x6e ? unuse_pte_range+0xe9/0x429 unuse_pte_range+0xe9/0x429 ? find_held_lock+0x2b/0x6e ? __lock_is_held+0x40/0x71 try_to_unuse+0x311/0x54b __do_sys_swapoff+0x254/0x625 ? lockdep_hardirqs_off+0x29/0x86 ? do_syscall_64+0x12/0x65 do_syscall_64+0x57/0x65 entry_SYSCALL_64_after_hwframe+0x49/0xbe Link: http://lkml.kernel.org/r/20181211084609.19553-1-ying.huang@intel.com Signed-off-by: "Huang, Ying" <ying.huang@intel.com> Cc: Vineeth Remanan Pillai <vpillai@digitalocean.com> Cc: Kelley Nielsen <kelleynnn@gmail.com> Cc: Rik van Riel <riel@surriel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Hugh Dickins <hughd@google.com> Cc: William Kucharski <william.kucharski@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Move all allocations outside of the regulator_lock()ed section. ====================================================== WARNING: possible circular locking dependency detected 5.7.13+ torvalds#535 Not tainted ------------------------------------------------------ f2fs_discard-179:7/702 is trying to acquire lock: c0e5d920 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x54/0x2c0 but task is already holding lock: cb95b080 (&dcc->cmd_lock){+.+.}-{3:3}, at: __issue_discard_cmd+0xec/0x5f8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: [...] -> #3 (fs_reclaim){+.+.}-{0:0}: fs_reclaim_acquire.part.11+0x40/0x50 fs_reclaim_acquire+0x24/0x28 __kmalloc_track_caller+0x54/0x218 kstrdup+0x40/0x5c create_regulator+0xf4/0x368 regulator_resolve_supply+0x1a0/0x200 regulator_register+0x9c8/0x163c [...] other info that might help us debug this: Chain exists of: regulator_list_mutex --> &sit_i->sentry_lock --> &dcc->cmd_lock [...] Cc: stable@vger.kernel.org Fixes: f8702f9 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Move all allocations outside of the regulator_lock()ed section. ====================================================== WARNING: possible circular locking dependency detected 5.7.13+ torvalds#535 Not tainted ------------------------------------------------------ f2fs_discard-179:7/702 is trying to acquire lock: c0e5d920 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x54/0x2c0 but task is already holding lock: cb95b080 (&dcc->cmd_lock){+.+.}-{3:3}, at: __issue_discard_cmd+0xec/0x5f8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: [...] -> #3 (fs_reclaim){+.+.}-{0:0}: fs_reclaim_acquire.part.11+0x40/0x50 fs_reclaim_acquire+0x24/0x28 __kmalloc_track_caller+0x54/0x218 kstrdup+0x40/0x5c create_regulator+0xf4/0x368 regulator_resolve_supply+0x1a0/0x200 regulator_register+0x9c8/0x163c [...] other info that might help us debug this: Chain exists of: regulator_list_mutex --> &sit_i->sentry_lock --> &dcc->cmd_lock [...] Cc: stable@vger.kernel.org Fixes: f8702f9 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Move all allocations outside of the regulator_lock()ed section. ====================================================== WARNING: possible circular locking dependency detected 5.7.13+ torvalds#535 Not tainted ------------------------------------------------------ f2fs_discard-179:7/702 is trying to acquire lock: c0e5d920 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x54/0x2c0 but task is already holding lock: cb95b080 (&dcc->cmd_lock){+.+.}-{3:3}, at: __issue_discard_cmd+0xec/0x5f8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: [...] -> #3 (fs_reclaim){+.+.}-{0:0}: fs_reclaim_acquire.part.11+0x40/0x50 fs_reclaim_acquire+0x24/0x28 __kmalloc_track_caller+0x54/0x218 kstrdup+0x40/0x5c create_regulator+0xf4/0x368 regulator_resolve_supply+0x1a0/0x200 regulator_register+0x9c8/0x163c [...] other info that might help us debug this: Chain exists of: regulator_list_mutex --> &sit_i->sentry_lock --> &dcc->cmd_lock [...] Fixes: f8702f9 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/6eebc99b2474f4ffaa0405b15178ece0e7e4f608.1597195321.git.mirq-linux@rere.qmqm.pl Signed-off-by: Mark Brown <broonie@kernel.org>
commit 87fe29b upstream. Move all allocations outside of the regulator_lock()ed section. ====================================================== WARNING: possible circular locking dependency detected 5.7.13+ torvalds#535 Not tainted ------------------------------------------------------ f2fs_discard-179:7/702 is trying to acquire lock: c0e5d920 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x54/0x2c0 but task is already holding lock: cb95b080 (&dcc->cmd_lock){+.+.}-{3:3}, at: __issue_discard_cmd+0xec/0x5f8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: [...] -> #3 (fs_reclaim){+.+.}-{0:0}: fs_reclaim_acquire.part.11+0x40/0x50 fs_reclaim_acquire+0x24/0x28 __kmalloc_track_caller+0x54/0x218 kstrdup+0x40/0x5c create_regulator+0xf4/0x368 regulator_resolve_supply+0x1a0/0x200 regulator_register+0x9c8/0x163c [...] other info that might help us debug this: Chain exists of: regulator_list_mutex --> &sit_i->sentry_lock --> &dcc->cmd_lock [...] Fixes: f8702f9 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/6eebc99b2474f4ffaa0405b15178ece0e7e4f608.1597195321.git.mirq-linux@rere.qmqm.pl Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
BugLink: https://bugs.launchpad.net/bugs/1896078 commit 87fe29b upstream. Move all allocations outside of the regulator_lock()ed section. ====================================================== WARNING: possible circular locking dependency detected 5.7.13+ torvalds#535 Not tainted ------------------------------------------------------ f2fs_discard-179:7/702 is trying to acquire lock: c0e5d920 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x54/0x2c0 but task is already holding lock: cb95b080 (&dcc->cmd_lock){+.+.}-{3:3}, at: __issue_discard_cmd+0xec/0x5f8 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: [...] -> #3 (fs_reclaim){+.+.}-{0:0}: fs_reclaim_acquire.part.11+0x40/0x50 fs_reclaim_acquire+0x24/0x28 __kmalloc_track_caller+0x54/0x218 kstrdup+0x40/0x5c create_regulator+0xf4/0x368 regulator_resolve_supply+0x1a0/0x200 regulator_register+0x9c8/0x163c [...] other info that might help us debug this: Chain exists of: regulator_list_mutex --> &sit_i->sentry_lock --> &dcc->cmd_lock [...] Fixes: f8702f9 ("regulator: core: Use ww_mutex for regulators locking") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/6eebc99b2474f4ffaa0405b15178ece0e7e4f608.1597195321.git.mirq-linux@rere.qmqm.pl Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
This commit fixes the following checkpatch.pl errors: ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#535: FILE: ./hal/HalBtcOutSrc.h:535: +void EXhalbtcoutsrc_PowerOnSetting(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#536: FILE: ./hal/HalBtcOutSrc.h:536: +void EXhalbtcoutsrc_InitHwConfig(struct BTC_COEXIST * pBtCoexist, u8 bWifiOnly); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#537: FILE: ./hal/HalBtcOutSrc.h:537: +void EXhalbtcoutsrc_InitCoexDm(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#538: FILE: ./hal/HalBtcOutSrc.h:538: +void EXhalbtcoutsrc_IpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#539: FILE: ./hal/HalBtcOutSrc.h:539: +void EXhalbtcoutsrc_LpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#540: FILE: ./hal/HalBtcOutSrc.h:540: +void EXhalbtcoutsrc_ScanNotify(struct BTC_COEXIST * pBtCoexist, u8 type); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#541: FILE: ./hal/HalBtcOutSrc.h:541: +void EXhalbtcoutsrc_ConnectNotify(struct BTC_COEXIST * pBtCoexist, u8 action); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#543: FILE: ./hal/HalBtcOutSrc.h:543: + struct BTC_COEXIST * pBtCoexist, enum RT_MEDIA_STATUS mediaStatus ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#545: FILE: ./hal/HalBtcOutSrc.h:545: +void EXhalbtcoutsrc_SpecialPacketNotify(struct BTC_COEXIST * pBtCoexist, u8 pktType); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#547: FILE: ./hal/HalBtcOutSrc.h:547: + struct BTC_COEXIST * pBtCoexist, u8 *tmpBuf, u8 length ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#549: FILE: ./hal/HalBtcOutSrc.h:549: +void EXhalbtcoutsrc_HaltNotify(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#550: FILE: ./hal/HalBtcOutSrc.h:550: +void EXhalbtcoutsrc_PnpNotify(struct BTC_COEXIST * pBtCoexist, u8 pnpState); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#551: FILE: ./hal/HalBtcOutSrc.h:551: +void EXhalbtcoutsrc_Periodical(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#555: FILE: ./hal/HalBtcOutSrc.h:555: +void EXhalbtcoutsrc_DisplayBtCoexInfo(struct BTC_COEXIST * pBtCoexist); Signed-off-by: Marco Cesati <marcocesati@gmail.com>
This commit fixes the following checkpatch.pl errors: ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#535: FILE: ./hal/HalBtcOutSrc.h:535: +void EXhalbtcoutsrc_PowerOnSetting(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#536: FILE: ./hal/HalBtcOutSrc.h:536: +void EXhalbtcoutsrc_InitHwConfig(struct BTC_COEXIST * pBtCoexist, u8 bWifiOnly); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#537: FILE: ./hal/HalBtcOutSrc.h:537: +void EXhalbtcoutsrc_InitCoexDm(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#538: FILE: ./hal/HalBtcOutSrc.h:538: +void EXhalbtcoutsrc_IpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#539: FILE: ./hal/HalBtcOutSrc.h:539: +void EXhalbtcoutsrc_LpsNotify(struct BTC_COEXIST * pBtCoexist, u8 type); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#540: FILE: ./hal/HalBtcOutSrc.h:540: +void EXhalbtcoutsrc_ScanNotify(struct BTC_COEXIST * pBtCoexist, u8 type); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#541: FILE: ./hal/HalBtcOutSrc.h:541: +void EXhalbtcoutsrc_ConnectNotify(struct BTC_COEXIST * pBtCoexist, u8 action); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#543: FILE: ./hal/HalBtcOutSrc.h:543: + struct BTC_COEXIST * pBtCoexist, enum RT_MEDIA_STATUS mediaStatus ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#545: FILE: ./hal/HalBtcOutSrc.h:545: +void EXhalbtcoutsrc_SpecialPacketNotify(struct BTC_COEXIST * pBtCoexist, u8 pktType); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#547: FILE: ./hal/HalBtcOutSrc.h:547: + struct BTC_COEXIST * pBtCoexist, u8 *tmpBuf, u8 length ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#549: FILE: ./hal/HalBtcOutSrc.h:549: +void EXhalbtcoutsrc_HaltNotify(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#550: FILE: ./hal/HalBtcOutSrc.h:550: +void EXhalbtcoutsrc_PnpNotify(struct BTC_COEXIST * pBtCoexist, u8 pnpState); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#551: FILE: ./hal/HalBtcOutSrc.h:551: +void EXhalbtcoutsrc_Periodical(struct BTC_COEXIST * pBtCoexist); ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" torvalds#555: FILE: ./hal/HalBtcOutSrc.h:555: +void EXhalbtcoutsrc_DisplayBtCoexInfo(struct BTC_COEXIST * pBtCoexist); Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Marco Cesati <marcocesati@gmail.com> Link: https://lore.kernel.org/r/20210315170618.2566-7-marcocesati@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sync with v5.15-rc7
ANBZ: torvalds#535 commit b6b556a ("ipv6: use jhash2() in rt6_exception_hash()") Faster jhash2() can be used instead of jhash(), since IPv6 addresses have the needed alignment requirement. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Dust Li <dust.li@linux.alibaba.com>
ANBZ: torvalds#535 commit 4785305 ("ipv6: use siphash in rt6_exception_hash()") A group of security researchers brought to our attention the weakness of hash function used in rt6_exception_hash() Lets use siphash instead of Jenkins Hash, to considerably reduce security risks. Following patch deals with IPv4. Fixes: 35732d0 ("ipv6: introduce a hash table to store dst cache") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Keyu Man <kman001@ucr.edu> Cc: Wei Wang <weiwan@google.com> Cc: Martin KaFai Lau <kafai@fb.com> Acked-by: Wei Wang <weiwan@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Dust Li <dust.li@linux.alibaba.com>
ANBZ: torvalds#535 commit a00df2c ("ipv6: make exception cache less predictible") Even after commit 4785305 ("ipv6: use siphash in rt6_exception_hash()"), an attacker can still use brute force to learn some secrets from a victim linux host. One way to defeat these attacks is to make the max depth of the hash table bucket a random value. Before this patch, each bucket of the hash table used to store exceptions could contain 6 items under attack. After the patch, each bucket would contains a random number of items, between 6 and 10. The attacker can no longer infer secrets. This is slightly increasing memory size used by the hash table, we do not expect this to be a problem. Following patch is dealing with the same issue in IPv4. Fixes: 35732d0 ("ipv6: introduce a hash table to store dst cache") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Keyu Man <kman001@ucr.edu> Cc: Wei Wang <weiwan@google.com> Cc: Martin KaFai Lau <kafai@fb.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> [Xuan Zhuo: fix minor conflict] Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Dust Li <dust.li@linux.alibaba.com>
ANBZ: torvalds#535 commit 5af6889 ("net: clean up codestyle") This is a pure codestyle cleanup patch. No functional change intended. Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Dust Li <dust.li@linux.alibaba.com>
ANBZ: torvalds#535 commit 6457378 ("ipv4: use siphash instead of Jenkins in fnhe_hashfun()") A group of security researchers brought to our attention the weakness of hash function used in fnhe_hashfun(). Lets use siphash instead of Jenkins Hash, to considerably reduce security risks. Also remove the inline keyword, this really is distracting. Fixes: d546c62 ("ipv4: harden fnhe_hashfun()") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Keyu Man <kman001@ucr.edu> Cc: Willy Tarreau <w@1wt.eu> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Dust Li <dust.li@linux.alibaba.com>
ANBZ: torvalds#535 commit 67d6d68 ("ipv4: make exception cache less predictible") Even after commit 6457378 ("ipv4: use siphash instead of Jenkins in fnhe_hashfun()"), an attacker can still use brute force to learn some secrets from a victim linux host. One way to defeat these attacks is to make the max depth of the hash table bucket a random value. Before this patch, each bucket of the hash table used to store exceptions could contain 6 items under attack. After the patch, each bucket would contains a random number of items, between 6 and 10. The attacker can no longer infer secrets. This is slightly increasing memory size used by the hash table, by 50% in average, we do not expect this to be a problem. This patch is more complex than the prior one (IPv6 equivalent), because IPv4 was reusing the oldest entry. Since we need to be able to evict more than one entry per update_or_create_fnhe() call, I had to replace fnhe_oldest() with fnhe_remove_oldest(). Also note that we will queue extra kfree_rcu() calls under stress, which hopefully wont be a too big issue. Fixes: 4895c77 ("ipv4: Add FIB nexthop exceptions.") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Keyu Man <kman001@ucr.edu> Cc: Willy Tarreau <w@1wt.eu> Signed-off-by: David S. Miller <davem@davemloft.net> Reviewed-by: David Ahern <dsahern@kernel.org> Tested-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Dust Li <dust.li@linux.alibaba.com>
atomic_inc will not reset the access variable, and so, the resource will be busy at any second call. To solve, atomic_dec, or simply, atomic_set to 0, as implied in the TODO.