Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2148318rdb; Mon, 20 Nov 2023 03:32:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcoxyl1K+Ek3jQD6sAl7Zp5uL2DVmmiv2CCQb43ErIn0jUB8BUynni2befEisFvxk3G6BI X-Received: by 2002:a17:90b:4f8f:b0:27d:ba33:6990 with SMTP id qe15-20020a17090b4f8f00b0027dba336990mr4282105pjb.10.1700479944356; Mon, 20 Nov 2023 03:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700479944; cv=none; d=google.com; s=arc-20160816; b=FCC+5kpg2Jn9o1T3G+G/M12N7I+LMkHDZJIF4vyaeM0915lF7Hal9GbZJ2l4XjSFg+ AfqVZyLyhOKFahR0PGqC/ryz/UwE5F+bPOk3mdpGDZeym+Y9Ym8XkUt3uUdbM3VnrGki U6YDySFp68Cugokzxs5lo5zTDwFHo6UrxwnASHl6FccNTvuQa1xJtygX+Sm6li565diZ JD/5acrgV172Cpg1cSiChTQArXZy5uzgTW8JhpaTDG3FfqH2mMy/exYyeHFM8AuerkXp nv2ZsiyKMtpY2rP6Dvt6zoo7f4GDeaJBHiT9ouM4TjBAGNbPupgBdVaq0R7f9fxEupbR eOBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=U67I4bOCYaRV2prl2LE1Ws063LlRSOIvBo7XdG1ZUyU=; fh=gWsV0TWEJEY2Vy3yBPMMpyqUsI97gu05wmJDLDzPlz4=; b=u1zuDzdpf9nBWM0QRW3QXJH/67q2KF6WmBxswTIHQ7ZztZS3rHpKpJRd9nZYJHhp+o N3K7qBo/9Fgjd1FDjSX1zPzvzK1ouCzEjtaebCdSCQkyIytpK5hN068eiUN0AYfoghkr Gwzftg23JXKbjgYD1i4cqNa4bRAh9dodTmnSwPoTrvOjsrTOyZynMDdD4FSO/cOiyEg4 V3VnPtnl/0+uK0KF9iX4bKe0qeenwjZHgc4pZGf9QN38zYROcDFQun/pd/8UBR1QgiQ/ cZXGOREN/c1TRpx51QYZIm2+hVBehtTM4j1+0GYxx4Z9DBEXAvgnA62Bls3LbKkct6Jv yLbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SNUpXu5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s93-20020a17090a2f6600b0028321d69667si7852535pjd.67.2023.11.20.03.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:32:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SNUpXu5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0F58A8070665; Mon, 20 Nov 2023 03:31:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbjKTLbP (ORCPT + 99 others); Mon, 20 Nov 2023 06:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232627AbjKTLbP (ORCPT ); Mon, 20 Nov 2023 06:31:15 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A481190 for ; Mon, 20 Nov 2023 03:31:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700479871; x=1732015871; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=YGbR5p4kQb9i8HmQmSVaXtrNqPcOGMP09hVzD3QkDGY=; b=SNUpXu5qdfJUXOZQocr91sfKAepIiyCNT+JUeEPrZ0+b1YLnYGQa8DIf NLALWVh3x/xVrkr/ow7gpHwrl/Hm6BEyg2ihV2cQEyT84PP5Lbc5bWJB4 9Dx9EC/94Cg368q5yVFGZOSbeRxndZfT+d4O7IyHuOlhNbBq1qS0lQCmv e5B4Tz2egwDeAh7q4gUWbBRFE9fDlAvk1h+Tzi2f7tP0vS7DgQIDmGS63 22ZGxNWXfsdwKkLc1QmqB9J/0L2QeZ0uoT2V+VHNLaD4LiXiKY2lShzSq 0g565pRhijOock1uJv+++ZLLYX+jHeHOgxFX1s/vGgyyoeJVElfMSwO6s g==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="388739532" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="388739532" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:31:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="1097725092" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="1097725092" Received: from avmoskal-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.40.194]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:31:07 -0800 From: Jani Nikula To: Edward Adam Davis , syzbot+2e93e6fb36e6fdc56574@syzkaller.appspotmail.com Cc: tzimmermann@suse.de, airlied@linux.ie, daniel.vetter@ffwll.ch, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, melissa.srw@gmail.com, mripard@kernel.org, daniel.vetter@intel.com, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] drm/modes: Fix divide error in drm_mode_debug_printmodeline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <000000000000bf0b1f060a2d9bea@google.com> Date: Mon, 20 Nov 2023 13:31:04 +0200 Message-ID: <875y1wpsp3.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 03:31:31 -0800 (PST) On Sun, 19 Nov 2023, Edward Adam Davis wrote: > [Syz Log] > divide error: 0000 [#1] PREEMPT SMP KASAN > CPU: 0 PID: 5068 Comm: syz-executor357 Not tainted 6.6.0-syzkaller-16039-gac347a0655db #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023 > RIP: 0010:drm_mode_vrefresh drivers/gpu/drm/drm_modes.c:1303 [inline] > RIP: 0010:drm_mode_debug_printmodeline+0x118/0x4e0 drivers/gpu/drm/drm_modes.c:60 > Code: 00 41 0f b7 07 66 83 f8 02 b9 01 00 00 00 0f 43 c8 0f b7 c1 0f af e8 44 89 f0 48 69 c8 e8 03 00 00 89 e8 d1 e8 48 01 c8 31 d2 <48> f7 f5 49 89 c6 eb 0c e8 fb 07 66 fc eb 05 e8 f4 07 66 fc 48 89 > RSP: 0018:ffffc9000391f8d0 EFLAGS: 00010246 > RAX: 000000000001f400 RBX: ffff888025045000 RCX: 000000000001f400 > RDX: 0000000000000000 RSI: 0000000000008000 RDI: ffff888025045018 > RBP: 0000000000000000 R08: ffffffff8528b9af R09: 0000000000000000 > R10: ffffc9000391f8a0 R11: fffff52000723f17 R12: 0000000000000080 > R13: dffffc0000000000 R14: 0000000000000080 R15: ffff888025045016 > FS: 0000555556932380(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 00000000005fdeb8 CR3: 000000007fcff000 CR4: 00000000003506f0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > > drm_mode_setcrtc+0x83b/0x1880 drivers/gpu/drm/drm_crtc.c:794 > drm_ioctl_kernel+0x362/0x500 drivers/gpu/drm/drm_ioctl.c:792 > drm_ioctl+0x636/0xb00 drivers/gpu/drm/drm_ioctl.c:895 > vfs_ioctl fs/ioctl.c:51 [inline] > __do_sys_ioctl fs/ioctl.c:871 [inline] > __se_sys_ioctl+0xf8/0x170 fs/ioctl.c:857 > do_syscall_x64 arch/x86/entry/common.c:51 [inline] > do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 > entry_SYSCALL_64_after_hwframe+0x63/0x6b > > [Analysis] > When calculating den in drm_mode_vrefresh(), if the vscan value is too large, > there is a probability of unsigned integer overflow. > > [Fix] > Before multiplying by vscan, first determine their ilog2. When their total > exceeds 32, return -EINVAL and exit the subsequent calculation. > > Reported-and-tested-by: syzbot+2e93e6fb36e6fdc56574@syzkaller.appspotmail.com > Fixes: ea40d7857d52 ("drm/vkms: fbdev emulation support") > Signed-off-by: Edward Adam Davis > --- > drivers/gpu/drm/drm_modes.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c > index ac9a406250c5..c7ec1ab041f8 100644 > --- a/drivers/gpu/drm/drm_modes.c > +++ b/drivers/gpu/drm/drm_modes.c > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > > #include