Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp359463rwi; Wed, 2 Nov 2022 12:48:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4gK53V0TRZGKpNhh5K5Jx6QQ0K723l9wp6p0o9Au8X6qidAr8t3QCs1b9mV8UxoAcQUJc4 X-Received: by 2002:a17:907:1c9e:b0:79e:6d97:5e0 with SMTP id nb30-20020a1709071c9e00b0079e6d9705e0mr24783244ejc.534.1667418503427; Wed, 02 Nov 2022 12:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667418503; cv=none; d=google.com; s=arc-20160816; b=frjTHr2TQFZEGzOw9zcLBo5rfkyaWToMfVgJnNAKuy7Lo1DTaiAwoMxH/9zommL+7m vLUBDWnwswPDP7QsH9ZwLmVelS9z0d2tu6T7vrezWwprLHt4KAQJbuPzIUiAF5y6gzf9 CqODw8EkuGFpT3DLVnfAINsm7jmtjRFY/03JBZosen0hWoN19QluBXG8ane6dJxQ8FJO L/rM3gddjIzMyvUqk9Z6X9kYMAvNWc0xOAbT+Z+joZpwCn1mEWBLMR4/ZDrPlDZJMqw2 WA1juOyF7BwHwiFKDlKO3CgQvtSyY8Q4FrfNtXWN000Yz/p+9enGqP7OaTige6m2ltSY JC/g== 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=71cIGVUi+2jVEjXbTMLP+sHbufV3ZHGsKiLlY1xVyE4=; b=bXX5rWpd6N/4SWVtKoDRnO/at69KGnOmtDuBldahBpL3ymqAAyk1iXg3HB4Fk9V/bf uz4zrz+Iy6qan3SmLcY+Tr7qtyLGGeT7QjgxVqHr4K31Rd6eEBMlgqb8YVd0K4gvEX1c uHlQ3F544B9Z8q0nw55CC2C9aW7PJoFkCaQJEG1smp03NCc2VvcKGWN+sEfE24ZDafqz sZD749SA2dKKfa7zjwzSry0vi6DJMNLLsjb0Kb+tX+sRYJCfGEm6M+ZXFQpW31Q5aQri 9YR9To2u0Qr4OiPYO6j2b1x+We6AYbMpYuzT5wep1DVDH60Z0VTclRb0IxWhgLZkUZy7 OzlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fjGGSl6T; 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 y5-20020a056402358500b004614db9083csi20262913edc.313.2022.11.02.12.47.58; Wed, 02 Nov 2022 12:48:23 -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=fjGGSl6T; 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 S231601AbiKBTHZ (ORCPT + 98 others); Wed, 2 Nov 2022 15:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231945AbiKBTHE (ORCPT ); Wed, 2 Nov 2022 15:07:04 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54AB1EE10 for ; Wed, 2 Nov 2022 12:06:52 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id u6so17462444plq.12 for ; Wed, 02 Nov 2022 12:06:52 -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=71cIGVUi+2jVEjXbTMLP+sHbufV3ZHGsKiLlY1xVyE4=; b=fjGGSl6TZGy6MhSeAlQ9V3XlMvK9/dKuFuRpy8Ew/54JsuPSu62uZ6R7xn5ia9d6mL xmWYa3LxJrXqfZL52eFl4W2S7p0zWy5w3mpFGbEqxRpS4Jz1o7xWa7Czjp+BMc/29Ion AObRStps16tXSHWBnfGNhb6ksTT8C1QPkW5mM= 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=71cIGVUi+2jVEjXbTMLP+sHbufV3ZHGsKiLlY1xVyE4=; b=cc4hLp3gqiI7elqEu2ExjwkMgo8vA8NedmwbYqXItO9jl/+QKxIfbrSOy25TBWxcjJ JfVZ5DFX1jAy06hbBcChPZte2+g/ICJUfzu9fu/oE3iLO+CZnlpURQJ2tSIfSsAw9vqb x0syOsHn732g/G5pL8hewLZibQU1/3CDcmJA+QFu1TpTbKNUqx+ZmU/Ybt0CCGkX0Cqo ejrcSqWAeFhLMW2xSbDcBvgSx0A+uTV4GOy1O4+KV5EaGJyb+C3b+CGxim9r22q4MWTD zmhMkNRb0uQMIeJ6nxtmFAlCHcRGZfNynCPRHo7a1+Dq4e7qWA5qIq1ssI/y7iyzHE1z Hqfw== X-Gm-Message-State: ACrzQf3oTkqB0XuxTZ/hwZj+zsjP5ptTZCe3Y7Tfs5YkzaDnLMBaYdKj CIvUy/uDq7kZGE/GOhB1xdSs9w== X-Received: by 2002:a17:90a:bf82:b0:214:6fd:90ec with SMTP id d2-20020a17090abf8200b0021406fd90ecmr11317834pjs.61.1667416011472; Wed, 02 Nov 2022 12:06:51 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l12-20020a170903244c00b0017da2798025sm8710635pls.295.2022.11.02.12.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 12:06:50 -0700 (PDT) Date: Wed, 2 Nov 2022 12:06:50 -0700 From: Kees Cook To: Nathan Chancellor Cc: Alain Volmat , dri-devel@lists.freedesktop.org, Nick Desaulniers , Tom Rix , Sami Tolvanen , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH] drm/sti: Fix return type of sti_{dvo,hda,hdmi}_connector_mode_valid() Message-ID: <202211021206.1A488F29C@keescook> References: <20221102155623.3042869-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102155623.3042869-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:56:23AM -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/sti/sti_hda.c:637:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = sti_hda_connector_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/gpu/drm/sti/sti_dvo.c:376:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = sti_dvo_connector_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/gpu/drm/sti/sti_hdmi.c:1035:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = sti_hdmi_connector_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ->mode_valid() in 'struct drm_connector_helper_funcs' expects a return > type of 'enum drm_mode_status', not 'int'. Adjust the return type of > sti_{dvo,hda,hdmi}_connector_mode_valid() to match the prototype's to > resolve the warning and CFI failure. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Signed-off-by: Nathan Chancellor Reviewed-by: Kees Cook -- Kees Cook