<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/char/ipmi, branch v5.18.2</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v5.18.2</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v5.18.2'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-04-29T15:06:52+00:00</updated>
<entry>
<title>ipmi:ipmi_ipmb: Fix null-ptr-deref in ipmi_unregister_smi()</title>
<updated>2022-04-29T15:06:52+00:00</updated>
<author>
<name>Corey Minyard</name>
<email>cminyard@mvista.com</email>
</author>
<published>2022-04-21T11:49:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9cc3aac42566a0021e0ab7c4e9b31667ad75b1e3'/>
<id>urn:sha1:9cc3aac42566a0021e0ab7c4e9b31667ad75b1e3</id>
<content type='text'>
KASAN report null-ptr-deref as follows:

KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
RIP: 0010:ipmi_unregister_smi+0x7d/0xd50 drivers/char/ipmi/ipmi_msghandler.c:3680
Call Trace:
 ipmi_ipmb_remove+0x138/0x1a0 drivers/char/ipmi/ipmi_ipmb.c:443
 ipmi_ipmb_probe+0x409/0xda1 drivers/char/ipmi/ipmi_ipmb.c:548
 i2c_device_probe+0x959/0xac0 drivers/i2c/i2c-core-base.c:563
 really_probe+0x3f3/0xa70 drivers/base/dd.c:541

In ipmi_ipmb_probe(), 'iidev-&gt;intf' is not set before
ipmi_register_smi() success.  And in the error handling case,
ipmi_ipmb_remove() is called to release resources, ipmi_unregister_smi()
is called without check 'iidev-&gt;intf', this will cause KASAN
null-ptr-deref issue.

General kernel style is to allow NULL to be passed into unregister
calls, so fix it that way.  This allows a NULL check to be removed in
other code.

Fixes: 57c9e3c9a374 ("ipmi:ipmi_ipmb: Unregister the SMI on remove")
Reported-by: Hulk Robot &lt;hulkci@huawei.com&gt;
Cc: stable@vger.kernel.org # v5.17+
Cc: Wei Yongjun &lt;weiyongjun1@huawei.com&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
<entry>
<title>ipmi: When handling send message responses, don't process the message</title>
<updated>2022-04-29T15:06:37+00:00</updated>
<author>
<name>Corey Minyard</name>
<email>cminyard@mvista.com</email>
</author>
<published>2022-04-19T17:08:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3d092ef09303e615707dc5755cf0e29b4df7555f'/>
<id>urn:sha1:3d092ef09303e615707dc5755cf0e29b4df7555f</id>
<content type='text'>
A chunk was dropped when the code handling send messages was rewritten.
Those messages shouldn't be processed normally, they are just an
indication that the message was successfully sent and the timers should
be started for the real response that should be coming later.

Add back in the missing chunk to just discard the message and go on.

Fixes: 059747c245f0 ("ipmi: Add support for IPMB direct messages")
Reported-by: Joe Wiese &lt;jwiese@rackspace.com&gt;
Cc: stable@vger.kernel.org # v5.16+
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
Tested-by: Joe Wiese &lt;jwiese@rackspace.com&gt;
</content>
</entry>
<entry>
<title>ipmi: initialize len variable</title>
<updated>2022-03-20T17:37:15+00:00</updated>
<author>
<name>Tom Rix</name>
<email>trix@redhat.com</email>
</author>
<published>2022-03-20T13:59:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8d10ea152e2fb9b4a42b282cb90bfc4d98e319a3'/>
<id>urn:sha1:8d10ea152e2fb9b4a42b282cb90bfc4d98e319a3</id>
<content type='text'>
Clang static analysis reports this issue
ipmi_ssif.c:1731:3: warning: 4th function call
  argument is an uninitialized value
  dev_info(&amp;ssif_info-&gt;client-&gt;dev,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The 4th parameter is the 'len' variable.
len is only set by a successful call to do_cmd().
Initialize to len 0.

Signed-off-by: Tom Rix &lt;trix@redhat.com&gt;
Message-Id: &lt;20220320135954.2258545-1-trix@redhat.com&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
<entry>
<title>ipmi: kcs: aspeed: Remove old bindings support</title>
<updated>2022-02-28T16:30:14+00:00</updated>
<author>
<name>Joel Stanley</name>
<email>joel@jms.id.au</email>
</author>
<published>2022-02-28T06:28:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f4676c8ec39689c6370bd58f4266c5c613de2a28'/>
<id>urn:sha1:f4676c8ec39689c6370bd58f4266c5c613de2a28</id>
<content type='text'>
It's been a few releases since we depreciated the "v1" bindings. Remove
support from the driver as all known device trees have been updated to
use the new bindings.

Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
Message-Id: &lt;20220228062840.449215-1-joel@jms.id.au&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
<entry>
<title>ipmi:ipmb: Add the ability to have a separate slave and master device</title>
<updated>2022-02-23T14:16:02+00:00</updated>
<author>
<name>Corey Minyard</name>
<email>minyard@acm.org</email>
</author>
<published>2022-02-20T20:38:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=00d93611f00219bd142aa119c5121793cac30ff0'/>
<id>urn:sha1:00d93611f00219bd142aa119c5121793cac30ff0</id>
<content type='text'>
A situation has come up where there is a slave-only device for the slave
and a separate master device on the same bug.  Allow a separate slave
device to be registered.

Signed-off-by: Corey Minyard &lt;minyard@acm.org&gt;
</content>
</entry>
<entry>
<title>ipmi:ipmi_ipmb: Unregister the SMI on remove</title>
<updated>2022-02-23T13:59:17+00:00</updated>
<author>
<name>Corey Minyard</name>
<email>minyard@acm.org</email>
</author>
<published>2022-02-23T13:38:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=57c9e3c9a374ff1419e5559f8979c0b43a0bffbd'/>
<id>urn:sha1:57c9e3c9a374ff1419e5559f8979c0b43a0bffbd</id>
<content type='text'>
Otherwise it will continue to be hooked into the IPMI framework.

Signed-off-by: Corey Minyard &lt;minyard@acm.org&gt;
</content>
</entry>
<entry>
<title>ipmi: kcs: aspeed: Add AST2600 compatible string</title>
<updated>2022-02-22T17:08:02+00:00</updated>
<author>
<name>Joel Stanley</name>
<email>joel@jms.id.au</email>
</author>
<published>2022-02-21T07:03:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2596f6b93a606332c0e5759991e880fbe76e6c8d'/>
<id>urn:sha1:2596f6b93a606332c0e5759991e880fbe76e6c8d</id>
<content type='text'>
The AST2600 is already described in the bindings, but the driver never
gained a compatible string.

Signed-off-by: Joel Stanley &lt;joel@jms.id.au&gt;
Message-Id: &lt;20220221070351.121905-1-joel@jms.id.au&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
<entry>
<title>ipmi: ssif: replace strlcpy with strscpy</title>
<updated>2022-01-17T15:10:46+00:00</updated>
<author>
<name>Jason Wang</name>
<email>wangborong@cdjrlc.com</email>
</author>
<published>2021-12-22T03:27:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d134ad2574a1c9b5c34659709769bdb25295fd25'/>
<id>urn:sha1:d134ad2574a1c9b5c34659709769bdb25295fd25</id>
<content type='text'>
The strlcpy should not be used because it doesn't limit the source
length. So that it will lead some potential bugs.

But the strscpy doesn't require reading memory from the src string
beyond the specified "count" bytes, and since the return value is
easier to error-check than strlcpy()'s. In addition, the implementation
is robust to the string changing out from underneath it, unlike the
current strlcpy() implementation.

Thus, replace strlcpy with strscpy.

Signed-off-by: Jason Wang &lt;wangborong@cdjrlc.com&gt;
Message-Id: &lt;20211222032707.1912186-1-wangborong@cdjrlc.com&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
<entry>
<title>ipmi/watchdog: Constify ident</title>
<updated>2022-01-17T15:10:46+00:00</updated>
<author>
<name>Rikard Falkeborn</name>
<email>rikard.falkeborn@gmail.com</email>
</author>
<published>2021-11-28T22:01:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7281599201c3336e350406781e7d88ca92453727'/>
<id>urn:sha1:7281599201c3336e350406781e7d88ca92453727</id>
<content type='text'>
ident is not modified and can be made const to allow the compiler to put
it in read-only memory.

Signed-off-by: Rikard Falkeborn &lt;rikard.falkeborn@gmail.com&gt;
Message-Id: &lt;20211128220154.32927-1-rikard.falkeborn@gmail.com&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
<entry>
<title>ipmi: Fix UAF when uninstall ipmi_si and ipmi_msghandler module</title>
<updated>2021-12-21T14:04:42+00:00</updated>
<author>
<name>Wu Bo</name>
<email>wubo40@huawei.com</email>
</author>
<published>2021-12-21T07:00:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ffb76a86f8096a8206be03b14adda6092e18e275'/>
<id>urn:sha1:ffb76a86f8096a8206be03b14adda6092e18e275</id>
<content type='text'>
Hi,

When testing install and uninstall of ipmi_si.ko and ipmi_msghandler.ko,
the system crashed.

The log as follows:
[  141.087026] BUG: unable to handle kernel paging request at ffffffffc09b3a5a
[  141.087241] PGD 8fe4c0d067 P4D 8fe4c0d067 PUD 8fe4c0f067 PMD 103ad89067 PTE 0
[  141.087464] Oops: 0010 [#1] SMP NOPTI
[  141.087580] CPU: 67 PID: 668 Comm: kworker/67:1 Kdump: loaded Not tainted 4.18.0.x86_64 #47
[  141.088009] Workqueue: events 0xffffffffc09b3a40
[  141.088009] RIP: 0010:0xffffffffc09b3a5a
[  141.088009] Code: Bad RIP value.
[  141.088009] RSP: 0018:ffffb9094e2c3e88 EFLAGS: 00010246
[  141.088009] RAX: 0000000000000000 RBX: ffff9abfdb1f04a0 RCX: 0000000000000000
[  141.088009] RDX: 0000000000000000 RSI: 0000000000000246 RDI: 0000000000000246
[  141.088009] RBP: 0000000000000000 R08: ffff9abfffee3cb8 R09: 00000000000002e1
[  141.088009] R10: ffffb9094cb73d90 R11: 00000000000f4240 R12: ffff9abfffee8700
[  141.088009] R13: 0000000000000000 R14: ffff9abfdb1f04a0 R15: ffff9abfdb1f04a8
[  141.088009] FS:  0000000000000000(0000) GS:ffff9abfffec0000(0000) knlGS:0000000000000000
[  141.088009] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  141.088009] CR2: ffffffffc09b3a30 CR3: 0000008fe4c0a001 CR4: 00000000007606e0
[  141.088009] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  141.088009] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  141.088009] PKRU: 55555554
[  141.088009] Call Trace:
[  141.088009]  ? process_one_work+0x195/0x390
[  141.088009]  ? worker_thread+0x30/0x390
[  141.088009]  ? process_one_work+0x390/0x390
[  141.088009]  ? kthread+0x10d/0x130
[  141.088009]  ? kthread_flush_work_fn+0x10/0x10
[  141.088009]  ? ret_from_fork+0x35/0x40] BUG: unable to handle kernel paging request at ffffffffc0b28a5a
[  200.223240] PGD 97fe00d067 P4D 97fe00d067 PUD 97fe00f067 PMD a580cbf067 PTE 0
[  200.223464] Oops: 0010 [#1] SMP NOPTI
[  200.223579] CPU: 63 PID: 664 Comm: kworker/63:1 Kdump: loaded Not tainted 4.18.0.x86_64 #46
[  200.224008] Workqueue: events 0xffffffffc0b28a40
[  200.224008] RIP: 0010:0xffffffffc0b28a5a
[  200.224008] Code: Bad RIP value.
[  200.224008] RSP: 0018:ffffbf3c8e2a3e88 EFLAGS: 00010246
[  200.224008] RAX: 0000000000000000 RBX: ffffa0799ad6bca0 RCX: 0000000000000000
[  200.224008] RDX: 0000000000000000 RSI: 0000000000000246 RDI: 0000000000000246
[  200.224008] RBP: 0000000000000000 R08: ffff9fe43fde3cb8 R09: 00000000000000d5
[  200.224008] R10: ffffbf3c8cb53d90 R11: 00000000000f4240 R12: ffff9fe43fde8700
[  200.224008] R13: 0000000000000000 R14: ffffa0799ad6bca0 R15: ffffa0799ad6bca8
[  200.224008] FS:  0000000000000000(0000) GS:ffff9fe43fdc0000(0000) knlGS:0000000000000000
[  200.224008] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  200.224008] CR2: ffffffffc0b28a30 CR3: 00000097fe00a002 CR4: 00000000007606e0
[  200.224008] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  200.224008] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  200.224008] PKRU: 55555554
[  200.224008] Call Trace:
[  200.224008]  ? process_one_work+0x195/0x390
[  200.224008]  ? worker_thread+0x30/0x390
[  200.224008]  ? process_one_work+0x390/0x390
[  200.224008]  ? kthread+0x10d/0x130
[  200.224008]  ? kthread_flush_work_fn+0x10/0x10
[  200.224008]  ? ret_from_fork+0x35/0x40
[  200.224008] kernel fault(0x1) notification starting on CPU 63
[  200.224008] kernel fault(0x1) notification finished on CPU 63
[  200.224008] CR2: ffffffffc0b28a5a
[  200.224008] ---[ end trace c82a412d93f57412 ]---

