Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1558756pxb; Tue, 8 Feb 2022 22:15:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJygtouiAcZmAZan2+IbQ6PdHiQMfI6ehafUAv80j5mj4/cHmxWZxjuw8vaW2WrfpOGacjml X-Received: by 2002:a17:902:bf0a:: with SMTP id bi10mr687295plb.164.1644387330558; Tue, 08 Feb 2022 22:15:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644387330; cv=none; d=google.com; s=arc-20160816; b=Y0inQvaQADbIVSxhsWJ//+vjerLUd5MXZX2sAHYS6WqMk7lt3Qe1GS5NMogGWxMuk5 ps03nPe1vYDgb1JCbmyRULsQqOAndzuNnqU0DkdmZm5E9jOmbJWG37qN1NaA8H7Wq1Re nMdC50ih8Vvg7AvozCdlA2g1nH72H8wWey6RbuBX7MskWfhBBImJa47rt1QZsJQPh2xM gt4eO8iMHPNK0fXz5dZvm3FkXDyFX3/iV/dgHz9ibkky79NylW/v8oINvcyEdMoU1hh0 ChkNw8Aui7HQlQKQ8Y3Ri98F/vpEHrmpILlodelxkSjFjt/OeKWz5XU6sndAnETu2BHy AfOg== 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=8FPluJVF9aWtwUGTKCjS+70K6/fX0iOecJ5yZR2L3ZM=; b=Y8M1bGJh9spnl2RnXGHEVX5Y71GvvkigPwvPiMu80uL6nlzN35OL29WumRR1L5Fzh8 sduqNKtYBNY0fp1OOvRWyPPMpQ6t86F+kLBXogG1gM9SIAheYqQsCRinayzMa7D6VDf/ R8WaTSgHKBnXEp+mgfvnEM8u4VMJAhU//U87+kWjq1gBZXDjyf79JA4ZAbM2X0AaH0nL RuVOQpMxYALfQviziGukPdJqax4EGcMieVOhE6ZAogQgvXbdJLo4sARguABOI2QPXW3y 5C/5Yvfrihf3SL4hMntXrYFxlpk6QAbHa+5Wov0NpSLKSuC5+/hDuy1iP24M0JvWGSWB 2JXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cc19Hm7r; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 84si15711534pga.173.2022.02.08.22.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:15:30 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cc19Hm7r; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F675E03496D; Tue, 8 Feb 2022 21:57:52 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238005AbiBHXnd (ORCPT + 99 others); Tue, 8 Feb 2022 18:43:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237941AbiBHXn2 (ORCPT ); Tue, 8 Feb 2022 18:43:28 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B0EFC061577 for ; Tue, 8 Feb 2022 15:43:28 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id u12so674306plq.10 for ; Tue, 08 Feb 2022 15:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8FPluJVF9aWtwUGTKCjS+70K6/fX0iOecJ5yZR2L3ZM=; b=cc19Hm7rBDBS0UO1Frz4kzMSOLES8Rk8QqiBpJ5+csh29OGXjc6joQpcObRXlE/MV+ CtRuLnmC8Sld1pUaM/J/Rjs31SEGT/iIaJb441EXQqPJK+opOx8QhC8SR+RVj9YYuBTh kxCLTi6jUC1hYj2+qOhFxY/7upb8MbndFk1yc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8FPluJVF9aWtwUGTKCjS+70K6/fX0iOecJ5yZR2L3ZM=; b=M9pGQRgYtHxW2Ihm5xOjEI8z0sbdKyEFRx7z0VSySTKJisyOfr3fDt0ujy9XvmLM2r 9ixGg9XMimQWOP4tebnSNaYxxNNyTmyXCv1+Gq3yOdR1TPSPRjA0RBbTohaGffN/I6Mw 00AdFH42oFtx1kVJfoRgEPEe7xpfhGzM27LvMfv992Fk45q13BSMBM2Ri00obkkwExXY ZXsUpiMMhuKfX2Hk5pIq+nc/T7JDn9X3B5utcV5rwHvxvrya+9Z8IhR26PcKet9g0Ut8 hh4dlMOCytO6sswDGLQJb4MTBvOOuwvlL0r2n/Kpbskhdo8HjzOnINy3+4gJIutvZCdb MABw== X-Gm-Message-State: AOAM530OCVGjBSqTM03DF5OLeUMaOW37CRBNBHsUj032wNvL+T+vqcVu N6RjAADXiWt2zOrw7qQRCzPqpw== X-Received: by 2002:a17:90a:e7c6:: with SMTP id kb6mr392818pjb.139.1644363807995; Tue, 08 Feb 2022 15:43:27 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t15sm12481061pgc.49.2022.02.08.15.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 15:43:27 -0800 (PST) Date: Tue, 8 Feb 2022 15:43:27 -0800 From: Kees Cook To: Josh Poimboeuf Cc: Peter Zijlstra , x86@kernel.org, joao@overdrivepizza.com, hjl.tools@gmail.com, andrew.cooper3@citrix.com, linux-kernel@vger.kernel.org, ndesaulniers@google.com, samitolvanen@google.com Subject: Re: [RFC][PATCH 6/6] objtool: Add IBT validation / fixups Message-ID: <202202081542.F685EC23@keescook> References: <20211122170301.764232470@infradead.org> <20211122170805.338489412@infradead.org> <20211124193037.nu7q4pa3sianzqtc@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211124193037.nu7q4pa3sianzqtc@treble> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Wed, Nov 24, 2021 at 11:30:37AM -0800, Josh Poimboeuf wrote: > On Mon, Nov 22, 2021 at 06:03:07PM +0100, Peter Zijlstra wrote: > > +static int validate_ibt_reloc(struct objtool_file *file, struct reloc *reloc, char **name) > > +{ > > + struct instruction *dest; > > + struct section *sec; > > + unsigned long off; > > + > > + sec = reloc->sym->sec; > > + off = reloc->sym->offset + reloc->addend; > > + > > + dest = find_insn(file, sec, off); > > + if (!dest) > > + return 0; > > + > > + if (name && dest->func) > > + *name = dest->func->name; > > I think these checks can be further narrowed down by only looking for > X86_64_64 relocs. > > > + list_for_each_entry(insn, &file->endbr_list, call_node) { > > + if (ibt_seal) { > > + elf_write_insn(file->elf, insn->sec, > > + insn->offset, insn->len, > > + arch_nop_insn(insn->len)); > > + } > > Like the retpoline rewriting, I'd much rather have objtool create > annotations which the kernel can then read and patch itself. > > e.g. have '.ibt.direct_call_sites' and '.ibt.unused_endbr_insns' > sections. Why have the kernel do that work at every boot when it can be known at link time? -- Kees Cook