Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5870810ioo; Wed, 1 Jun 2022 14:33:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4AF+LrY2oYyU9duC3yepY0nid2Hn6rmkTPJ1uF4Nvs+PxxP+kvAOjAiq726Rv+mS9hpt9 X-Received: by 2002:a17:903:2304:b0:162:ed1:ed9c with SMTP id d4-20020a170903230400b001620ed1ed9cmr1403167plh.122.1654119227977; Wed, 01 Jun 2022 14:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654119227; cv=none; d=google.com; s=arc-20160816; b=f13Yb4Jb2mwM0QU+m7deEeofyZ8nWLnbu8ztsYQ722C6H00syKy/oqpQgRd6d01MgR /aNxGn4VVryEo08b6oQyCMJtT1niFVSkUQu9XRVhV9nHEmPwwKBLOT4FGjkGt8NCZgUi C2KDyRPJ+WvQ/AoXPAm4KJN5sfByH+0PX2waq7AkMX/d430Ekw3qO2YwIqv1/RIxGoY+ lYlHF9p7mfDzIB2ErCRpKQbPrwsR2FX+yy8ssAXMQLtLkLuEEzzDn5hshSr5jsUDnQED jctIyNSJWD6ZqsQRogLKgtooEt91oi8C+gV+M8V5GHlEsbwQAK2xInePQp9jAYCn1zCO hhEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hoMiNZYJrAfbuhQrGDapdgZz3vciw9pWtItN8E0slnw=; b=dQpQuUXFCiwYrSVQ5tROMEh3TFY9YVFBMGOZzsqFbpp5Eb3BzTMBtEwm1lQTqWK8Bp BKeQVUDJ0sTPWJ7HkNYWR+l6ULnWBKOt1GnLyI0N84b4g9oNAfP7+cAFTp2pi+4U8SwU wc7mowe3YgvdFXOoZvv7BSFpoekDO0pX6iuMrYBpi75A4DebZwxils3kJrm0imHwa1YB kRHgo38g+VxKzF6VhOnBPnJeTJtlUJVfNzKXkbMmBZQD6OIGWKs871EXRe/d8d7YwIym 7CmNsxT4TseP6srEYQhdv/92LsgRs1kX3MwgBB2IWBo5WF0DPUUFzvV7+ER3o9EYutMc 28rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="od8SH/Ys"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m10-20020a654c8a000000b003c22121a268si3168654pgt.247.2022.06.01.14.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="od8SH/Ys"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 437FC31EE06; Wed, 1 Jun 2022 13:21:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbiFASoN (ORCPT + 99 others); Wed, 1 Jun 2022 14:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbiFASoL (ORCPT ); Wed, 1 Jun 2022 14:44:11 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7748A316 for ; Wed, 1 Jun 2022 11:44:09 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-e5e433d66dso3867353fac.5 for ; Wed, 01 Jun 2022 11:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hoMiNZYJrAfbuhQrGDapdgZz3vciw9pWtItN8E0slnw=; b=od8SH/Ys8gt43a9X8iPqlOmXKL+R0dCjlhw+7x4xGPXOwq1laMrsXksFC1Lpm6raHl hjrUwgOu2u+Hi9vpAU57nizmNVmQxC5bqUmEnE40bAbAQgdfYk09bmtPLwkCwtL8aEXu Kf9hVdDD4PbpqmbCNRmVbccAOAWKxv/fNNau/Bzv6/zNGHc1g8dBCBTpHBCc+mbl0z8j MAu+Ks11lNNkWp9UvJWpv8IPTnPBJ2sDIoDHwFr/ZIet9kPNM/wuRMtLqK1PIS5jzsMr PgOjbm19yYAIWXntuaURWePdXVw4oWAiEWBmLjid4em4AmXpN2PwsnaSmpAhJu9LOw5H sGTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hoMiNZYJrAfbuhQrGDapdgZz3vciw9pWtItN8E0slnw=; b=Puvr1IiykuHSUDd01Q+3rMLHpAGUaxokCqrgKJ0Mb6Y8Pko82YBEpQHPccRlyjdbng 8h0bb8lOnLHiTGQ3JkQ8QqjavlPF5WrBfxfg36HKl+LmHlWDC8xagRezwcnQUTa+/2jD EtCjmlNdzMG7i1Gos1pnH7lQO6WLJZGdIZDmdLGaXgR/9fQst9OX22meqEoEe8rExkNi /0Pkgn60DH2kLqJGjzaMC+HxEz8x9c7W5XSLG6C6bBKUmLBVPIlwv9oU9UsJwyXUW/ci WcTq83x5OzwzFHc242O3RpHZpca2ultQqCK6hsDC+f2eYHwZLNbNMpWiZXPtfurMKqYF fbGA== X-Gm-Message-State: AOAM533SvNxgn9BU0dcC7ZdyzWqP2K39GbQpcoSlFicqr9le8dMdW2do ZRlSQyW9G28JKd/t15njUMaTrRZ2g6NSxRVrjN5vGT3zumg= X-Received: by 2002:a05:6870:3105:b0:f2:9615:ff8e with SMTP id v5-20020a056870310500b000f29615ff8emr16722560oaa.200.1654109048402; Wed, 01 Jun 2022 11:44:08 -0700 (PDT) MIME-Version: 1.0 References: <202205271546.oV14N2r8-lkp@intel.com> In-Reply-To: <202205271546.oV14N2r8-lkp@intel.com> From: Alex Deucher Date: Wed, 1 Jun 2022 14:43:57 -0400 Message-ID: Subject: Re: [kbuild] drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3 To: Dan Carpenter Cc: kbuild@lists.01.org, Alex Deucher , kbuild-all@lists.01.org, kernel test robot , amd-gfx list , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 27, 2022 at 3:46 AM Dan Carpenter wrote: > > [ kbuild bot sent this warning on May 4 but I never heard back and it's > May 27 now so sending a duplicate warning is probably for the best. -dan] > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > head: 7e284070abe53d448517b80493863595af4ab5f0 > commit: 622469c87fc3e6c90a980be3e2287d82bd55c977 drm/amdgpu/discovery: add a function to parse the vcn info table > config: arc-randconfig-m031-20220524 (https://download.01.org/0day-ci/archive/20220527/202205271546.oV14N2r8-lkp@intel.com/config ) > compiler: arceb-elf-gcc (GCC) 11.3.0 > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot > Reported-by: Dan Carpenter > > smatch warnings: > drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1433 amdgpu_discovery_get_vcn_info() error: buffer overflow 'adev->vcn.vcn_codec_disable_mask' 2 <= 3 > > vim +1433 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c > > 622469c87fc3e6 Alex Deucher 2022-03-30 1403 int amdgpu_discovery_get_vcn_info(struct amdgpu_device *adev) > 622469c87fc3e6 Alex Deucher 2022-03-30 1404 { > 622469c87fc3e6 Alex Deucher 2022-03-30 1405 struct binary_header *bhdr; > 622469c87fc3e6 Alex Deucher 2022-03-30 1406 union vcn_info *vcn_info; > 622469c87fc3e6 Alex Deucher 2022-03-30 1407 u16 offset; > 622469c87fc3e6 Alex Deucher 2022-03-30 1408 int v; > 622469c87fc3e6 Alex Deucher 2022-03-30 1409 > 622469c87fc3e6 Alex Deucher 2022-03-30 1410 if (!adev->mman.discovery_bin) { > 622469c87fc3e6 Alex Deucher 2022-03-30 1411 DRM_ERROR("ip discovery uninitialized\n"); > 622469c87fc3e6 Alex Deucher 2022-03-30 1412 return -EINVAL; > 622469c87fc3e6 Alex Deucher 2022-03-30 1413 } > 622469c87fc3e6 Alex Deucher 2022-03-30 1414 > 622469c87fc3e6 Alex Deucher 2022-03-30 1415 if (adev->vcn.num_vcn_inst > VCN_INFO_TABLE_MAX_NUM_INSTANCES) { > > Capped to 4 > > 622469c87fc3e6 Alex Deucher 2022-03-30 1416 dev_err(adev->dev, "invalid vcn instances\n"); > 622469c87fc3e6 Alex Deucher 2022-03-30 1417 return -EINVAL; > 622469c87fc3e6 Alex Deucher 2022-03-30 1418 } > 622469c87fc3e6 Alex Deucher 2022-03-30 1419 > 622469c87fc3e6 Alex Deucher 2022-03-30 1420 bhdr = (struct binary_header *)adev->mman.discovery_bin; > 622469c87fc3e6 Alex Deucher 2022-03-30 1421 offset = le16_to_cpu(bhdr->table_list[VCN_INFO].offset); > 622469c87fc3e6 Alex Deucher 2022-03-30 1422 > 622469c87fc3e6 Alex Deucher 2022-03-30 1423 if (!offset) { > 622469c87fc3e6 Alex Deucher 2022-03-30 1424 dev_err(adev->dev, "invalid vcn table offset\n"); > 622469c87fc3e6 Alex Deucher 2022-03-30 1425 return -EINVAL; > 622469c87fc3e6 Alex Deucher 2022-03-30 1426 } > 622469c87fc3e6 Alex Deucher 2022-03-30 1427 > 622469c87fc3e6 Alex Deucher 2022-03-30 1428 vcn_info = (union vcn_info *)(adev->mman.discovery_bin + offset); > 622469c87fc3e6 Alex Deucher 2022-03-30 1429 > 622469c87fc3e6 Alex Deucher 2022-03-30 1430 switch (le16_to_cpu(vcn_info->v1.header.version_major)) { > 622469c87fc3e6 Alex Deucher 2022-03-30 1431 case 1: > 622469c87fc3e6 Alex Deucher 2022-03-30 1432 for (v = 0; v < adev->vcn.num_vcn_inst; v++) { > 622469c87fc3e6 Alex Deucher 2022-03-30 @1433 adev->vcn.vcn_codec_disable_mask[v] = > > But this array doesn't have 4 elements Correct, but num_vcn_inst can't be larger than AMDGPU_MAX_VCN_INSTANCES (2) at the moment thanks to: https://patchwork.freedesktop.org/patch/486289/ Alex > > 622469c87fc3e6 Alex Deucher 2022-03-30 1434 le32_to_cpu(vcn_info->v1.instance_info[v].fuse_data.all_bits); > 622469c87fc3e6 Alex Deucher 2022-03-30 1435 } > 622469c87fc3e6 Alex Deucher 2022-03-30 1436 break; > 622469c87fc3e6 Alex Deucher 2022-03-30 1437 default: > 622469c87fc3e6 Alex Deucher 2022-03-30 1438 dev_err(adev->dev, > 622469c87fc3e6 Alex Deucher 2022-03-30 1439 "Unhandled VCN info table %d.%d\n", > 622469c87fc3e6 Alex Deucher 2022-03-30 1440 le16_to_cpu(vcn_info->v1.header.version_major), > 622469c87fc3e6 Alex Deucher 2022-03-30 1441 le16_to_cpu(vcn_info->v1.header.version_minor)); > 622469c87fc3e6 Alex Deucher 2022-03-30 1442 return -EINVAL; > 622469c87fc3e6 Alex Deucher 2022-03-30 1443 } > 622469c87fc3e6 Alex Deucher 2022-03-30 1444 return 0; > f39f5bb1c9d68d Xiaojie Yuan 2019-06-20 1445 } > > -- > 0-DAY CI Kernel Test Service > https://01.org/lkp > _______________________________________________ > kbuild mailing list -- kbuild@lists.01.org > To unsubscribe send an email to kbuild-leave@lists.01.org >