<html><head></head><body><div dir="auto">Hi Sekhar,<br><br>I’ve fixed memory corruption issues in the past by replacing the memory cards. Have you tried swapping them out to see if the cards are the problem? Sometimes, even software stress tests won’t catch the issue. You might also want to test the setup on a different device using the same driver—that can help pinpoint the problem.<br><br>Hope this helps!<br>Dudley<br><br></div><br><br><div class="gmail_quote"><div dir="auto">On November 16, 2024 2:00:01 AM GMT+09:00, kernelnewbies-request@kernelnewbies.org wrote:</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><div dir="auto">Send Kernelnewbies mailing list submissions to<br> kernelnewbies@kernelnewbies.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> <a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>or, via email, send a message with subject or body 'help' to<br> kernelnewbies-request@kernelnewbies.org<br><br>You can reach the person managing the list at<br> kernelnewbies-owner@kernelnewbies.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Kernelnewbies digest..."<br><br><br>Today's Topics:<br><br> 1. Help Needed: Debugging Memory Corruption results GPF (Muni Sekhar)<hr>Message: 1<br>Date: Fri, 15 Nov 2024 21:47:59 +0530<br>From: Muni Sekhar <munisekharrms@gmail.com><br>To: kernel-hardening@lists.openwall.com, kasan-dev<br> <kasan-dev@googlegroups.com>, LKML <linux-kernel@vger.kernel.org>,<br> kernelnewbies <kernelnewbies@kernelnewbies.org><br>Subject: Help Needed: Debugging Memory Corruption results GPF<br>Message-ID:<br> <CAHhAz+i+4iCn+Ddh1YvuMn1v-PfJj72m6DcjRaY+3vx7wLhFsQ@mail.gmail.com><br>Content-Type: text/plain; charset="UTF-8"<br><br>Hi all,<br><br>I am encountering a memory corruption issue in the function<br>msm_set_laddr() from the Slimbus MSM Controller driver source code.<br><a href="https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-sunfish-4.14-android12/drivers/slimbus/slim-msm-ctrl.c">https://android.googlesource.com/kernel/msm/+/refs/heads/android-msm-sunfish-4.14-android12/drivers/slimbus/slim-msm-ctrl.c</a><br><br>In msm_set_laddr(), one of the arguments is ea (enumeration address),<br>which is a pointer to constant data. While testing, I observed strange<br>behavior:<br><br>The contents of the ea buffer get corrupted during a timeout scenario<br>in the call to:<br><br>timeout = wait_for_completion_timeout(&done, HZ);<br><br>Specifically, the ea buffer's contents differ before and after the<br>wait_for_completion_timeout() call, even though it's declared as a<br>pointer to constant data (const u8 *ea).<br>To debug this issue, I enabled KASAN, but it didn't reveal any memory<br>corruption. After the buffer corruption, random memory allocations in<br>other parts of the kernel occasionally result in a GPF crash.<br><br>Here is the relevant part of the code:<br><br>static int msm_set_laddr(struct slim_controller *ctrl, const u8 *ea,<br> u8 elen, u8 laddr)<br>{<br> struct msm_slim_ctrl *dev = slim_get_ctrldata(ctrl);<br> struct completion done;<br> int timeout, ret, retries = 0;<br> u32 *buf;<br>retry_laddr:<br> init_completion(&done);<br> mutex_lock(&dev->tx_lock);<br> buf = msm_get_msg_buf(dev, 9, &done);<br> if (buf == NULL)<br> return -ENOMEM;<br> buf[0] = SLIM_MSG_ASM_FIRST_WORD(9, SLIM_MSG_MT_CORE,<br> SLIM_MSG_MC_ASSIGN_LOGICAL_ADDRESS,<br> SLIM_MSG_DEST_LOGICALADDR,<br> ea[5] | ea[4] << 8);<br> buf[1] = ea[3] | (ea[2] << 8) | (ea[1] << 16) | (ea[0] << 24);<br> buf[2] = laddr;<br> ret = msm_send_msg_buf(dev, buf, 9, MGR_TX_MSG);<br> timeout = wait_for_completion_timeout(&done, HZ);<br> if (!timeout)<br> dev->err = -ETIMEDOUT;<br> if (dev->err) {<br> ret = dev->err;<br> dev->err = 0;<br> }<br> mutex_unlock(&dev->tx_lock);<br> if (ret) {<br> pr_err("set LADDR:0x%x failed:ret:%d, retrying", laddr, ret);<br> if (retries < INIT_MX_RETRIES) {<br> msm_slim_wait_retry(dev);<br> retries++;<br> goto retry_laddr;<br> } else {<br> pr_err("set LADDR failed after retrying:ret:%d", ret);<br> }<br> }<br> return ret;<br>}<br><br>What I've Tried:<br>KASAN: Enabled it but couldn't identify the source of the corruption.<br>Debugging Logs: Added logs to print the ea contents before and after<br>the wait_for_completion_timeout() call. The logs show a mismatch in<br>the data.<br><br>Question:<br>How can I efficiently trace the source of the memory corruption in<br>this scenario?<br>Could wait_for_completion_timeout() or a related function cause<br>unintended side effects?<br>Are there additional tools or techniques (e.g., dynamic debugging or<br>specific kernel config options) that can help identify this<br>corruption?<br>Any insights or suggestions would be greatly appreciated!<br><br><br><br></div></pre></blockquote></div></body></html>