Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp197558lqh; Mon, 6 May 2024 16:30:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUiL9iOEKVZ4wDAQfUWlKEoN/UJtE10fm6HCqdboffRB/u/aObodpaVmu66U/PWwjXtIUI4E9KUuWPHM11mjiLGEgML+2qKFCOcFpHtRw== X-Google-Smtp-Source: AGHT+IF06b15IFy2nwnDMO5zuU0KRxVpSlkWabmlXfGqM09irY14WDdO6hNGCYc25HXgo75re79g X-Received: by 2002:a37:e208:0:b0:78a:4d0f:21fd with SMTP id g8-20020a37e208000000b0078a4d0f21fdmr10075472qki.63.1715038251199; Mon, 06 May 2024 16:30:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715038251; cv=pass; d=google.com; s=arc-20160816; b=wKpSyKTXH1dQ6I4H01PlJxgG7ugROetdxiIlX7qMEQDft5+5QeGjRKq4/a4q8MEUww NEKnC6gvhGKF53DedNwDYNSv9VcRoA3Ot70t2lXoMY9pTHhQVFy3z8FwCSNN11ZsY25K /onFgI34UA8G+pggroW9i4K0GKRGQvt2uS5DZCugNrIwj+6O2AzxwudjXq4ZnHPu+yyI lkzcggG2QljOBPnNavSzaCuQQIhi/rmnxMIYV4soCa3TPN/LT0o+2LRLDx/pG+Got3z4 1lEWVISvfGMvsXtCO6pHgxWFDZdyoTqxSaYzCmQyTM+27FrVAN+rlwl3iSYNpGr7wNl9 OZfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=rday+enGpH1mUN4w1iIrCf7IG9Q6aF8QR6lBBrCyZ7g=; fh=w4TbhjwP//c/UGiC+TKadfFovGmvse3Xfk4K7ZFz/kc=; b=J2XCAFSY5lwWPay718vCDCud/OV5Uo7w6kfJ6QxNxTyh8BV9pQl2CslhA86r9ZoShe JI6oO6vwFYqPe0q39a495eQNQepbEHTIA8KH+s9smGYzRCjdY6s8FXD2IPAOzQk3jFnZ LFg54YB7k5o2QdEd79xPgWLfT7AnjVsWhuFY0g2DCmhqTVNSSI0u3nGxtwV1QBe+wAOO VL4RaWRzN8VEExzBcIuLMO/20yE8wJDfH1LD4hYs3ysxsPDsFc2DMfDhjfMCcoxJdafo Whn1PVLrh+UU7T6FyINAKIfOuVsKka30UX1uHnuhTjMUsMlyUSDiMQ7ZUixR9YFcCUVE Zp2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vejhz29H; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z20-20020a05620a261400b0078d4b620c82si11419355qko.609.2024.05.06.16.30.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 16:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vejhz29H; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-170506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E42E01C21C91 for ; Mon, 6 May 2024 23:30:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5EEF15D5BB; Mon, 6 May 2024 23:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vejhz29H" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EAB715B0ED for ; Mon, 6 May 2024 23:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715038244; cv=none; b=ZcRxbnwnFoBJcia7iM6PapMb3EG2x6v9IY4ETaQkkFBYg+S2NGePJpTJVi+3OWhkt+H4yG5CbVZiB3Un8ITsgi56IyZ6g2Vs34qSlZVESEsXOdd44hxVLwkpZFZJ0iYxun5zVpAJUM/y1IQH8bZUty6eblTCwx3W4KXO730RdDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715038244; c=relaxed/simple; bh=dC5gmNPxNSH+aIEWUfqlcoUV3/RSi8n3oR46/xve6dA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Qi62R9jNJERojl/JXLKWCJ1li7mqltu1r98mQ3W8vRKp2NUGaeH4HpjSsmbvNRTdKlN8ggtsPYGB4elE8jNfnhoUMUT9gGYdCvdjbG4eFG3qeQgGBsl8czlqIyzFc34sh0fdXJQ5Q5yWOWrUZ8lkSXo2LGUz3NPxQoJHKGD/m7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vejhz29H; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5724736770cso2362a12.1 for ; Mon, 06 May 2024 16:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715038241; x=1715643041; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rday+enGpH1mUN4w1iIrCf7IG9Q6aF8QR6lBBrCyZ7g=; b=vejhz29HQj+gKtb2WBiToZaEiReMxu6rMyWsEaQNyrYelzJtXm6QXARFGs+gCMc9uI 1bR8A8t7uZb8FSTLnOipGuyAZmNvSCl2NFiAbn4XxXfy1Imvhd7IVqvIN+bib+3w1lg5 IPQd+9F7JFynHtvPiJBcLsZxTmMac1vH7Gm2e1xTsVooNKySrtOU+K8dzpYmwKqHaa82 0CNs5dMpqqcaWO5Xlv5V0TwvxIYN32LFWPStMApOSn/fJ5Nxj1XPwaooQvf/nQ/JLTvf H+wXXm5iOf+UNGNkM2f30GeWTBQxcMGMYv7L7JHrGMtb3P7m+yGK18wfaU1L5bTxH32p r+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715038241; x=1715643041; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rday+enGpH1mUN4w1iIrCf7IG9Q6aF8QR6lBBrCyZ7g=; b=iaBZys04c2ZZIBzzKnvpZNnP2sibiSgG6yMjcBkSTLlZiiKbTjGf7O1tsWOlGp0ldH dH87vMuywC483nAetBYn75PKp0rDsD8WOkzLk8eIbSIjFarF7wzz1oDH/7KhmJpu5Xdq 7A7ZAocphUu/2pDXCfWKkURlHiAWJbrDNmMPg0nhInWQQ7UGY1wUlZD4UDTYV0kR5vec A2N4GgBE3dgfqVaUSRi4TrD+kCIejCkPsF9cG8SZ4276zs+DYSQLq0Jdw2e7eq2YX7YQ zqJ7x36Ekwca1AH0mHSEwL5qV3OHZ4owNmu5YK1C2EAR95BRM4eagiHPduGmyH1snhnQ rtYA== X-Forwarded-Encrypted: i=1; AJvYcCVLniFypJWYOgDsUXaT2wbl+0dfGbbngPZUaxth7Tw4gL11f7jKkfXeAmCTxC+daueiJ+BIc6abHsXXYTqmo9WXmLEBKld/6YkqyLEr X-Gm-Message-State: AOJu0YwcaKsRnNRT32F13i7YASbw64J/n1Rf+h92gjLNRXRwyj0a6olz RIPJinOkI5wakozAiP2HnO2670EQAvJrI1EYQ2tzsWJTvh977zErX9oRJ1+n2CO+qyPqxzrxlw7 Z6GMcTXBQB+k4TT78IMHkOMq7jElvkpjxy54q X-Received: by 2002:aa7:d389:0:b0:572:554b:ec4f with SMTP id 4fb4d7f45d1cf-5731316c507mr37653a12.3.1715038240800; Mon, 06 May 2024 16:30:40 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240416152831.3199999-1-usama.anjum@collabora.com> <202404161027.63F4D4FDEB@keescook> In-Reply-To: <202404161027.63F4D4FDEB@keescook> From: Fangrui Song Date: Mon, 6 May 2024 16:30:27 -0700 Message-ID: Subject: Re: [PATCH v2] selftests: exec: make binaries position independent To: Kees Cook , Muhammad Usama Anjum Cc: Eric Biederman , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andrew Morton , Yang Yingliang , kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 16, 2024 at 10:28=E2=80=AFAM Kees Cook = wrote: > > On Tue, Apr 16, 2024 at 08:28:29PM +0500, Muhammad Usama Anjum wrote: > > The -static overrides the -pie and binaries aren't position independent > > anymore. Use -static-pie instead which would produce a static and > > position independent binary. This has been caught by clang's warnings: > > > > clang: warning: argument unused during compilation: '-pie' > > [-Wunused-command-line-argument] > > > > Tested with both gcc and clang after this change. > > > > Fixes: 4d1cd3b2c5c1 ("tools/testing/selftests/exec: fix link error") > > Signed-off-by: Muhammad Usama Anjum > > Thanks for this! > > Reviewed-by: Kees Cook > > -- > Kees Cook GCC versions before 8.1 do not support -static-pie, while https://www.kernel.org/doc/html/next/process/changes.html says the minimal version is GCC 5.1. Is this a problem? If not, and CFLAGS is guaranteed to include -fpie/-fpic/-fPIE/-fPIC (PIC), using -static-pie looks good to me. --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF