Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp353687rwi; Wed, 2 Nov 2022 12:43:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7V4AscxOUTVZ4+3P41JYXKdVOd1i4hNpnaKTREWpEflA388ARKAXr950tl+WZwN/C7fK6v X-Received: by 2002:a63:d845:0:b0:44b:d074:97d with SMTP id k5-20020a63d845000000b0044bd074097dmr23470552pgj.32.1667418230925; Wed, 02 Nov 2022 12:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667418230; cv=none; d=google.com; s=arc-20160816; b=FRPVztuUAq6jc7s4edA5M07ZJQePhAGGqS5NCHnBXPt38gSvLCjlGxm7f4WdDebq3b Q+PqeSuAyprgXDzNQlE35RFRCymFSOeDV5HClNVMmYEAwq4gAOBueou9cIzDa29rT+qw iC8Fi0tREBGAyZRPUmW42JJRcOLmpLcaSW6SXeh2LW4/Tm3K452I50of+PDJV12dZsAE cKpjMRBwECbFz6EYHjRdruL7HbhfYWbqlfWHBz1hMYFRHOuYaBlh2Z9dtaHqTtGhcSZh O5ZQz4Ie9ZMhO/I60vFCozeUMW2gJp5vqDKh6rAst1foEt+hxz7GVd9yysfanAOHJcaM W+Pw== 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=btNV1F5raSfgVHS1/gKMO9RappBFKUG6No8ZOPbnTjE=; b=kWrmqp8JtCVNSzac4NCFGnMrINLqvfsnzfSNkU9cAoe8+x68PQkUVa10Vv5kNaFXuU 9bsHH1wUYW9fe4uQPDiPxwP+Vs9/W6snieVgHcJDeOWBJYyL72oK++5YXQWuT0dercjN fRkYFN+MoWjAmVnAF7v5OtuFsh57G6b8WgnrElLBbmTMGR+kdeupmmS6iB6ZmWZvNICq ydqkAI+X0ufLSEmL59FmTe8C2sxcZDAQpK1SRrd50tv31tFQXWWMcJJv/Boq5lN9Wr2p sYkWxdEvDUiXBez6g1fsGmfZnM5fAUjTH7s01AanNCTIc8aRDZQpuTwlNmyNMAMwQCAw dV3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="WnF/CAav"; 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 l9-20020a170902f68900b00186c41eced7si17392996plg.36.2022.11.02.12.43.20; Wed, 02 Nov 2022 12:43:50 -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="WnF/CAav"; 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 S231855AbiKBTJM (ORCPT + 99 others); Wed, 2 Nov 2022 15:09:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbiKBTIp (ORCPT ); Wed, 2 Nov 2022 15:08:45 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14A5D1263E for ; Wed, 2 Nov 2022 12:08:31 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id q71so17044174pgq.8 for ; Wed, 02 Nov 2022 12:08:31 -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=btNV1F5raSfgVHS1/gKMO9RappBFKUG6No8ZOPbnTjE=; b=WnF/CAavVaQFZ6hu1mucTiUFMFRH07YS8pP+nQhN6HJJeWng0qN/pqcGUZWF8DF3YJ UKrrhCuT8pZe5efQKDQYbL4sl4O0d0Yq7dniUij9mlyoue48MfGSkAiZceOt6LH7Zyla DMmq4Zy98pWpB2nYorJEhV8afi41FbMNfLd98= 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=btNV1F5raSfgVHS1/gKMO9RappBFKUG6No8ZOPbnTjE=; b=fa7kgKdjaKOt/iggVfGHnBaB5kl+k3zQ9f/Z+GLK6kHSV1HTn7zoX/Fk/RZwz4sL2o a0R8bGiXs+fD5AlhmTzhOYMUo8CWJn4a42EgE6Z+LchA9ILo+msbdAPoYSFdgv52F2fS AuXe4jNzaJ13SeyoDsh4PXEbm7v3poUNOkkRZy9eFPpom/ZRYsFpPW9voQDwhNzTjW6H VPGGp4govbrGnOXF1AwG8hfL2s4LDAaQITrUuBzhRHwjlL7csQ6SA37Jz0M96Chvz0NX xRfKO0PIeEF8fMGE/msynPosjmRziGU1s1scBxSDghB+SwrNQpLEG5Ba0XpdVFDxa53W FoVA== X-Gm-Message-State: ACrzQf2xVUsuu3rk4CDrj4ox8Yz5HpqIVDcY1KNbSzsfrqgz7+EW5Rk5 Mr7EdFaTmhCYCxBSGfA56IDW1g7injzULw== X-Received: by 2002:a63:501f:0:b0:46f:a711:c455 with SMTP id e31-20020a63501f000000b0046fa711c455mr18062893pgb.402.1667416111214; Wed, 02 Nov 2022 12:08:31 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id v20-20020a63f214000000b0045ff216a0casm4784265pgh.3.2022.11.02.12.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 12:08:30 -0700 (PDT) Date: Wed, 2 Nov 2022 12:08:30 -0700 From: Kees Cook To: Nathan Chancellor Cc: James Smart , Ram Vegesna , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Nick Desaulniers , Tom Rix , Sami Tolvanen , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH] scsi: elx: libefc: Fix second parameter type in state callbacks Message-ID: <202211021208.055D396D8E@keescook> References: <20221102161906.2781508-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102161906.2781508-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=unavailable 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 09:19:06AM -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/scsi/elx/libefc/efc_node.c:811:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] > ctx->current_state = state; > ^ ~~~~~ > drivers/scsi/elx/libefc/efc_node.c:878:21: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] > node->nodedb_state = state; > ^ ~~~~~ > drivers/scsi/elx/libefc/efc_node.c:905:6: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' from 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') [-Werror,-Wincompatible-function-pointer-types-strict] > pf = node->nodedb_state; > ^ ~~~~~~~~~~~~~~~~~~ > > drivers/scsi/elx/libefc/efc_device.c:455:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] > node->nodedb_state = __efc_d_init; > ^ ~~~~~~~~~~~~ > > drivers/scsi/elx/libefc/efc_sm.c:41:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] > ctx->current_state = state; > ^ ~~~~~ > > The type of the second parameter in the prototypes of ->current_state() > and ->nodedb_state() ('u32') does not match the implementations, which > have a second parameter type of 'enum efc_sm_event'. Update the > prototypes to have the correct second parameter type, clearing up all > the warnings and CFI failures. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Reported-by: Sami Tolvanen > Signed-off-by: Nathan Chancellor Reviewed-by: Kees Cook -- Kees Cook