Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp85281rwi; Wed, 2 Nov 2022 09:34:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5AmHzOBO4GXjdbGQvb+WvoNWnEX9Mq21R9pJknO2Il9mEWT+1AiB4Rzv4rQPuz7FZq7HdN X-Received: by 2002:a05:6402:51c8:b0:462:3e90:aef with SMTP id r8-20020a05640251c800b004623e900aefmr26431891edd.225.1667406859057; Wed, 02 Nov 2022 09:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667406859; cv=none; d=google.com; s=arc-20160816; b=a6NwBaV5B+YCKcSHNSYLbwH1hyLrN4Rb8qnvo2oY/n05FXzcJ7RvBqhQ5T8E4MBxlQ xMy9MSonCoJFw9E+BpSxex8y/ZLXIh4EgwiESahy6JNTjp1NiQjVAe1Mil32FPJS+KDP aIEWUrQVGVC8ahiz80tXslePJhL+7bu/yHsjUDBgbPjYhXhtUJ8GjKqIrjQj5+O6h+QL qDMcKM6mZE2JdUbc0bkVe3rNMYB8H6sYOqq2jjORx5n9xyFlwhr0zP9j1Pe/goFDqVQ+ T4ovRMjfNGqC3Y5kASvfdnApImPe/sWOGiOUaAhN0larAsEfMMXZe2e9w5p/97+ihDRy K7MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CbzfHUK/OIe01GljM+tYcwS2aLG1wlQhszOS90aIPbk=; b=FUw+NDuOekM+6IM5EDimIOHl3VcNy9yjJ+4ImofPFpY2fwhD7+p2zVrW1gvRGMvRKb YAXtgPgR6F9oCA48RH9iuTvIAULu7nJip9R0wM4z+dl0KiYrUZAu88Klxt+WZCkiezlP 6h0Jt3XspagJzx7SyoVUc2cJtkZ5HDsEPdBrHXL1EX8l4MrUihJXXb4NcVXpOXbXXr0H mCTXhD9uxr+VZqb+Ri5nIdn+iVMX2tdvjZJWnBpOxbMEZ1nw3rDjrt5iPiVQkBzrnl03 TmHsOSKHNY0bK9lzE24NqKRIOCLOGe/J1Lz313ROcV0o2G2O3jfd+6nq99G0F+RvUseh 0U3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TnvBNqsS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hh17-20020a170906a95100b007820f00167fsi14219527ejb.260.2022.11.02.09.33.47; Wed, 02 Nov 2022 09:34:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TnvBNqsS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbiKBPnS (ORCPT + 98 others); Wed, 2 Nov 2022 11:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbiKBPnC (ORCPT ); Wed, 2 Nov 2022 11:43:02 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B3A286C2 for ; Wed, 2 Nov 2022 08:43:01 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id z26so3608446pff.1 for ; Wed, 02 Nov 2022 08:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CbzfHUK/OIe01GljM+tYcwS2aLG1wlQhszOS90aIPbk=; b=TnvBNqsScJgJGa9F6e4NUp0WnQSFcyWRX8Px7ptg6cO6ctt1BRBZcdYb69cwPtIwyN QoHb48pAlpwFaQk7ewUS76qc4+cdspn2SEn24wD7ztEg1qPECfbSrnmQfKNybPMUuQua osc2GMsfESHWanbfjNZictRM04i534QWu1ZfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CbzfHUK/OIe01GljM+tYcwS2aLG1wlQhszOS90aIPbk=; b=t4YDGVjYEG07LrUE5YX5aFf74WkDs6Oq5DmdBPVtvOhlm5SjEyrVVHie4N3JBz9/az 7X+vOtARCOmr099GlFLfjHaQSlmTdPtpHoMRU8d2cbrvHOhlslys0INcJOXcRIkLtOqu CXAwqy3rO2SNr1TSc5aIkrTVrkrz4aee8eVGHgw6Pfy6Dg3jjkH5sxLS/skCknPoWUdf UMDTDKu08ZbFFxnht0mXJJDCUzIIiCFTs7/k7xT0qgItW+wl+Lb9X0uA21LqajJSaXF1 ZSPq3QgG2fL2lp/vbkQl9AVIHYLO4dzAs1MDTDS+pA2e34YqQJmZUlTx05KjpZpDTmIw Gihg== X-Gm-Message-State: ACrzQf3UaTTrTX7/haTFVgnraIIS8c/GwU3xruOQq3W2uR/cIOEY45I8 LjSechLzj9Nt3IMvRVwlaGq9iRnCel8WQg== X-Received: by 2002:a65:6b81:0:b0:461:4049:7df7 with SMTP id d1-20020a656b81000000b0046140497df7mr22347812pgw.593.1667403780934; Wed, 02 Nov 2022 08:43:00 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b5-20020a170902650500b00186afd756edsm8431471plk.283.2022.11.02.08.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 08:43:00 -0700 (PDT) Date: Wed, 2 Nov 2022 08:42:59 -0700 From: Kees Cook To: Nathan Chancellor Cc: Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "Pan, Xinhui" , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Tom Rix , Sami Tolvanen , llvm@lists.linux.dev, patches@lists.linux.dev Subject: Re: [PATCH 2/2] drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback Message-ID: <202211020842.8B8E29F8@keescook> References: <20221102152540.2389891-1-nathan@kernel.org> <20221102152540.2389891-2-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102152540.2389891-2-nathan@kernel.org> X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Wed, Nov 02, 2022 at 08:25:40AM -0700, Nathan Chancellor wrote: > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), > indirect call targets are validated against the expected function > pointer prototype to make sure the call target is valid to help mitigate > ROP attacks. If they are not identical, there is a failure at run time, > which manifests as either a kernel panic or thread getting killed. A > proposed warning in clang aims to catch these at compile time, which > reveals: > > drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *, uint32_t, long *, uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, uint32_t)' (aka 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] > .odn_edit_dpm_table = smu_od_edit_dpm_table, > ^~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > There are only two implementations of ->odn_edit_dpm_table() in 'struct > amd_pm_funcs': smu_od_edit_dpm_table() and pp_odn_edit_dpm_table(). One > has a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND' and the > other uses 'u32'. Ultimately, smu_od_edit_dpm_table() calls > ->od_edit_dpm_table() from 'struct pptable_funcs' and > pp_odn_edit_dpm_table() calls ->odn_edit_dpm_table() from 'struct > pp_hwmgr_func', which both have a second parameter type of 'enum > PP_OD_DPM_TABLE_COMMAND'. > > Update the type parameter in both the prototype in 'struct amd_pm_funcs' > and pp_odn_edit_dpm_table() to 'enum PP_OD_DPM_TABLE_COMMAND', which > cleans up the warning. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Reported-by: Sami Tolvanen > Signed-off-by: Nathan Chancellor Reviewed-by: Kees Cook -- Kees Cook