Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3607982ybl; Fri, 20 Dec 2019 12:14:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzDVYybLIftGBFSX717QavJn4yGHL+4Rsnih8YKbE7TE5AuHdc+9JjxbShkHPnRIqyVHlIH X-Received: by 2002:a9d:750b:: with SMTP id r11mr11442800otk.209.1576872861392; Fri, 20 Dec 2019 12:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576872861; cv=none; d=google.com; s=arc-20160816; b=JlGX9q9QtsQTpNh8zXcjTKF22ZlnwPsb31sJUGp7V4S+gd1saZnkVlK6cNFPFdRtSh h5WjbFM/lOKIrQRjDaoVkF1UtxjuKrV3I2972nki84DIJsiceNV49frx6h5J4eJp2s6a lR9/HKwBSKmb2tCWdFfPphcXwKA0zctMmWKu5rWi+/VyckIUdUZ2mw3lzvIcjmVkgvyW A9mSuVW5jGuMQiufzTdkGA/UlsBCH/eREPSv/BLlu83otFtGJI/ljS7E+1xBlQsXArs0 2YGXtFrAFmXCcPdGM4UcakJhHOm/MM5HFG5/N1auMP4/0eNCzDB1A/LjSx8jrcyt2bwX 9YRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=980W3whSRgBeVIaqMTIFKJArmeV0Zx+uhmhhz5FKa8s=; b=bCaYhvD8Z4bCeiqwyjCjuKfGACfcm+Jbr8XMBRlxUBVhghZsZ7YpzQoozXozqhsXfU Z+jMnSnwv+ycNv9p4L+V7pVz23mfi4TGGVH3P2KvIfXz6LHiXMjggtsdVosA1XOf1g++ fonnvecH6ib4FPVoKqfOCgSiVz8UJy7Behz4xuiJTj0sVtZ5/9BMhaaEm2YuWg5dcFAv K53oVcHoCifvxh6csPmN1jj6fVUFtpBsqDSxjMJv0LqOMgW6Pozb5jkIRzOFRmlHhiKF Un0XsyhbCXyGVKuzkeQ1SCuh3II7GWjP7OyA5Edsk0pya5rgGRXjOEbpkHS2HYZ0hn/t MlaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=kIXRicsU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si5809835oti.246.2019.12.20.12.14.08; Fri, 20 Dec 2019 12:14:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=kIXRicsU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727524AbfLTUMT (ORCPT + 99 others); Fri, 20 Dec 2019 15:12:19 -0500 Received: from mail.efficios.com ([167.114.142.138]:55104 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727394AbfLTUMT (ORCPT ); Fri, 20 Dec 2019 15:12:19 -0500 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id A616A68FA9A; Fri, 20 Dec 2019 15:12:17 -0500 (EST) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id yqE96adCoYLl; Fri, 20 Dec 2019 15:12:17 -0500 (EST) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 1C18A68FA97; Fri, 20 Dec 2019 15:12:17 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 1C18A68FA97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1576872737; bh=980W3whSRgBeVIaqMTIFKJArmeV0Zx+uhmhhz5FKa8s=; h=From:To:Date:Message-Id; b=kIXRicsU3ZmQ2ebkOvSyMn7uOcWZVbX6npx4UZHYpc5L4YiLfNpivw3Eqt+tp7Efj 6GbXUD4B3HIKkr1M8kkUUpBRfE1cS73+PUUKsegA403F6whWiCD4OBk7yp963G7gXK O9dSwqCyiyxQuLKLruPrathlMnWNgag+aTHqT+BOvnwC9tm43BwcmpNzV4WzRCL/zk l8qxRd/cXn5zuJZQEN6NlJToiqFGe3w0AhiAXmYFrTc1nx9ZqyvkYqShAIjI0jrX7+ F7RFTg204Ob1H//lfNTnwxxNF5HzFMs50x7u+Kqpt2fUwyPeuO4vQIBXw4LtoBka4k DfU1pOpQYZSew== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id S8tKXA6YpzEL; Fri, 20 Dec 2019 15:12:17 -0500 (EST) Received: from localhost.localdomain (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id BFE6068FA91; Fri, 20 Dec 2019 15:12:16 -0500 (EST) From: Mathieu Desnoyers To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, stable@vger.kernel.org, Mathieu Desnoyers , Florian Weimer , Dmitry Vyukov , Neel Natu Subject: [PATCH for 5.5 1/2] rseq: Fix: Clarify rseq.h UAPI rseq_cs memory reclaim requirements Date: Fri, 20 Dec 2019 15:12:06 -0500 Message-Id: <20191220201207.17389-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rseq.h UAPI documents that the rseq_cs field must be cleared before reclaiming memory that contains the targeted struct rseq_cs. We should extend this comment to also dictate that the rseq_cs field must be cleared before reclaiming memory of the code pointed to by the rseq_cs start_ip and post_commit_offset fields. While we can expect that use of dlclose(3) will typically unmap both struct rseq_cs and its associated code at once, nothing would theoretically prevent a JIT from reclaiming the code without reclaiming the struct rseq_cs, which would erroneously allow the kernel to consider new code which is not a rseq critical section as a rseq critical section following a code reclaim. Suggested-by: Florian Weimer Signed-off-by: Mathieu Desnoyers Cc: Florian Weimer Cc: Thomas Gleixner Cc: Peter Zijlstra (Intel) Cc: "Paul E. McKenney" Cc: Boqun Feng Cc: "H . Peter Anvin" Cc: Paul Turner Cc: Dmitry Vyukov Cc: Neel Natu Cc: linux-api@vger.kernel.org --- include/uapi/linux/rseq.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index 9a402fdb60e9..6f26b0b148a6 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -100,7 +100,9 @@ struct rseq { * instruction sequence block, as well as when the kernel detects that * it is preempting or delivering a signal outside of the range * targeted by the rseq_cs. Also needs to be set to NULL by user-space - * before reclaiming memory that contains the targeted struct rseq_cs. + * before reclaiming memory that contains the targeted struct rseq_cs + * or reclaiming memory that contains the code refered to by the + * start_ip and post_commit_offset fields of struct rseq_cs. * * Read and set by the kernel. Set by user-space with single-copy * atomicity semantics. This field should only be updated by the -- 2.17.1