From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8EF8175A64 for ; Sun, 9 Aug 2026 01:46:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786240020; cv=none; b=nTbTrZp3adScK90OwJW+m0TqLxMmc203hty5p73wUS6whUgFQOnPJLbV1ml8EX/PJ63dkzxezQHrSv6xypRYWtv6Wy1YL6pAa6JCPqinUCq+368AOjnx3poprnqoYa1qq74ppNXUHLJcNGLI01oXNeeT8JHZKRKjQoJfyVEvUfw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786240020; c=relaxed/simple; bh=vAqFQiFt84IiRtshe/fy4JKl5qkVCiNq3vkL5YBDqp8=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=dXMbDrF1Nboh3G3FeNsoeMjiSUOpixsLGyQChCSofFvh+AFdzqSfDV0MGwmZBiXb+pOrrnUT1M2PS8tvbLKtdd56muMuRc4FN/8s5IcuO3IWdMuM8xOPzawEAWnUqGYPxoSr9zU3d3G0slq78Pt+MN0xfqrmR5yLNZSlEhl1+qg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.167.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-4b19ce23e5cso262851b6e.1 for ; Sat, 08 Aug 2026 18:46:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786240017; x=1786844817; h=content-type:to:from:subject:message-id:in-reply-to:date :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=b6pDCtcywoWDKeNVxweImMOdXNeeM/ZOP3/MjKC5kZ4=; b=XkK9WakLK0lLaAYaXFQRC603Ua8HLFNewg5sGSPC5JrhMdCSndPw3zbbOeFZF9CHvo sRH9n8hol6nrZZHPdkLuXqzk9OKGtoRItytLBlqqK8nxxb8C1I1R7BYxKCxKop2EwPtv VTxImemIjjgdEWIEsaNXMFoNVFSwWVcD4Rm8T7tdKa5ISlxDm+wIdTn2e2DWVhvQ1P4y 6zW2cGbr/ODpbfLevpN/AlVD+Ya4PaINUrTrmyYVT3C6gmvpUOzEtW9B1+EDuo2tutpz +PPcTrpzuV/7ogWgRhmWSMPPdiI+4x9VGQGi/D6QJwP8G0X2oel2ZNf7NaonyN95aoQv HqSg== X-Gm-Message-State: AOJu0YxmOaYlgy+1UZMj2NtwFdJ8yF0qZq/e5cv1GTMq+jci3jn75MLU rsCtt+De8DuUnw+E6jnGlbI+uUxJfHmWHN9gSn1MR2ywd/iH/f926Hxmqxw+TLy2tRk/nrlLGW+ QRgDULKJofNgfBxGvL5lIcqmk7vkIyF2m3Bd1mawhZnmsQPYAJQ2VsAM3lfg= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6808:3097:b0:495:e92e:d797 with SMTP id 5614622812f47-4afae066763mr18937031b6e.11.1786240017386; Sat, 08 Aug 2026 18:46:57 -0700 (PDT) Date: Sat, 08 Aug 2026 18:46:57 -0700 In-Reply-To: <6a778c82.01d0871a.3a0d52.0069.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a77dc11.b50370da.49fe0.0035.GAE@google.com> Subject: Forwarded: [PATCH] HID: core: check field offset before dumping input From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] HID: core: check field offset before dumping input Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master hid_set_field() passes field->usage + offset to hid_dump_input() before validating offset against field->report_count. field->usage is allocated with exactly report_count entries, so a larger offset is read out of bounds before the existing check rejects it: BUG: KASAN: slab-out-of-bounds in hid_dump_input+0xcb/0xd0 Read of size 4 at addr ffff88802ab28fc0 by task kworker/1:2/48 Move the bounds check above the hid_dump_input() call so the function returns before the dereference. Reported-by: syzbot+a942efa43c928a1e3daa@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=a942efa43c928a1e3daa Signed-off-by: Deepanshu Kartikey --- drivers/hid/hid-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index cf123347a2af..7ea1fb62b9d4 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1933,13 +1933,14 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) size = field->report_size; - hid_dump_input(field->report->device, field->usage + offset, value); - if (offset >= field->report_count) { hid_err(field->report->device, "offset (%d) exceeds report_count (%d)\n", offset, field->report_count); return -1; } + + hid_dump_input(field->report->device, field->usage + offset, value); + if (field->logical_minimum < 0) { if (value != snto32(s32ton(value, size), size)) { hid_err(field->report->device, "value %d is out of range\n", value); -- 2.43.0