From patchwork Thu Feb 25 07:29:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 12103557 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 92AF2C433E0 for ; Thu, 25 Feb 2021 07:33:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1983564F0A for ; Thu, 25 Feb 2021 07:33:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1983564F0A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 63B636B0072; Thu, 25 Feb 2021 02:33:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 558C46B0073; Thu, 25 Feb 2021 02:33:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 439DE6B0074; Thu, 25 Feb 2021 02:33:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id 2EEC46B0072 for ; Thu, 25 Feb 2021 02:33:51 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E26EF10F78 for ; Thu, 25 Feb 2021 07:33:50 +0000 (UTC) X-FDA: 77855975820.14.7918B35 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf06.hostedemail.com (Postfix) with ESMTP id 21068C0001FA for ; Thu, 25 Feb 2021 07:33:51 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id j24so3054242pfi.2 for ; Wed, 24 Feb 2021 23:33:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zgKO3MnWtgg50f4xin0lRAlnzGDn6IFUU+LS1IwPjiI=; b=W/Hk+wWyxzLK85Yspxk1j9kKCNb2H/TE8Nr3Gsd4yYPhFoQqeFYulVz1ESEv9Xuyuy RhNtM6Hwq7cRgFjCtqGqXH7Iue9w/00NIlLkAeKmW5eCHN17S92vu71m/qLWNUua1ZWj FNsUtTlmdX+nONjru1+lUpNNeuvBTw+cJrb0fzST/1ux/1h1Zf/pA+ka4vtqCmriGpAl 3cXsbLbzA+B0VKEYW2J9LQqIkd5v16cHVUPeZzrBkRZcLlpA8kDNqk7A6dSmOS1oZ84L ngFdFH4gKzdcvg4IPh7w74oNyMY8vDSCc91N2A5IfH2YVvLJDAPd30cPIBoXLCu23wxW nSKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zgKO3MnWtgg50f4xin0lRAlnzGDn6IFUU+LS1IwPjiI=; b=boHoFXh8ZjLYiGEkKQPHnxQG+w+5OTn/2J6C/NBnn7cAMUIfHqEugrDFElXmRdCO0w Fhu0FpwE76yBs5wK21gCagldxFDD112CB222Mrza0pIpCAoUuS8z7/1eiwCU1Z9Bxcpi Y8RX5u2Z1SwTjE24EBzqEW5macYhKxv3jB3XmB1JXZVCuKaBRWKYvfjFFbuCgb2ni2c6 mRPfdJmhCGQ7cveOQp+yjlYuszPFwnXMOnTQY+vkH8w4HzBjQeaEB0n3pKDwYuVIcYgj HU/m+ajvxIWEGX48YkUb0iopm2vCx+JUGzJdDdPx+pPR7nezhWQDBSx+O61XSTlPJsQO vZ6A== X-Gm-Message-State: AOAM533itkdBaiPba3JP+FI4AqeyJsIsmZJ3MnLEmJbLOmJW+zaxnYB4 SnrjWyMZ8ZzBYrE7liXv0rs1ANaE9Yp+oA== X-Google-Smtp-Source: ABdhPJxSLsgCDlJ2iNA9exMeg5JU1gPQkYTFM9O+DtIiU0GZ0RewqOlVs2JHJeIXT5peHT7BfkCfag== X-Received: by 2002:a05:6a00:1a4b:b029:1d2:8522:75e7 with SMTP id h11-20020a056a001a4bb02901d2852275e7mr2037326pfv.80.1614238429290; Wed, 24 Feb 2021 23:33:49 -0800 (PST) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id w3sm4917561pjt.24.2021.02.24.23.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 23:33:48 -0800 (PST) From: Nadav Amit X-Google-Original-From: Nadav Amit To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hugh Dickins , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Borislav Petkov , Nadav Amit , Sean Christopherson , Andrew Morton , x86@kernel.org Subject: [RFC 1/6] vdso/extable: fix calculation of base Date: Wed, 24 Feb 2021 23:29:05 -0800 Message-Id: <20210225072910.2811795-2-namit@vmware.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210225072910.2811795-1-namit@vmware.com> References: <20210225072910.2811795-1-namit@vmware.com> MIME-Version: 1.0 X-Stat-Signature: 5kf13rq5rskhnxym7mbbpcbmqjs9idzb X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 21068C0001FA Received-SPF: none (<>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from="<>"; helo=mail-pf1-f176.google.com; client-ip=209.85.210.176 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614238431-171584 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: 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)) { if (regs->ip == base + extable[i].insn) { regs->ip = base + extable[i].fixup; regs->di = trapnr;