linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: "Doug Smythies" <dsmythies@telus.net>,
	"'Ahmad Khalifa'" <ahmad@khalifa.ws>,
	"'Guenter Roeck'" <linux@roeck-us.net>
Cc: "'Jean Delvare'" <jdelvare@suse.com>,
	Linux Hardware Monitoring <linux-hwmon@vger.kernel.org>,
	Linux Regressions <regressions@lists.linux.dev>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: hwmon: (nct6775) Regression Bisected
Date: Sat, 16 Sep 2023 16:20:54 +0700	[thread overview]
Message-ID: <ZQVzdlHgWdFhOVyQ@debian.me> (raw)
In-Reply-To: <002101d9e7e0$f67c4490$e374cdb0$@telus.net>

[-- Attachment #1: Type: text/plain, Size: 5481 bytes --]

On Fri, Sep 15, 2023 at 07:28:57AM -0700, Doug Smythies wrote:
> Kernel 6.6-rc1 has an error during boot. The guilty commit is:
> b7f1f7b2523a6a4382f12fe953380b847b80e09d
> hwmon: (nct6775) Additional TEMP registers for nct6799
> 
> There seems to be confusion between the indexes into
> the NCT6799_ALARM_BITS array or the
> NCT6779_ALARM_BITS array. I do not understand the code
> and do not know if it is the indexing that is reversed or the
> wrong table is being used.
> 
> The error from kern.log (edited):
> 
> ================================================================================
> UBSAN: shift-out-of-bounds in drivers/hwmon/nct6775-core.c:1757:39
> shift exponent -1 is negative
> CPU: 9 PID: 822 Comm: sensors Not tainted 6.6.0-rc1-stock2 #1165
> Hardware name: ASUS System Product Name/PRIME Z490-A, BIOS 9902 09/15/2021
> Call Trace:
> <TASK>
> dump_stack_lvl+0x48/0x70
> dump_stack+0x10/0x20
> ubsan_epilogue+0x9/0x40
> __ubsan_handle_shift_out_of_bounds+0x10f/0x170
> ...
> 
> I added a "pr_info" line (in the below it was as of the prior commit,
> 43fbe66dc216 hwmon: Add driver for Renesas HS3001):
> 
> doug@s19:~/kernel/linux$ git diff
> diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
> index 33533d95cf48..12e3df84c034 100644
> --- a/drivers/hwmon/nct6775-core.c
> +++ b/drivers/hwmon/nct6775-core.c
> @@ -1727,6 +1727,7 @@ nct6775_show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
>                 return PTR_ERR(data);
> 
>         nr = data->ALARM_BITS[sattr->index];
> +       pr_info("doug: nr: %d  ; index %d\n", nr, sattr->index);
>         return sprintf(buf, "%u\n",
>                        (unsigned int)((data->alarms >> nr) & 0x01));
>  }
> 
> And for b7f1f7b2523a got (edited):
> 
> nct6775_core: doug: nr: 0  ; index 0
> nct6775_core: doug: nr: 1  ; index 1
> nct6775_core: doug: nr: 2  ; index 2
> nct6775_core: doug: nr: 3  ; index 3
> nct6775_core: doug: nr: 8  ; index 4
> nct6775_core: doug: nr: -1  ; index 5
> ================================================================================
> UBSAN: shift-out-of-bounds in drivers/hwmon/nct6775-core.c:1758:39
> shift exponent -1 is negative
> ...
> nct6775_core: doug: nr: 20  ; index 6
> nct6775_core: doug: nr: 16  ; index 7
> nct6775_core: doug: nr: 17  ; index 8
> nct6775_core: doug: nr: 24  ; index 9
> nct6775_core: doug: nr: 25  ; index 10
> nct6775_core: doug: nr: 26  ; index 11
> nct6775_core: doug: nr: 27  ; index 12
> nct6775_core: doug: nr: 28  ; index 13
> nct6775_core: doug: nr: 29  ; index 14
> nct6775_core: doug: nr: 6  ; index 24
> nct6775_core: doug: nr: 7  ; index 25
> nct6775_core: doug: nr: 11  ; index 26
> nct6775_core: doug: nr: 10  ; index 27
> nct6775_core: doug: nr: 23  ; index 28
> nct6775_core: doug: nr: 33  ; index 29
> nct6775_core: doug: nr: 12  ; index 48
> nct6775_core: doug: nr: 9  ; index 49
> 
> Observe that the table seems to be
> NCT6799_ALARM_BITS
> But the indexes seem to be for
> NCT6779_ALARM_BITS
> 
> static const s8 NCT6799_ALARM_BITS[NUM_ALARM_BITS] = {
>          0,  1,  2,  3,  8, -1, 20, 16, 17, 24, 25, 26,   /* in0-in11     */
>         27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1,   /* in12-in23    */
>          6,  7, 11, 10, 23, 33, -1, -1, -1, -1, -1, -1,   /* fan1-fan12   */
>          4,  5, 40, 41, 42, 43, 44, -1, -1, -1, -1, -1,   /* temp1-temp12 */
>         12,  9,                                           /* intr0-intr1  */
> };
> 
> Now repeat the test as of 43fbe66dc216:
> 
> nct6775_core: doug: nr: 0  ; index 0
> nct6775_core: doug: nr: 1  ; index 1
> nct6775_core: doug: nr: 2  ; index 2
> nct6775_core: doug: nr: 3  ; index 3
> nct6775_core: doug: nr: 8  ; index 4
> nct6775_core: doug: nr: 21  ; index 5
> nct6775_core: doug: nr: 20  ; index 6
> nct6775_core: doug: nr: 16  ; index 7
> nct6775_core: doug: nr: 17  ; index 8
> nct6775_core: doug: nr: 24  ; index 9
> nct6775_core: doug: nr: 25  ; index 10
> nct6775_core: doug: nr: 26  ; index 11
> nct6775_core: doug: nr: 27  ; index 12
> nct6775_core: doug: nr: 28  ; index 13
> nct6775_core: doug: nr: 29  ; index 14
> nct6775_core: doug: nr: 6  ; index 24
> nct6775_core: doug: nr: 7  ; index 25
> nct6775_core: doug: nr: 11  ; index 26
> nct6775_core: doug: nr: 10  ; index 27
> nct6775_core: doug: nr: 23  ; index 28
> nct6775_core: doug: nr: 33  ; index 29
> nct6775_core: doug: nr: 12  ; index 48
> nct6775_core: doug: nr: 9  ; index 49
> 
> Observe that the table seems to be
> NCT6779_ALARM_BITS
> And the indexing seems to be for that
> Table.
> 
> static const s8 NCT6779_ALARM_BITS[NUM_ALARM_BITS] = {
>          0,  1,  2,  3,  8, 21, 20, 16, 17, 24, 25, 26,   /* in0-in11     */
>         27, 28, 29, -1, -1, -1, -1, -1, -1, -1, -1, -1,   /* in12-in23    */
>          6,  7, 11, 10, 23, -1, -1, -1, -1, -1, -1, -1,   /* fan1-fan12   */
>          4,  5, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1,   /* temp1-temp12 */
>         12,  9,                                           /* intr0-intr1  */
> };
> 
> You probably need this information:
> nct6775: Found NCT6798D or compatible chip at 0x2e:0x290
> 

Thanks for the regression report. I'm adding it to regzbot:

#regzbot ^introduced: b7f1f7b2523a6a
#regzbot title: shift out-of-bounds in nct6799's additional TEMP registers

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

       reply	other threads:[~2023-09-16  9:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <002101d9e7e0$f67c4490$e374cdb0$@telus.net>
2023-09-16  9:20 ` Bagas Sanjaya [this message]
2023-09-21  9:14   ` hwmon: (nct6775) Regression Bisected Linux regression tracking #update (Thorsten Leemhuis)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZQVzdlHgWdFhOVyQ@debian.me \
    --to=bagasdotme@gmail.com \
    --cc=ahmad@khalifa.ws \
    --cc=dsmythies@telus.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=regressions@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).