Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4979327pxu; Thu, 10 Dec 2020 09:55:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+a/afIyUaF1HFnjeOb5NlPmMtAHGoU7QYIIk+SydTE5y9DYUAG0Bxz/4jhe3eWUflmuP2 X-Received: by 2002:a17:906:a00a:: with SMTP id p10mr7539727ejy.312.1607622931149; Thu, 10 Dec 2020 09:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607622931; cv=none; d=google.com; s=arc-20160816; b=LYj3YhCEjpt/X+pcXUHRb/o8Mpx66xwLN+2dmnS40CAUd/bktgN5SIVjO0zsXmoZJs eaGZ5CGkBrBI8EsI5soejBRRWTG2NPKBUca+0FgXiHLsx1jdHvN8/oSahxMJKl5kPaCc LWn1a1+fFfQiBfunVAHpkJKI+WnPGQK1QUh5LG1+RXlmfBKIENaODiLW/dJvvRR5hXtb 5xeMF6bQx6q9rMzFUjTd+gjBBqzBOBfEmkAzC0RXsWsYiGJ6nXRvDFLg+OSAQqyBY0ld H6qz+tGptwsLlqKG2s0AqwtC3DyBopJwZ/JW2QBIRIgXSieQuTIVbIcfxSKutzpdeZFN 8DHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject :autocrypt:from:references:cc:to:dkim-signature; bh=yr+7PimI5SX8gLaBBIeyUIA4tybpzSbAPxDoOmcjcnQ=; b=C7XUH29lSsDF0IH/iCBvCvLaNzjqX3/1kPJ2bZb6u65eLe39jzSdUhPAP01dLxA6Rw nzsl5X3sBkiE6BuOZljfAu44UioMQyqtwUhb5fhHZvkEMclS0zu1IsifxTSbjapHOF0w cdp2P0JxByBJ6lmVgMHan74r/ICPMzoF43mjW3Z5D7I4ADy8thEt/hrM/ynW913CAKgL EXhCnXBey4llncBg1flb3HPZSbL/QaMVEN4h2nH/kQPy2eO2r7ImEf/9zZ8yXfafCBFc 8g5llVWafdrVdGSILSRKGhU2T3YeaanDhh3EFTBlLNtukftBdna42CcivoCyoFdNgoW+ TRHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vrWaP2Bg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j18si3185718edj.99.2020.12.10.09.55.07; Thu, 10 Dec 2020 09:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vrWaP2Bg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392280AbgLJRwQ (ORCPT + 99 others); Thu, 10 Dec 2020 12:52:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390136AbgLJRwK (ORCPT ); Thu, 10 Dec 2020 12:52:10 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55109C0613CF for ; Thu, 10 Dec 2020 09:51:30 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id z3so4303169qtw.9 for ; Thu, 10 Dec 2020 09:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:cc:references:from:autocrypt:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=yr+7PimI5SX8gLaBBIeyUIA4tybpzSbAPxDoOmcjcnQ=; b=vrWaP2BghzgXVAXO8/4fJFu+YdAr3B+p9Y+yw0FoUavRxTv6Vgpv6B6ve24ci/I1bY KzbWww4N/yd8SBZg1ELjrsQywJXvvNBT8fq0UzGe6T+mQWJ2sKgqmvSY6vkjnutYBs+A lc26FKPJzeVoMGlpqvRxeTYq5N7i0FbV/ExJXqwutN5WherqgHNH3tm5bGlJbVd0DJ8k HLko3AlKteVVWqTHTvjn1I+oUmK8WFmnCXehpVMEeD43khvbDOJHW92FmfMP6HHiDo0I 3Zw1DQAJ7sOUs6LyU7PBOBhD383A0OQ/wRZ/LJNFq3Krjz2AaA1hXC3jzKH7u1ThBaKG CI9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=yr+7PimI5SX8gLaBBIeyUIA4tybpzSbAPxDoOmcjcnQ=; b=E35CCuVEDcsV5CUMOhGUsglLXtvoMx1dCfRTk82rZqjuFXwwxFT7Uv8+C2XVJz0GzS mWTwLEtWvgmiMiVto8YuglyMvTnm9ofLP6qducLIk0VyokHdZmgUQPxuji4JXyhVzXIV fyqSUE6QFNJZfz6XOdIvO5mTu0epCPXjHPb/qkbScFyqg7V+1X1LFrEe4z+xQ72T/cks /dKrIMN8FPMGm/iHfOjUilEDnW74qMrCJIKblkicVPP0wxSwo5lzKfT+2bhuO0CKZ4O2 xaivnjVp/Uugc9vnjfbf9wuDPOx4C2XI1Fudtan4BZjB12FkxdjNSI3uNbr6ldphepT1 jfxA== X-Gm-Message-State: AOAM5316RjC+Ok+6C9NYKQ5YPh5ynH3HNG1PYF6wWXxKBkfdSPG4vVUY csVdzFGBToTbuTSmNPLQ786D5ZkRIOIEag== X-Received: by 2002:a05:622a:14:: with SMTP id x20mr10611188qtw.58.1607622689364; Thu, 10 Dec 2020 09:51:29 -0800 (PST) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id 9sm4237323qkm.81.2020.12.10.09.51.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Dec 2020 09:51:28 -0800 (PST) To: Szabolcs Nagy , libc-alpha@sourceware.org Cc: Mark Rutland , kernel-hardening@lists.openwall.com, Catalin Marinas , linux-kernel@vger.kernel.org, Jeremy Linton , Mark Brown , Topi Miettinen , Will Deacon , linux-arm-kernel@lists.infradead.org References: <8756cc1083eb4cd93d3766cd39b2f34b6623bbcb.1606319495.git.szabolcs.nagy@arm.com> From: Adhemerval Zanella Autocrypt: addr=adhemerval.zanella@linaro.org; prefer-encrypt=mutual; keydata= mQINBFcVGkoBEADiQU2x/cBBmAVf5C2d1xgz6zCnlCefbqaflUBw4hB/bEME40QsrVzWZ5Nq 8kxkEczZzAOKkkvv4pRVLlLn/zDtFXhlcvQRJ3yFMGqzBjofucOrmdYkOGo0uCaoJKPT186L NWp53SACXguFJpnw4ODI64ziInzXQs/rUJqrFoVIlrPDmNv/LUv1OVPKz20ETjgfpg8MNwG6 iMizMefCl+RbtXbIEZ3TE/IaDT/jcOirjv96lBKrc/pAL0h/O71Kwbbp43fimW80GhjiaN2y WGByepnkAVP7FyNarhdDpJhoDmUk9yfwNuIuESaCQtfd3vgKKuo6grcKZ8bHy7IXX1XJj2X/ BgRVhVgMHAnDPFIkXtP+SiarkUaLjGzCz7XkUn4XAGDskBNfbizFqYUQCaL2FdbW3DeZqNIa nSzKAZK7Dm9+0VVSRZXP89w71Y7JUV56xL/PlOE+YKKFdEw+gQjQi0e+DZILAtFjJLoCrkEX w4LluMhYX/X8XP6/C3xW0yOZhvHYyn72sV4yJ1uyc/qz3OY32CRy+bwPzAMAkhdwcORA3JPb kPTlim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oDxWQr86T2fZGJ/HIZuVVBf3+ gaYJF92GXFynHnea14nFFuFgOni0Mi1zDxYH/8yGGBXvo14KWd8JOW0NJPaCDFJkdS5hu0VY 7vJwKcyHJGxsCLU+Et0mryX8qZwqibJIzu7kUJQdQDljbRPDFd/xmGUFCQiQAncSilYOcxNU EMVCXPAQTteqkvA+gNqSaK1NM9tY0eQ4iJpo+aoX8HAcn4sZzt2pfUB9vQMTBJ2d4+m/qO6+ cFTAceXmIoFsN8+gFN3i8Is3u12u8xGudcBPvpoy4OoG Subject: Re: [PATCH v2 1/6] aarch64: Fix missing BTI protection from dependencies [BZ #26926] Message-ID: Date: Thu, 10 Dec 2020 14:51:23 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8756cc1083eb4cd93d3766cd39b2f34b6623bbcb.1606319495.git.szabolcs.nagy@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/11/2020 10:19, Szabolcs Nagy via Libc-alpha wrote: > The _dl_open_check and _rtld_main_check hooks are not called on the > dependencies of a loaded module, so BTI protection was missed on > every module other than the main executable and directly dlopened > libraries. > > The fix just iterates over dependencies to enable BTI. > > Fixes bug 26926. LGTM, modulus the argument name change. I also think it would be better to add a testcase, for both DT_NEEDED and dlopen case. > --- > sysdeps/aarch64/dl-bti.c | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c > index 196e462520..8f4728adce 100644 > --- a/sysdeps/aarch64/dl-bti.c > +++ b/sysdeps/aarch64/dl-bti.c > @@ -51,11 +51,24 @@ enable_bti (struct link_map *map, const char *program) > return 0; > } > > -/* Enable BTI for L if required. */ > +/* Enable BTI for MAP and its dependencies. */ > > void > -_dl_bti_check (struct link_map *l, const char *program) > +_dl_bti_check (struct link_map *map, const char *program) I don't see much gain changing the argument name. > { > - if (GLRO(dl_aarch64_cpu_features).bti && l->l_mach.bti) > - enable_bti (l, program); > + if (!GLRO(dl_aarch64_cpu_features).bti) > + return; > + > + if (map->l_mach.bti) > + enable_bti (map, program); > + > + unsigned int i = map->l_searchlist.r_nlist; > + while (i-- > 0) > + { > + struct link_map *l = map->l_initfini[i]; > + if (l->l_init_called) > + continue; > + if (l->l_mach.bti) > + enable_bti (l, program); > + } > } > Ok.