Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2389916rwb; Thu, 29 Sep 2022 09:34:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5N2V9vO39RQfWIQn0knj8AVlJTZwSRzxbs2pbPJiZRO1FcjmfH/Q8+7xs8fIcPcqCLBs0H X-Received: by 2002:a17:907:2bd5:b0:76f:591c:466b with SMTP id gv21-20020a1709072bd500b0076f591c466bmr3256528ejc.504.1664469263014; Thu, 29 Sep 2022 09:34:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664469263; cv=none; d=google.com; s=arc-20160816; b=BzDDoewVxto2cJzddIFImKZLzAFcymjCSAZZRz017f8JOt73rDUY1TAQXpkyYeUvwv 6SpjZBoWACu2K0MeqUZkyM9uoJSK0QDb8jxwtDAWfrGRpzNwk9xdfaKZo7gAGb64uQD1 bgPNYNNCGQkE7e2WhVVbekD/KaxOExhvb7f9h+kcfZ5mr3X9qjxL+KhCUdIiXBHnz39c vBgqH82fvB6GbdiD3/cTf/HvCCb6+RQ8rf23MkR15PD63aUxBd1jnT7jW70Lh+qQ9s4D 52egMCNXMA8KYDfu2cWfeXCJN+7gclBc2QXNUWeihAcJy95DKe6+lw6hmJMKzIY3DGne xRoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=KIKRiNCMl8nInzQERG/wsficIfJQBRAkF9qxlTO5SHU=; b=raQBbeG8JJZg66s25iT3c7Pbz1PNd07PzovCp213Xu0mRRWKPLjvF0ZyWbOkdnY1eW YN1+xSS2sfWJXt4btbiSngPIH5ktDKrUNuCnG7zzeZLk5aCB8F+OEwry4ilOAvD7uPmq iYj87kognU0qE4+Oz1AtwS7sdA+YDVmAdl/ffP61Qm244oXBa2Q7b3hRlRsVH4cE1YJY UhgZFaqekwGgwTqwV/cghcjflbKXbKA19AjG9SEAQzUXvQ351fdRKflXdedEaVXPb593 QFZ/g+JL2Ed1WCRG/WMWkOrN9smmnOyaD+3zR9WSK78mQe9GuIjuRLqwCP5Dm0gGc2Ny d2MQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ha22-20020a170906a89600b0076fa2b7712csi5867427ejb.221.2022.09.29.09.33.55; Thu, 29 Sep 2022 09:34:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235944AbiI2QGs (ORCPT + 99 others); Thu, 29 Sep 2022 12:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234951AbiI2QGq (ORCPT ); Thu, 29 Sep 2022 12:06:46 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3056713E21; Thu, 29 Sep 2022 09:06:45 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A205C15BF; Thu, 29 Sep 2022 09:06:51 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.81.100]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5C9E83F792; Thu, 29 Sep 2022 09:06:43 -0700 (PDT) Date: Thu, 29 Sep 2022 17:06:40 +0100 From: Mark Rutland To: Mathieu Desnoyers Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Peter Oskolkov Subject: Re: [RFC PATCH] rseq: Use pr_warn_once() when deprecated/unknown ABI flags are encountered Message-ID: References: <20220929141227.205343-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929141227.205343-1-mathieu.desnoyers@efficios.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 On Thu, Sep 29, 2022 at 10:12:27AM -0400, Mathieu Desnoyers wrote: > 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 Thanks for this! I've set off a Syzkaller run with this applied, and I'll be able to tell you in a day or two whether that's made it possible to spot anything more interesting. Regardless, I think this is a good change, so FWIW: Acked-by: Mark Rutland Mark. > --- > 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 >