Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp214177lqh; Mon, 6 May 2024 17:15:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGd1SJiMqZ9b2/swSyL9uHxKsJcLk+w++EkzvEYUiNA+pkZL6em7xhUF62xTV6mH5Yw1bzlyoCdL2/GxlTbvpl5tqWXIYtOclGo6qUyQ== X-Google-Smtp-Source: AGHT+IHEEgd/eDnAxQBvxfKzg30wxCAJi5dtOevXhXcj0mqgceJxrbjjEkjoR6cyVkph8yTG+35L X-Received: by 2002:a17:90b:886:b0:2b1:3cc7:ae83 with SMTP id bj6-20020a17090b088600b002b13cc7ae83mr9330627pjb.32.1715040901297; Mon, 06 May 2024 17:15:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715040901; cv=pass; d=google.com; s=arc-20160816; b=wzRCzUVVSpax0ad2SuXyiHFnlQ4s2okqFPhHwC2NylxduR+wEcXaz6Y0toe56NY3YN 8C8Ijh9NnxMDiJnf1Xw/PX8ZKQqdnkQzeE2l/Lbh9O4+bUapxxuZHHRcCdTDfvWbfzn4 pEgxWTTszkz8QQHf+tQG9eUepdHShIwtrcC2h7NDrFb9uS39jj5y+rzyP8MVv6RRKOTY lIPc97UgcT5kksydWfoexqRSG4eiycu/MqFubonQuXRaTWwrS8zY0h+iM+ybeG2qVRm3 AOwEtKujn8Jy33BRVDYg11ZgWJj704iC9KSYGotfRoNDbqONaZXzB2ZpYjha7B1d0/Vz H7aQ== 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=B8oWcFWnZBGCM1E5sWUM+4SbAQ1guZn75qzZz72Y3AQ=; fh=iy3mtqv5okDbwNODJJUqmUeg7qh+YcL/krQEee2vcao=; b=NrT+ve92NdRFII6es0GqD5+1PG5gUaJwZkoFnd2bIFfRzIY+liueOArdytX0wryp2E zDx0+T9iBuf0VAcc7Dzn2Iw5cs0AKKVyrkwsu/GKPkd9uotEQbr9VpnCqZ1xJl+Ts3Je Sxp0QAM98OPgx6iTe4d35d/J3H8z1fmC+sUFc8w/yE2rQ+3zGgZIfsYAUHKhIcdV6FSB 1zgow/+tFwe633W1hnTOzjL8IKGybotIt3u1QagNKECceYpF217EwxjWgsObuaIir1pf vV2+V3XbiGacgvKQ+QWDxt8NzW+kRXkjgZTxe4FZ02YWpOTfBI1DOzyqWffKzo+vaG63 wNsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NtNluoYS; 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-170519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ip11-20020a17090b314b00b002b142ee0bfasi9641225pjb.74.2024.05.06.17.15.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 17:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NtNluoYS; 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-170519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170519-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E4E51282268 for ; Tue, 7 May 2024 00:15:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE56665F; Tue, 7 May 2024 00:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NtNluoYS" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 52417182 for ; Tue, 7 May 2024 00:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715040893; cv=none; b=L9ld6I3JmDqJDE4pK3hkCw9GglulPHmfC5A8zsmBfmD5K02xILGUYXMMH7I1kFE2gE8vaS8tGiLyzfI2XBuuWFnRSbwD0ycxJHh0tMenn0NYESJJTzLDbhUQqlWyYrAq7tPRRwaDOZ75hcPU4BApgm9E6Wq335FWSboQEXEX2to= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715040893; c=relaxed/simple; bh=lu0OQIrcM30++N9sDEIpsDIcuzGB7E5UCYPW/qPlrfo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=hwlKV4yd0Av+nVNlb0Kc2uJdhljdK2OAdsjfVoNd7uQWv1foSAaKvk6n9wuT3bg6kjkxPnHBFEyKFjlcD81Z1QCHAx65NS1ONDIu+Fox5Y0+VmHcVeafAbnEcCHJaQtQW0CIBB1M+vvc5tkHatGG29lbL92VY+cGKgvYCLssOmU= 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=NtNluoYS; arc=none smtp.client-ip=209.85.208.51 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-f51.google.com with SMTP id 4fb4d7f45d1cf-572aad902baso7173a12.0 for ; Mon, 06 May 2024 17:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715040891; x=1715645691; 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=B8oWcFWnZBGCM1E5sWUM+4SbAQ1guZn75qzZz72Y3AQ=; b=NtNluoYSNsl4EIr92M4syUAOjb4lj+hBtxoLgRjoE45FQEmPwiwKqCFfj52kDRPvdV DQwVqVVG2RpFc37OA7q4lLqvA9W8U9choz4Wsoue2O3L+UzLboeMTAo8Tk8BmhO5gQi8 k1Xd3z5Sx/0OqFBraIhe7aRWkRM1NH3q3gfvNfI2tmLM7tjC3jysak/5IJykgo4by+Jc ml6cqUn1VgJYiWniRcwM6mvqkovCdEszV0TsMfbCIGP8Bvc1nMyMKUDZBazn056P+kC3 hK/GAZ4PDji8aNfjcfnUzRW+qTrmfZMjI7Qnq3MgDLVLaEf+1idRq/8iTBPHqi7iqidB 6Scg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715040891; x=1715645691; 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=B8oWcFWnZBGCM1E5sWUM+4SbAQ1guZn75qzZz72Y3AQ=; b=B8q07UIvvTu8C/gQKnvR1mgY1qVsp1Dxp+if6wM0eGNT0Tn3lO9odxpbcMvIHYnln9 yXkqLZqYby80Mj/bR4oqAwxn8/yAlAtkrq1aavi//zYCWb/V4Qv89oi9H5oSACk0kp/z olckYCVcmIp75fbvVk/V7WijGKvcgLZOVOHwWTXTVx1UZb5kSfSBjRnIBynwikNJUMrL 7gSkFnHTXAirPfgBK8B2jsWNR29u+1jMAgPTxem12feGjOOQZqLQsT1FR1LThG1tqTav LjpSzsBS+oY9oj1VA2E+jvwpbEexXn257dVo6WXOmIHZoGRjqoX7W5SCZIg3qj/NlmQL 2U7A== X-Forwarded-Encrypted: i=1; AJvYcCVzBfv5x/kPee1NPTVKoOB+45VtHJVq/CiY/iowkSNJF2QQXpSoUostR/2YvmjEzKdWU1+ZDxq0qX+KvOnC/YnzCTxFMgSVxpHCjs6W X-Gm-Message-State: AOJu0YzciDvSzmIYZXwy56MN8aHqiguEBEW+WesDnoT+lBsYJ5F6o8e6 O88x9TaMM1IBsJ0A25uelUapAvIrfwFQY1TUc+R6p/C1VRzhPk1W8mOLCpNFmxoHiSKByGsABpa kXERKREfX6PIMi/L/KWKInIlj5KlCwAjbqW+m X-Received: by 2002:a50:cddc:0:b0:572:988f:2f38 with SMTP id 4fb4d7f45d1cf-57311e083efmr96122a12.6.1715040890499; Mon, 06 May 2024 17:14:50 -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> <202405061704.DD3AF674@keescook> In-Reply-To: <202405061704.DD3AF674@keescook> From: Fangrui Song Date: Mon, 6 May 2024 17:14:36 -0700 Message-ID: Subject: Re: [PATCH v2] selftests: exec: make binaries position independent To: Kees Cook Cc: Muhammad Usama Anjum , John Hubbard , 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 Mon, May 6, 2024 at 5:05=E2=80=AFPM Kees Cook wr= ote: > > On Mon, May 06, 2024 at 04:30:27PM -0700, Fangrui Song wrote: > > 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 indepen= dent > > > > anymore. Use -static-pie instead which would produce a static and > > > > position independent binary. This has been caught by clang's warnin= gs: > > > > > > > > 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. > > Should we use this alternative, which may be more portable? > https://lore.kernel.org/all/20240504022301.35250-1-jhubbard@nvidia.com/ > > -Kees s/-fPIE -static/-static/ then it looks good to me:) -static creates a position-dependent executable. It doesn't matter whether the compiler uses -fno-pic/-fpie/-fpic codegen, so -fPIE can be removed. --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF