Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp153190rwb; Wed, 14 Dec 2022 15:21:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jENmsFX23X7tBOEt5C17IxESAv83rrLzGwmiwfNPjYn6thsqOh7+nzh6o5+uy/ZRk2216 X-Received: by 2002:a05:6a21:3397:b0:9d:efbf:48d5 with SMTP id yy23-20020a056a21339700b0009defbf48d5mr41905851pzb.25.1671060078099; Wed, 14 Dec 2022 15:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671060078; cv=none; d=google.com; s=arc-20160816; b=vEyYxOXK9VGV+Gss0RrApN2LT8mwZZcEuiwH6KKMfmuUUDBVspijSp1CBC4Gsk+IQO h2h/DpC4KRU4zJ2udvIw/Ev01Wc2y/JicTSdD0FZbYdiV9BY+EgHPmLZkN2z8Tfm6MP9 Qp6XoLfgWBifNoIFCJ1VHqcjr5RO7tvVRN4A5lWv7f1lP7DGew2l6d0ZsK0NzsDmFGGJ FjItCfXxWeRl2UN479QCPt6h5Jdhk7WMZO34q0ukeG8EY5sz6L/qXhJhSgtSqaCHqvO0 OpH0eKP+JU5W/Tv5b1UBEpRURqvXezUHGscVDLdqE8aGbvbf5EHTud8CcCeXTOwHwbi1 fBBw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iMEJ8qWvU17qF8Iw6KkCvqlY5TEaxk9MDPpeFJN2leo=; b=lsLISL2i8DzgA0/30VLgwPNPiI2u8vbmajHZmZp1DViQgXjVvvEtjiTBgU6eXPR6Ad pWmy8kO+YZthwB6MMK2BhpgCIDciGGuNCjbV4VBwX29GnauirmY9Nft/nFwLuWoJXG9S Qy+pITani5qwOsS9ZKhFmyJI82GEn/q3rtno24YkO5ORP5DvJ9lpTrLwo8A8ghrlQ+5c 5HKZLHLu8C4HIONJkThpRKmSPf1kQsumSjjPilI9H0b8/KnlW8ApqS4pkEuuT1wV8sn4 lvW/uHc1x80PqIY3j4xWM56RgDU0Z+XQ8LKKILDElhWw3Sv3zBMBBivEnSJ2hCmQQMih +heg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aXfHEhtI; 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 n14-20020a63ee4e000000b0046f4696a544si1188364pgk.128.2022.12.14.15.20.20; Wed, 14 Dec 2022 15:21:18 -0800 (PST) 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=aXfHEhtI; 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 S229492AbiLNWsd (ORCPT + 69 others); Wed, 14 Dec 2022 17:48:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbiLNWsc (ORCPT ); Wed, 14 Dec 2022 17:48:32 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A5D531EEB for ; Wed, 14 Dec 2022 14:48:31 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id w23so4927573ply.12 for ; Wed, 14 Dec 2022 14:48:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=iMEJ8qWvU17qF8Iw6KkCvqlY5TEaxk9MDPpeFJN2leo=; b=aXfHEhtI9R9soKDZaToBP0eHoF2wK2L4yt464De59nc6HszERIRBsqLpZZ+DFxc96F ErGuCCGWsqQeO+Y1l54z466jTHAlyVTnV523ltKdLyfd0Iho/DTDTk578EVfOjG7+STh xQf2eoCCBBhAtR68zaS7SgJiOTnl2XhSwFrvM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding: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=iMEJ8qWvU17qF8Iw6KkCvqlY5TEaxk9MDPpeFJN2leo=; b=PqbFDdN9NL3vFIE7gfn2BtNeiRAvic76JW4+7jvyOAB+9IBMeMOIFLl8nx2A5GqyrZ leS2oupWiBl4ger3oaI7g2anOxYcXCdJ4d1gYkRi4TgaNRipFkQQIywu6Q1uu6p6OtgG 8CbSfKw8DJAYL5pPzWWEmwLf3h61d6Olc70OnoAkc9/fOnqmzM4Rnp4eXLHmEPs97tVr SKJdKNQZ5GbxLudz9ZSOHZoWK+aQ7cJ98WvektrRCMmA4WkzkfewCnOhAzwYi4hXfnE9 rOMELhNMMDJlrl0rtykIDU/rAlLZVNve1qh2WVpDUS1VZ4wmCxp0ayKvpmhht61XxrIX mFVQ== X-Gm-Message-State: ANoB5plBUkVS3nxpT+cuCFXSBCTXxXrfVut33RRQJY50H+CjyuzIn8SC YKyB0SsvwylLae2FGTH04CcekQ== X-Received: by 2002:a05:6a20:429a:b0:af:89c2:ad01 with SMTP id o26-20020a056a20429a00b000af89c2ad01mr1690943pzj.40.1671058110782; Wed, 14 Dec 2022 14:48:30 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h8-20020a170902680800b00172f6726d8esm2327431plk.277.2022.12.14.14.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 14:48:29 -0800 (PST) Date: Wed, 14 Dec 2022 14:48:28 -0800 From: Kees Cook To: Kristina Martsenko Cc: Daniel =?iso-8859-1?Q?D=EDaz?= , Dan Li , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] lkdtm: Add CFI_BACKWARD to test ROP mitigations Message-ID: <202212141448.03552F3@keescook> References: <20220416001103.1524653-1-keescook@chromium.org> <202212072221.A9FCC905CF@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.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 Fri, Dec 09, 2022 at 05:34:41PM +0000, Kristina Martsenko wrote: > Subject: [PATCH] lkdtm: cfi: Make PAC test work with GCC 7 and 8 > > The CFI test uses the branch-protection=none compiler attribute to > disable PAC return address protection on a function. While newer GCC > versions support this attribute, older versions (GCC 7 and 8) instead > supported the sign-return-address=none attribute, leading to a build > failure when the test is built with older compilers. Fix it by checking > which attribute is supported and using the correct one. > > Fixes: 2e53b877dc12 ("lkdtm: Add CFI_BACKWARD to test ROP mitigations") > Reported-by: Daniel D?az > Signed-off-by: Kristina Martsenko > Link: https://lore.kernel.org/all/CAEUSe78kDPxQmQqCWW-_9LCgJDFhAeMoVBFnX9QLx18Z4uT4VQ@mail.gmail.com/ Thanks! Added to my tree. > --- > drivers/misc/lkdtm/cfi.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/misc/lkdtm/cfi.c b/drivers/misc/lkdtm/cfi.c > index 5245cf6013c9..d4bb8e31a2fe 100644 > --- a/drivers/misc/lkdtm/cfi.c > +++ b/drivers/misc/lkdtm/cfi.c > @@ -54,7 +54,11 @@ static void lkdtm_CFI_FORWARD_PROTO(void) > # ifdef CONFIG_ARM64_BTI_KERNEL > # define __no_pac "branch-protection=bti" > # else > -# define __no_pac "branch-protection=none" > +# ifdef CONFIG_CC_HAS_BRANCH_PROT_PAC_RET > +# define __no_pac "branch-protection=none" > +# else > +# define __no_pac "sign-return-address=none" > +# endif > # endif > # define __no_ret_protection __noscs __attribute__((__target__(__no_pac))) > #else > -- Kees Cook