Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5263028rwb; Mon, 14 Nov 2022 01:42:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6JFuFxHxAFmtn64mq8uP0GnFIAls8YFCCxfZEp/eZXNPD1tzE0xonmDTszhbrCelHbJurk X-Received: by 2002:a17:907:6d07:b0:78d:a836:1d88 with SMTP id sa7-20020a1709076d0700b0078da8361d88mr9638737ejc.470.1668418949884; Mon, 14 Nov 2022 01:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668418949; cv=none; d=google.com; s=arc-20160816; b=L34bkaimKtku6c09l8w06KK3755nV44LhkJoc8unTAex1Y/a3F/Lx4FWaR1wkQ67NB pm/jt8CC0lM4iQCrS1ogzvx1VJzFg2i6ikAHAeTmre1s4GGo1slJSD5ULzMA2ON+gFIc DWoYCDNjGZPk+i5C2zUdt4z3xXL/JT1sZLlxJVJKKr8vKJ4WmA820UXHG9GUq2f9neLU LqP9I+gSCL2ahgbZc7o9RXZgRaWV9nWy5x0ZrmG4u7uzanc0SY+LydCzsPf87EWzr8aK 0w77NWnIlbru8VIOCUOyQtbdC5y4DpibgN2bYaLvZ9Dbx+xme24Loi4X+sj60cE5XdTW zF1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=flibQ14geqBtHOZ1ZdsLp9+eqkvU+IBQCYejrpRxmlM=; b=qkEDsEahrDj30Z6NeqUQ8YzSMMRk0sjn59bQivkyaYvIrIXCBTdHAFBXS3EMqsuODr 0zU5fkY9WzQ+t9vpWBqTPUZxGLIJaiqE2j55Oag809x267CxoMaPT+E3cwTmPvzR/8sq WJ2haGrTcc8BAY+pH6beagpZqGEl5I6NDux1osdeUqY/1ItN54Eb69S/QZcCT5qUMTB9 8CojKKI2mC9i+sbNIUb2/PTg11z+/f+wqCacVCcvAddalio7E5aVghKnjlJnIdZuYAgA w5Y+tnrTXzMJj9S4gD5Dph7zm/MMqm59Y/fpxUPFPJAvRbmAEf6M5Ycac3AFwiNbdCvP 3+8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Fu+1KDPB; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf15-20020a1709077f0f00b007ade20fc40csi7524487ejc.810.2022.11.14.01.42.08; Mon, 14 Nov 2022 01:42:29 -0800 (PST) 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=@linutronix.de header.s=2020 header.b=Fu+1KDPB; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235874AbiKNJK0 (ORCPT + 88 others); Mon, 14 Nov 2022 04:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235889AbiKNJKT (ORCPT ); Mon, 14 Nov 2022 04:10:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A7BACEA; Mon, 14 Nov 2022 01:10:18 -0800 (PST) Date: Mon, 14 Nov 2022 09:10:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668417016; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=flibQ14geqBtHOZ1ZdsLp9+eqkvU+IBQCYejrpRxmlM=; b=Fu+1KDPBwhpGK4tizlig/AS7Wz+jSvcjnMilQaXRuO9iR/QfWYnLKMqVlTuBwL5WneQfn7 P47j0H3kZAXNBJyx69qzQBR34IbvfE1F4Zg3ophy1wjYJTnGfpGcV1E6q2GP8ZhdgiW0NE dKMxG99dDoeM2spqVhajubawLMQJHkO8qdYOFZetZZgvZ75Eu9HLrnqB7VV8+J01SdDVVU MU9/eB0G+kdZDwBU3jN2HLzKrBkVDXI4iLMFVvEDY+qzxbymW0X0nf6kgBnZU7cgXxu2hP 088njtygSn9D+hoXsMuDhZFg0OrnRU9iPYs/CeOjfJLLEQPZn2yejWU1KpnPQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668417016; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=flibQ14geqBtHOZ1ZdsLp9+eqkvU+IBQCYejrpRxmlM=; b=WCbXEb6IhTvLN7iLukqTlSpjzhTB6BIxIW9yy4uY77MgUwd2wPzhgnG8AsmT0sKxcG1fbF p3ZNB95x7oKw0WCQ== From: "tip-bot2 for Mathieu Desnoyers" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] rseq: Use pr_warn_once() when deprecated/unknown ABI flags are encountered Cc: Mark Rutland , Mathieu Desnoyers , "Peter Zijlstra (Intel)" , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221102130635.7379-1-mathieu.desnoyers@efficios.com> References: <20221102130635.7379-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Message-ID: <166841701553.4906.1749822907973997217.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 448dca8c88755b768552e19bd1618be34ef6d1ff Gitweb: https://git.kernel.org/tip/448dca8c88755b768552e19bd1618be34ef6d1ff Author: Mathieu Desnoyers AuthorDate: Wed, 02 Nov 2022 09:06:35 -04:00 Committer: Peter Zijlstra CommitterDate: Mon, 14 Nov 2022 09:58:32 +01:00 rseq: Use pr_warn_once() when deprecated/unknown ABI flags are encountered These commits use WARN_ON_ONCE() and kill the offending processes when deprecated and unknown flags are encountered: commit c17a6ff93213 ("rseq: Kill process when unknown flags are encountered in ABI structures") commit 0190e4198e47 ("rseq: Deprecate RSEQ_CS_FLAG_NO_RESTART_ON_* flags") The WARN_ON_ONCE() triggered by userspace input prevents use of Syzkaller to fuzz the rseq system call. Replace this WARN_ON_ONCE() by pr_warn_once() messages which contain actually useful information. Reported-by: Mark Rutland Signed-off-by: Mathieu Desnoyers Signed-off-by: Peter Zijlstra (Intel) Acked-by: Mark Rutland Acked-by: Paul E. McKenney Link: https://lkml.kernel.org/r/20221102130635.7379-1-mathieu.desnoyers@efficios.com --- kernel/rseq.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/kernel/rseq.c b/kernel/rseq.c index bda8175..d38ab94 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -171,12 +171,27 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs) return 0; } +static bool rseq_warn_flags(const char *str, u32 flags) +{ + u32 test_flags; + + if (!flags) + return false; + test_flags = flags & RSEQ_CS_NO_RESTART_FLAGS; + if (test_flags) + pr_warn_once("Deprecated flags (%u) in %s ABI structure", test_flags, str); + test_flags = flags & ~RSEQ_CS_NO_RESTART_FLAGS; + if (test_flags) + pr_warn_once("Unknown flags (%u) in %s ABI structure", test_flags, str); + return true; +} + static int rseq_need_restart(struct task_struct *t, u32 cs_flags) { u32 flags, event_mask; int ret; - if (WARN_ON_ONCE(cs_flags & RSEQ_CS_NO_RESTART_FLAGS) || cs_flags) + if (rseq_warn_flags("rseq_cs", cs_flags)) return -EINVAL; /* Get thread flags. */ @@ -184,7 +199,7 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags) if (ret) return ret; - if (WARN_ON_ONCE(flags & RSEQ_CS_NO_RESTART_FLAGS) || flags) + if (rseq_warn_flags("rseq", flags)) return -EINVAL; /*