From patchwork Mon Nov 14 09:10:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 19625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2054833wru; Mon, 14 Nov 2022 01:41:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4qjyG0//OF0bEwsc+nYKRotcr8qhGRmSHgbIbSST1WIPF0ROIrAJ16bk01pWiQ3vMy5MYW X-Received: by 2002:a50:fe13:0:b0:461:565e:8779 with SMTP id f19-20020a50fe13000000b00461565e8779mr10653517edt.387.1668418877800; Mon, 14 Nov 2022 01:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668418877; cv=none; d=google.com; s=arc-20160816; b=GuXlQ4emyogYe20aDT63I7IDMkHG1b2rJLMYOsTrKa2nANOcxZJe/hY0heYcYTt4+o WYA3jVmWMZhAOlFFBO3u+YqQDDkeTWaHuQ+OeRWdoNwbsqz8b01EAt/321T2w/KxTTAM l/y40zFhC0PvF7ERCfTW3Kui7yOWWuKSfI7W9UCT9xMSAqfG1FAmSjbQUZTs6Os1KDsX If/8s1YD3yZXWgf2zIbuLZe0F92s007TimjD/LRu7Z+7x9guSl/RymNAIZxBDGcXR4FD DU0RH0xXFeue7XYkKyDVKpxeXNlTM3E78xqxRCVZFsMUA+6IpyxtHOtqCAWSd4rYcl2A 703Q== 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 header.s=2020e header.b=WCbXEb6I; 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: 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.40.54; Mon, 14 Nov 2022 01:41:17 -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 header.s=2020e header.b=WCbXEb6I; 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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748390365752330225?= X-GMAIL-MSGID: =?utf-8?q?1749463993129922941?= 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; /*