Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp281924pxb; Mon, 25 Apr 2022 09:55:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBTxNp75mM+O4k7mnWr1WqGGTLvgfA3ey3NZblGWieRQvkAzQl41VYSwpTV69CbY2QME8j X-Received: by 2002:a05:6402:34d2:b0:423:e6c4:3e9 with SMTP id w18-20020a05640234d200b00423e6c403e9mr20557023edc.372.1650905710107; Mon, 25 Apr 2022 09:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650905710; cv=none; d=google.com; s=arc-20160816; b=FcXkT17uiONThCUpMJQxsq35zNJntjw9/u5TQkHnEJCW6aZoVJleg8QMMLqa9tRk0N zsiAz7kUryqmSGcTHnP9IznosKx6mL3rFkJlviQTkPY9hjD7TGJEH8v5Jz9oN/Vzo6M1 sKFuVPU1JnvAsLSflt4XrLBg4MY/YMMlwOS+I4DamcLDrjrXuF61/U7Am4R7xBiFJ9f9 zhvnjP3zxyv/cR25y4z/whnqbcZShJYYNXeS5YIGSaSHGdZClap28l4Zwk9fzqqnUgol UpRD0CyHQRF1OxoK+jmFQ4yew7c8IAQVyx5+3MMKWvUHKJZpMOwOGZRmlZ+qPKFKjuZ/ sNiQ== 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=QOnKlAHRJyRZh6UTpzLqlrkzZwi4pUejGOJI+FgSH1M=; b=Mf/O01tLiQW2xCVHtVkkQX7tuvMFWbYUDggrBplG/x9VqpynZLAzzUt4ka1BTcERIo yN82Be1w41G7HXTTD8jRTmOqENDOLObOl9VIWHAox1hj2CCtyOBun7zlhB276gIn38lc /Rgj0tGtE3Wix2aNqCXc3ALJ/JiV6YxJWyCQ8hHbPaTwA6q+L0AwjRT+gxSL66stAKI2 ZbgAQb9waK98/NwNnvL6DAo4Un0MCPR61pP/1BLUOqWQdV8hGbxyogkzMYzLl4ltXGqR b4zP2JGddr/Gpbou/Vvw2ObihpwMmU9sFBILnUaO1wglETtSTw/PgO8fyNybZKcwlh6h iftQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TkM+ckAI; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 g39-20020a056402322700b0041d76ccf69asi12824275eda.621.2022.04.25.09.54.46; Mon, 25 Apr 2022 09:55:10 -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=TkM+ckAI; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 S231557AbiDYGaX (ORCPT + 99 others); Mon, 25 Apr 2022 02:30:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiDYGaW (ORCPT ); Mon, 25 Apr 2022 02:30:22 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0A875C64F for ; Sun, 24 Apr 2022 23:27:18 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 71012210F3; Mon, 25 Apr 2022 06:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1650868037; 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=QOnKlAHRJyRZh6UTpzLqlrkzZwi4pUejGOJI+FgSH1M=; b=TkM+ckAIkflSnwvJTgnOGO3a95nO9NarZAJ6TJosfV58gJ69hE+wbR1ci0u3R4dfBitSo2 Ps4ohRYff7nxZkkwh+DCyzVsyKyG6tHRZY6rpkAKFLlsoYpj9G8gdRTl19cdZ4Veb2OQ7P oq1Yn5xO3s+c0mG513ZlMHggQzwtMeo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1650868037; 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=QOnKlAHRJyRZh6UTpzLqlrkzZwi4pUejGOJI+FgSH1M=; b=hnG7m/7l7EV0wMdRJvVFE/G6qqbPbmjrE5uP2daOHr9LJmtSt834+h1G6t3dO7jtk7aQnX 3Vjwhb9vlqGKEUAw== 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 53DA72C141; Mon, 25 Apr 2022 06:27:17 +0000 (UTC) Date: Mon, 25 Apr 2022 08:27:17 +0200 (CEST) From: Miroslav Benes To: Peter Zijlstra cc: Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 15/25] objtool: Rework ibt and extricate from stack validation In-Reply-To: <20220422105037.GV2731@worktop.programming.kicks-ass.net> Message-ID: References: <20220422105037.GV2731@worktop.programming.kicks-ass.net> 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 On Fri, 22 Apr 2022, Peter Zijlstra wrote: > On Wed, Apr 20, 2022 at 07:25:16PM +0200, Miroslav Benes wrote: > > 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. > > Something like so perhaps? Seems to build and boot x86_64-defconfig. Yes, that looks good. Thanks. Miroslav