Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp10605rwi; Wed, 2 Nov 2022 08:48:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gWykOQ9zVScor3qx9d8IwBstPIQ+E+6oJHBVxamI8X9bNAih52Q4l+Olk4vM/ucCkb6xz X-Received: by 2002:a05:6a00:22cf:b0:56d:1c55:45d0 with SMTP id f15-20020a056a0022cf00b0056d1c5545d0mr23128589pfj.54.1667404122216; Wed, 02 Nov 2022 08:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667404122; cv=none; d=google.com; s=arc-20160816; b=ZxAYmA59vXxP/MYMvPZnCHlCoI5sLNzGwPh/CcrqTxotAzL8RpoYxRMu6UEiQu6OQA 3OcUaUetIVEq1ADBrtEGibm7InO+frJ1gdLXjX8HkpX86cbjsNOZnZnU2ZE6PmlWnbKG RmUs4iFF2TwkeTRbQZvu51AmGOCM9MwdbTTxILxfSjP7mrTh3aOoySqYkRPWw9IFXJv5 ghmOFKO0xtSuOx7+H+X10F5lvJ6o7W7QVjmLy2qoVEJfYKYSzL2g/VXuLl4BOKJIQYII 6UNgmUoDqGL8XJ5wW3rv8crmZlV6u9LvEdDnq2xQ6NqNr/nGoRSuH6lRdfpcywf0Bqyj if+A== 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=gbHhHvdRSfNW3M6lKiiBiHsy/aZHIegD8in6WLhhzSY=; b=cV595Nd7gJGWXxtZc8PZzoSc1GvmfertTSIM5i/uWBOczACeNLHB+geyPM02nbSAwP hiFcMppw8egQEKQGZSVGtDMJvXIuvFuajRgN2a+axmiCxc9rHbla46YEtxgGN/u63Bj9 lHKsZvZXW2SegaJ60tmLPWrPkbYiZlXL+pIHV+BPOvfcMFb+rThhTXkCzi3LvFPY0M89 n023QXAl7oPfPfaYKVIxVVQ7LqnzBklHAP8LGnbZLzk9nP9mq6+DwL+PkKBs5eeDe01y 3b1GCWA0MZ0v7KNux0eW2DdEIAf3kCMznKZVd2Lp9dJPuWc6JVDa64u0e32jAUHPNJC1 Er+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=grx0sX1v; 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 r11-20020aa7988b000000b005364d3b5482si15455914pfl.99.2022.11.02.08.48.06; Wed, 02 Nov 2022 08:48:42 -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=grx0sX1v; 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 S230222AbiKBPnQ (ORCPT + 98 others); Wed, 2 Nov 2022 11:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbiKBPm4 (ORCPT ); Wed, 2 Nov 2022 11:42:56 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB19628E37 for ; Wed, 2 Nov 2022 08:42:55 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id y4so16965663plb.2 for ; Wed, 02 Nov 2022 08:42:55 -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=gbHhHvdRSfNW3M6lKiiBiHsy/aZHIegD8in6WLhhzSY=; b=grx0sX1vyt4doXabEeN05DzVGZaktvYdcCfg6WGKYn2Um48Zgp2UMnzv9yxRjGlvDs s02OzcMqRXmY81P844mFxCquKl032+JyuX8aVk9fGB0kVUT/d3ioGHRtH7AHRaujNbdw 65vnLvXCz2xWmb3ZUvb4RYrBdcrT6g2PSeo3Y= 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=gbHhHvdRSfNW3M6lKiiBiHsy/aZHIegD8in6WLhhzSY=; b=yVHE3CCFdqsVwvJ89TFjO65uOtRu+SjtYoPabZNsCUJhW5Lx2ixCriBJZucb3EArDR cv3E5ObCl0mNg0C9M2YB8JZwRfsDzQvqc3ZgHdQsUXcybRMFVQkfVsPRRVnVyKOKdmPV uI8bxsCGJ0CVugvvbm2N7lEH3eEa1fHL2byHcvihfcHIQdZDt5BaY5qQVkgMSble+8y9 hhGMkeQ5MNT2mrTddtPmnSN/L/saymcBTL4YfaNqBSI8V53/F2qrlY/Jp5+REEyyLT68 Re6sqTsX190VGXRw8UztVfDbRH8sEan324tQzTErOylNeHBKDOUIx9Apm0g8QcjiegaG nXcQ== X-Gm-Message-State: ACrzQf2QBpgQC8JaaG8/0GjTRG4gPPf2ivMEEoUBNvFKv3oQ7VceKZTW i5BMc4EKR4xRDqlyye0x9AiGqg== X-Received: by 2002:a17:902:720c:b0:186:fb90:573e with SMTP id ba12-20020a170902720c00b00186fb90573emr25604727plb.160.1667403775155; Wed, 02 Nov 2022 08:42:55 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id a15-20020a170902710f00b001885041d7b8sm47015pll.293.2022.11.02.08.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 08:42:54 -0700 (PDT) Date: Wed, 2 Nov 2022 08:42:54 -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 1/2] drm/amdgpu: Fix type of second parameter in trans_msg() callback Message-ID: <202211020842.8F3ECD397@keescook> References: <20221102152540.2389891-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102152540.2389891-1-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:39AM -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/mxgpu_ai.c:412:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] > .trans_msg = xgpu_ai_mailbox_trans_msg, > ^~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c:435:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] > .trans_msg = xgpu_nv_mailbox_trans_msg, > ^~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > The type of the second parameter in the prototype should be 'enum > idh_request' instead of 'u32'. Update it to clear up the warnings. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Reported-by: Sami Tolvanen > Signed-off-by: Nathan Chancellor Reviewed-by: Kees Cook -- Kees Cook