Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp488726rdb; Tue, 19 Sep 2023 01:08:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEi5OAyf7mKhIDJ3XM0Bs2QKZ2bOq8oBVGHNlomN4Wia/UifxWppKmIS9+uCUTMWz0eFjji X-Received: by 2002:a05:6a00:80c:b0:68f:efc2:ba51 with SMTP id m12-20020a056a00080c00b0068fefc2ba51mr11786215pfk.21.1695110887342; Tue, 19 Sep 2023 01:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695110887; cv=none; d=google.com; s=arc-20160816; b=PtnpxhPo4+hB6TA2CgKAdeI/4dUm/Mfccb3Wp+9TO1WQVgt3XXTr4iXnJIOjGH5E6y kwflxzhxIFmIVFc6/ifnottNfw+1YsKe9cMRIgHm3lf51/85A12YUQPmaazWduYVNQ8E yeD2fdSuzafQFHoWdA1At1OSxXu8nX1cIZXQQUuhmMc5kOHmR6w3e63Ey1HzdYBnw5o6 +RjrHQtAXsNcZoszsG2ViKwwC6EjeItExdvtTF9zGdnnGte9+74JIBafWOIuoMofwfRy eeVpQIKQLc3/0CvjLEWR0Bj+VoZnKVIkTJjLMTTXkZMaeJZxsqCDyPe5rVzF8sIUfkAk whUQ== 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=roZV9F5FyFuDCeFY1+u+qcz6qw5Wz9LE+Zv6v3iaQKo=; fh=+c+LjeOnJ+R82KjXLp66U8MCw5SxaJvD9nhJScgUWtc=; b=xf9GPJ7Aj49jUXCeizm97hdMjaRdD6Y4+ebc2OiEgtAhRzK/z/ymQ8tGRa1R5SXQ63 SC/TQ7ZmLz5OhVFZFxYFdBM3hQk0iVQ3w0ZgXwtP7u8+PmP0dGLgCN8+tDkOgX1a70LF EOAkRbsfat6xF2BLyCGv6L2prB93p79xUDhviLPIr2chdv/OMioY/mmWAfT66zUBq7XB JiS0A/8jC2I/GZJUTmJwEBPb3ZP1y91CqIn1npP8rM1+Iyq8IF7haQXqOLccS+56QjYf zsLYreGqXkcO6ajC3HFx+S4QJ8GvvUxRgP2rMxzgNh3fWd2orQoYX3sxIIF0KwKfOyhH ynwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DPrYWXip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w4-20020a656944000000b00578a30162c8si1431103pgq.537.2023.09.19.01.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 01:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DPrYWXip; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6608A8096397; Tue, 19 Sep 2023 00:57:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230206AbjISH5Q (ORCPT + 99 others); Tue, 19 Sep 2023 03:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjISH5P (ORCPT ); Tue, 19 Sep 2023 03:57:15 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDBC100; Tue, 19 Sep 2023 00:57:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CA4FC433C8; Tue, 19 Sep 2023 07:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695110229; bh=htQQ2FKHvXLVeL8p+eXAdtx1fMJOjR4PUpElFMKZmN8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DPrYWXipXZJdXGi4m4osl3qZ7MBnh8weLjgO7/xXIO5pQl8clIxe/0Y0NZxtBJ9UY nUOO9CZDTA0arOa8FsurXadf0pzWwjCBNfFOXdXIC4WOUDMV+4Z/Emdo/qH2TOy0/N czCoFE0oyL3+SY1NbA1+93AlBKQkXDhGKUd312ao2Le0mPIQVjvcDfj0c8UZ5/4wfz 7uhbnt8zod5c3QxB5ktAOEcQu6wvpan2wWQFugq5mpQIC1qfIfoSsuE0U/V0MPZEAK n2q7xpXKC2f5aNSo+9Js1azxyt+xv86exbrDS753wojB/7IN3cAg9/J/ThbIGokR/8 I7H/DBkCJybwg== Date: Tue, 19 Sep 2023 09:57:07 +0200 From: Maxime Ripard To: David Gow Cc: Nathan Chancellor , Kees Cook , Brendan Higgins , Rae Moar , dlatypov@google.com, Benjamin Berg , Richard Fitzgerald , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-hardening@vger.kernel.org, Nick Desaulniers , Tom Rix Subject: Re: [RFC PATCH] kunit: Add a macro to wrap a deferred action function Message-ID: References: <20230915050125.3609689-1-davidgow@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qzavn4uvzmrnbux4" Content-Disposition: inline In-Reply-To: <20230915050125.3609689-1-davidgow@google.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 19 Sep 2023 00:57:15 -0700 (PDT) --qzavn4uvzmrnbux4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 15, 2023 at 01:01:23PM +0800, David Gow wrote: > KUnit's deferred action API accepts a void(*)(void *) function pointer > which is called when the test is exited. However, we very frequently > want to use existing functions which accept a single pointer, but which > may not be of type void*. While this is probably dodgy enough to be on > the wrong side of the C standard, it's been often used for similar > callbacks, and gcc's -Wcast-function-type seems to ignore cases where > the only difference is the type of the argument, assuming it's > compatible (i.e., they're both pointers to data). >=20 > However, clang 16 has introduced -Wcast-function-type-strict, which no > longer permits any deviation in function pointer type. This seems to be > because it'd break CFI, which validates the type of function calls. >=20 > This rather ruins our attempts to cast functions to defer them, and > leaves us with a few options: > 1. Stick our fingers in our ears an ignore the warning. (It's worked so > far, but probably isn't the right thing to do.) > 2. Find some horrible way of casting which fools the compiler into > letting us do the cast. (It'd still break CFI, though.) > 3. Disable the warning, and CFI for this function. This isn't optimal, > but may make sense for test-only code. However, I think we'd have to > do this for every function called, not just the caller, so maybe it's > not practical. > 4. Manually write wrappers around any such functions. This is ugly (do > we really want two copies of each function, one of which has no type > info and just forwards to the other). It could get repetitive. > 5. Generate these wrappers with a macro. That's what this patch does. >=20 > I'm broadly okay with any of the options above, though whatever we go > with will no doubt require some bikeshedding of details (should these > wrappers be public, do we dedupe them, etc). >=20 > Thoughts? Looks awesome :) We ended up using a wrapper in KMS to workaround this issue and would benefit from it too. Maxime --qzavn4uvzmrnbux4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZQlUUwAKCRDj7w1vZxhR xTUeAQCXea7YsXjxXaDvxqjnE997V4ealgCJYazsP/VqEvHEawEAp7F5FghSDNVD /T5BI0YgKuv0gkRyUl7Mzj3oYZDKEg0= =Vf6p -----END PGP SIGNATURE----- --qzavn4uvzmrnbux4--