mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pei Xiao <xiaopei01@kylinos.cn>
To: syzbot+3fa2af55f15bd21cada9@syzkaller.appspotmail.com,
	linux-kernel@vger.kernel.org
Cc: xiaopei01@kylinos.cn
Subject: Re: [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton
Date: Thu, 14 Nov 2024 09:40:02 +0800	[thread overview]
Message-ID: <20241114014002.7435-2-xiaopei01@kylinos.cn> (raw)
In-Reply-To: <20241114014002.7435-1-xiaopei01@kylinos.cn>

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 81d6c734c8bc..ead1d338fa58 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -66,8 +66,11 @@ static s32 snto32(__u32 value, unsigned int n)
 
 static u32 s32ton(__s32 value, unsigned int n)
 {
-	s32 a = value >> (n - 1);
+	s32 a;
 
+	if (n >= 32)
+		return value;
+	a = value >> (n - 1);
 	if (a && a != -1)
 		return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1;
 	return value & ((1 << n) - 1);


  reply	other threads:[~2024-11-14  1:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 15:08 syzbot
2024-11-13 14:59 ` xiaopeitux
2024-11-14  1:40 ` Pei Xiao
2024-11-14  1:40   ` Pei Xiao [this message]
2024-11-14  2:19 Pei Xiao
2024-11-14  2:20 ` syzbot

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=20241114014002.7435-2-xiaopei01@kylinos.cn \
    --to=xiaopei01@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+3fa2af55f15bd21cada9@syzkaller.appspotmail.com \
    /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

all inboxes | Powered by JetHome®