Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2227092rwb; Thu, 29 Sep 2022 07:41:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vWH5IIaXtSTkCyLXHOkXi9J5wTaSA5uA99tHWY3+2YiilVXVhueFU7+BvuHGFvitU4WnB X-Received: by 2002:a17:907:724e:b0:783:5fba:4298 with SMTP id ds14-20020a170907724e00b007835fba4298mr3219697ejc.28.1664462492415; Thu, 29 Sep 2022 07:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664462492; cv=none; d=google.com; s=arc-20160816; b=cEMh4rA25ukNLDa6vViPkhWWw7+WXUFr3pJxa42nGvBUDBX3lIyK2I2YF1iMwKjrUN yHxKXD+FjI2SW72WYDmrWBVOWeLsnuqT5hfX2p/xmagye8KYJNt7zEvg7TI/KtGPKk1B rHkW/nv98zSbFSCcHEgVySmyyW1tsfweQogT3XG+ZO+7JDQ+uiVwabJLBttTR2o6OXMs ZuU9Oqfalj86tonh3GvsZGamaJt+IE9pOzvLIBRKVfsZVyOwgJOVfRVPZDMBz1rMcftn Cg+Wa9neRtTkOiuNOdUbE0LX7NfLFb6U+UNV4yelajQF4Ui+XlXN31S2BlT34Fd5S42y Vo8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QL0fXUD76O2+GdkRC5/dYnZh2p/jEtpvxDrH4CSYgBc=; b=a8Ai64Y70F5MKpdwO9bnA0V5WG8ACx/97gZgyBxa91O8z4XblW40xSQniOjLnqewP+ 9qsnF2SN1KcI4aFfxPv2oaHA8j7rmhF9XGpfD+9UZKMwOVxmxSwvvNI/tiC0tVWhtl7v gJi5Pq8BVTw9HW5DFaXReXYmtt5S4dCFZbKGNV0FstguPei+gYDodjMgmoNjBXj1AC0r OGc/Nw/tWz+7b+FBYcdW5ejuiUM+jkdxCQ6ewQkwmT+qrYX7fDAcKfvoBavKCuV0fng4 gNzl1sj1mIe9E5Y6anu7OstBUNrs/LjGe0pZGeiGuVZ9C75kzuyAlgjhlIZ5S7eKXkqU l/Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=QBykbJua; 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=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p19-20020a170906b21300b0077f92be81adsi7650153ejz.212.2022.09.29.07.41.04; Thu, 29 Sep 2022 07:41:32 -0700 (PDT) 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=@efficios.com header.s=smtpout1 header.b=QBykbJua; 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=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235585AbiI2OMB (ORCPT + 99 others); Thu, 29 Sep 2022 10:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235451AbiI2OL5 (ORCPT ); Thu, 29 Sep 2022 10:11:57 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:5aae::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F6916F9CB; Thu, 29 Sep 2022 07:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1664460712; bh=+v2ZYO1lkgc/LYM8PWe013yC+/t8ZcJu73Y8uuch+Ao=; h=From:To:Cc:Subject:Date:From; b=QBykbJuapgDBnBDizKGTSHZjYL5TjwaoAhgwwiuhieMfnEfedrciQn2X7WO3v+Egp xssoA17yPqRiMCK0tyAnNCrDhQqwW+SKMWfKgQjj/r1gqDzV8gCLoKnS8NCHQOZsou uTCWaUILZRIfxZ2qleJE6YtT/qHhlUIRpKqKbgm57EgGKPGYKdhBmt4Q/xbMWcc1GK TQCud6i5seza0IR9I4CUcX9//evSf5QDGxNJEJn7TkTW36toNm4ThroicySF3+v4rA dmLudWCZcqwRRz7PeoqX9lPn5TqNtBrycAsn2ED3cfFh7nsBRZZrQ9ePeux17bUowr vVaWhg2tuqHNg== Received: from thinkos.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4MdZzq5tDSzP99; Thu, 29 Sep 2022 10:11:51 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Peter Oskolkov , Mathieu Desnoyers , Mark Rutland Subject: [RFC PATCH] rseq: Use pr_warn_once() when deprecated/unknown ABI flags are encountered Date: Thu, 29 Sep 2022 10:12:27 -0400 Message-Id: <20220929141227.205343-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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 --- kernel/rseq.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/kernel/rseq.c b/kernel/rseq.c index bda8175f8f99..d38ab944105d 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; /* -- 2.30.2