The reason is as follows:
T1: rmmod ipmi_si.
    -&gt;ipmi_unregister_smi()
        -&gt; ipmi_bmc_unregister()
            -&gt; __ipmi_bmc_unregister()
                -&gt; kref_put(&amp;bmc-&gt;usecount, cleanup_bmc_device);
                    -&gt; schedule_work(&amp;bmc-&gt;remove_work);

T2: rmmod ipmi_msghandler.
    ipmi_msghander module uninstalled, and the module space
    will be freed.

T3: bmc-&gt;remove_work doing cleanup the bmc resource.
    -&gt; cleanup_bmc_work()
        -&gt; platform_device_unregister(&amp;bmc-&gt;pdev);
            -&gt; platform_device_del(pdev);
                -&gt; device_del(&amp;pdev-&gt;dev);
                    -&gt; kobject_uevent(&amp;dev-&gt;kobj, KOBJ_REMOVE);
                        -&gt; kobject_uevent_env()
                            -&gt; dev_uevent()
                                -&gt; if (dev-&gt;type &amp;&amp; dev-&gt;type-&gt;name)

   'dev-&gt;type'(bmc_device_type) pointer space has freed when uninstall
    ipmi_msghander module, 'dev-&gt;type-&gt;name' cause the system crash.

drivers/char/ipmi/ipmi_msghandler.c:
2820 static const struct device_type bmc_device_type = {
2821         .groups         = bmc_dev_attr_groups,
2822 };

Steps to reproduce:
Add a time delay in cleanup_bmc_work() function,
and uninstall ipmi_si and ipmi_msghandler module.

2910 static void cleanup_bmc_work(struct work_struct *work)
2911 {
2912         struct bmc_device *bmc = container_of(work, struct bmc_device,
2913                                               remove_work);
2914         int id = bmc-&gt;pdev.id; /* Unregister overwrites id */
2915
2916         msleep(3000);   &lt;---
2917         platform_device_unregister(&amp;bmc-&gt;pdev);
2918         ida_simple_remove(&amp;ipmi_bmc_ida, id);
2919 }

Use 'remove_work_wq' instead of 'system_wq' to solve this issues.

Fixes: b2cfd8ab4add ("ipmi: Rework device id and guid handling to catch changing BMCs")
Signed-off-by: Wu Bo &lt;wubo40@huawei.com&gt;
Message-Id: &lt;1640070034-56671-1-git-send-email-wubo40@huawei.com&gt;
Signed-off-by: Corey Minyard &lt;cminyard@mvista.com&gt;
</content>
</entry>
</feed>
