Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp398494pxb; Thu, 21 Apr 2022 02:00:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIvV01P8mCXzYRFGhVqqmU1y+d0DKDv1KgI5JXAwktJdpw1Pnw5j5r3tbZWfIrfRzv3Beb X-Received: by 2002:a17:90b:4b42:b0:1d2:f9a9:e20b with SMTP id mi2-20020a17090b4b4200b001d2f9a9e20bmr9196436pjb.173.1650531633013; Thu, 21 Apr 2022 02:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650531633; cv=none; d=google.com; s=arc-20160816; b=sl3Swo1QB0yrIH6tvIqPCRE3emNPjApwONwKk+n5rojAa4kk82+gmI2h/Tjbfjzqnp rt68nJb7kSqiV5sTqKajbhQ7M3vHm87TbM/IF7UgsI2LvoS9unqIW6K85ToWYlOegAXp uZXR2l4XJIBeo7xzjVCoXIDuLPYdE6K14jzf3sO+/6Opa2FJ5QD9BOHhLXZ19lyHL4jR vmUTjld6/sutIr32KWe0K6YCWjFccuXyMAlc4bgnTqSC+ZjV1z4l9HJbRqMBcRDsBjy5 L+q4EXfNNaQUcozuQsO8NFkEipr2gZWLoVEmAhl2tvtR8sTYJSQ185AZsPOh/6o4bjMX 9Ekw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=beOjjz8wjPVhCvHg8uOnVQKum2lXeuiW4masHsPOdQQ=; b=eLfOWsn4a9Ho8Ch/62TMWxBuRGkxgE75fLxAPs9UPMNKnP6bQRGxLDooM62+nSEOtS gxcCM67MFUmxUOJxUBEaA/+hmh7d/Ly9mVG+Q+R6i7mBrvf4NXJ6P9qcd6IbQL5liRKX ZntfwUq/FeOxDoWYiWGMkeZ1gyxzZ3mwan54R6taku9HHeAFMzbkFXqSNwy/X+wTRgKQ kLJ/iWoaUSfhy163Rg646A9Leivs4u4cLGshbnJVXiCjd63TKJjcxyI5ExAyXbrYLXZF 09zUdm6c/3DdjO3nBkb+lGLVdJ3Imz90camHUzN+5uGOMD+6kA5cqD9MmSf6U1t29a5j uUsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=bGx1CePC; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aFwBWj2u; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a634d4e000000b0039da71704a0si4519534pgl.877.2022.04.21.02.00.18; Thu, 21 Apr 2022 02:00:33 -0700 (PDT) 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=@suse.cz header.s=susede2_rsa header.b=bGx1CePC; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=aFwBWj2u; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381055AbiDTR2I (ORCPT + 99 others); Wed, 20 Apr 2022 13:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243846AbiDTR2E (ORCPT ); Wed, 20 Apr 2022 13:28:04 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D4CAE0EB for ; Wed, 20 Apr 2022 10:25:18 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3430021115; Wed, 20 Apr 2022 17:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1650475517; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=beOjjz8wjPVhCvHg8uOnVQKum2lXeuiW4masHsPOdQQ=; b=bGx1CePCrWIifOZZocpsdLrRHb3bgZQRw2KTWM0IxQsNVFcswYWm9Nl50qP6Y05eVFzfD5 flUscuZHsRgFKEGkpjCu3qdhQPkzQZkGEyiOmu7JpkmwheL5ba8VYSpuEEAqFAmFxLaxhx mNAo0jTWrBdIUx+5Wy+4Pe+dQM1Gu3Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1650475517; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=beOjjz8wjPVhCvHg8uOnVQKum2lXeuiW4masHsPOdQQ=; b=aFwBWj2uAWyjKcRIkbMSkBNkU0gAhBlMgpYJSL2wiqvVxkkTtlIc9+q4CnbbNyaAJPF2GH kT0LqluDjAW5jWBA== Received: from pobox.suse.cz (pobox.suse.cz [10.100.2.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 19D502C142; Wed, 20 Apr 2022 17:25:17 +0000 (UTC) Date: Wed, 20 Apr 2022 19:25:16 +0200 (CEST) From: Miroslav Benes To: Josh Poimboeuf cc: x86@kernel.org, Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 15/25] objtool: Rework ibt and extricate from stack validation In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 A nit and it was there even before this patch... > -static struct instruction * > -validate_ibt_reloc(struct objtool_file *file, struct reloc *reloc) > -{ > - struct instruction *dest; > - struct section *sec; > - unsigned long off; > - > - sec = reloc->sym->sec; > - off = reloc->sym->offset; > - > - if ((reloc->sec->base->sh.sh_flags & SHF_EXECINSTR) && > - (reloc->type == R_X86_64_PC32 || reloc->type == R_X86_64_PLT32)) > - off += arch_dest_reloc_offset(reloc->addend); here... > +static int validate_ibt_insn(struct objtool_file *file, struct instruction *insn) > +{ ... > + off = reloc->sym->offset; > + if (reloc->type == R_X86_64_PC32 || reloc->type == R_X86_64_PLT32) > + off += arch_dest_reloc_offset(reloc->addend); > + else > + off += reloc->addend; it looks kind of strange to have arch_dest_reloc_offset() and still reference arch-specific relocation types here. On the other hand it seems difficult to achieve complete arch-agnostic code, so take it just as a note and maybe someone porting objtool to a different architecture will split the code, make it all arch-independent and all will be nice and shiny. Miroslav