From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C325C433E0 for ; Thu, 25 Feb 2021 21:16:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A08F64EBA for ; Thu, 25 Feb 2021 21:16:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A08F64EBA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 05A206B0005; Thu, 25 Feb 2021 16:16:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00B146B0006; Thu, 25 Feb 2021 16:16:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3CBB6B006C; Thu, 25 Feb 2021 16:16:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id CE2686B0005 for ; Thu, 25 Feb 2021 16:16:39 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 900F618411DD2 for ; Thu, 25 Feb 2021 21:16:39 +0000 (UTC) X-FDA: 77858049318.11.5C930B7 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf01.hostedemail.com (Postfix) with ESMTP id 7453E200038E for ; Thu, 25 Feb 2021 21:16:38 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id d2so4335190pjs.4 for ; Thu, 25 Feb 2021 13:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=L+15buzFSO+wmGF8wIGRELylp1Ige8/Z4b20PdJ1kvs=; b=XkCtrdURkT7J2cFFwlt1wxUTETBNr4vHEthI99Kg8cHTvz+Y5s7A2S/l+YzmOE6mlE /CMw3kpQlv4LtVsFOLUnuiPsVWCujSRUo5UZGHYszaGKyuvk8ZWh+y7MY5/rtIOj825Z 8VIqp2rH/xDDyVxTV7UESCQfmgU0uc9w/+qrvzGDhVXIz+Ykj8ZHQ6p/22qe2a5n49sX u4nxTVyUIwPjSWkxWN5evIu9+RsFoZYvTX5D452kfXm1qNbHfGhS42xvkvPxsFEDUubw DOMcsVx0Yy3GyfrqAWk4/ntKrRR2FlQzRcUfAJI496SVT803nENuSxzl0YGhJGizdWfz uWTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=L+15buzFSO+wmGF8wIGRELylp1Ige8/Z4b20PdJ1kvs=; b=J0wq8mvXkhHv0Sn/q6/7aHVDekl5lCs479QSrS7eH/bAF8P6jFPcptVkE1sOk49czk QLepbm4z9d64uHPYegJBc0oYn66Jb4MvDSTARKXrovQ69JHB/oHfJ17OwCKJPWJwQy56 Fr8LVxjs4pZ3+r3CzO2Fi275EGGU5zpWHG8sEhq2YCABLxQQN7mowX5pNpEDmXYbrHnJ N2vIBREBzoDyrkJsCgV3uCsfGqhH7li2yPT13RmUpQ//amZ5VMf8ZR6Jmg5K89iRRJAV BhdOJD1TrxNqafOYFc9KslNV5qxeg7dLB/LCOcSM00NaQwGgIH8puZsRXTXsbVH63Vfr I+lA== X-Gm-Message-State: AOAM531b/Uvkej95rr3mpoHrmznPY/imAJzXR8zBfDdRVHBeKsFESp8E N3HBLYdwevH+5G2RYLNXM3+VFQ== X-Google-Smtp-Source: ABdhPJy9GrNM8xIUtij9FqzPAlyjFhjJVErTEtF3Rr5zRg8baB7A45kasmYHyhC7TIEcZJhXTiHfXA== X-Received: by 2002:a17:90a:694c:: with SMTP id j12mr317875pjm.176.1614287797549; Thu, 25 Feb 2021 13:16:37 -0800 (PST) Received: from google.com ([2620:15c:f:10:34c4:7c1d:f9ba:4576]) by smtp.gmail.com with ESMTPSA id c6sm7488114pfc.94.2021.02.25.13.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 13:16:36 -0800 (PST) Date: Thu, 25 Feb 2021 13:16:30 -0800 From: Sean Christopherson To: Nadav Amit Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Borislav Petkov , Nadav Amit , Andrew Morton , x86@kernel.org Subject: Re: [RFC 1/6] vdso/extable: fix calculation of base Message-ID: References: <20210225072910.2811795-1-namit@vmware.com> <20210225072910.2811795-2-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210225072910.2811795-2-namit@vmware.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7453E200038E X-Stat-Signature: pjuy5pqgqzew8rgri9zk1y3ux4tjcwz7 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-pj1-f43.google.com; client-ip=209.85.216.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614287798-506030 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 24, 2021, Nadav Amit wrote: > From: Nadav Amit > > Apparently, the assembly considers __ex_table as the location when the > pushsection directive was issued. Therefore when there is more than a > single entry in the vDSO exception table, the calculations of the base > and fixup are wrong. > > Fix the calculations of the expected fault IP and new IP by adjusting > the base after each entry. > > Cc: Andy Lutomirski > Cc: Peter Zijlstra > Cc: Sean Christopherson > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Andrew Morton > Cc: x86@kernel.org > Signed-off-by: Nadav Amit > --- > arch/x86/entry/vdso/extable.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/entry/vdso/extable.c b/arch/x86/entry/vdso/extable.c > index afcf5b65beef..c81e78636220 100644 > --- a/arch/x86/entry/vdso/extable.c > +++ b/arch/x86/entry/vdso/extable.c > @@ -32,7 +32,7 @@ bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, > nr_entries = image->extable_len / (sizeof(*extable)); > extable = image->extable; > > - for (i = 0; i < nr_entries; i++) { > + for (i = 0; i < nr_entries; i++, base += sizeof(*extable)) { It's been literally years since I wrote this code, but I distinctly remember the addresses being relative to the base. I also remember testing multiple entries, but again, that was a long time ago. Assuming things have changed, or I was flat out wrong, the comment above the macro magic should also be updated. /* * Inject exception fixup for vDSO code. Unlike normal exception fixup, * vDSO uses a dedicated handler the addresses are relative to the overall * exception table, not each individual entry. */ > if (regs->ip == base + extable[i].insn) { > regs->ip = base + extable[i].fixup; > regs->di = trapnr; > -- > 2.25.1 >