Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1394470rwi; Thu, 3 Nov 2022 04:58:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GMwmgLffpwMDZ+oEj1gDCJ6TDzm+0yIFj5KA8/CObJGrTDQb/nq25FxQUxuurro/ugcjr X-Received: by 2002:a17:90a:4212:b0:215:eee3:bb10 with SMTP id o18-20020a17090a421200b00215eee3bb10mr3096246pjg.130.1667476713396; Thu, 03 Nov 2022 04:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667476713; cv=none; d=google.com; s=arc-20160816; b=kfvvk1kTPcFt+bQ+rrS7uVRJLusmpuuWL0yfB0wfOBW88s77OgU0x2PDXpmFy73snU QRguhigkRjzFNzEjskzSPfFgYPjhjzMch8y+6KhUb7u7Mx1Qhy2T3NsAmEWYPnxR+jq1 WVfIt8Mx1aOCNVWSCMU0qxXtV5Q/6q+9OVUbyuWLBApWbB2C8MZrOFSTAfldBBVp0F0u w9UO80TtY+7k0JIbGdZDr2GGH0PIc+liVlKKLfxbA5pqZERaUxE76VWK80iMYgdewvWB uJLjIVz1wk01i44q15ZymXz+toR77XwW4T8zBCH7/3YWn6+nYE/AHFLyCQjsMQLCEDf9 5tSw== 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=0WVTMAT3+3au2VP5YYPUZuE6kXewtezhL0bjSasmxU4=; b=Qz0Ra3j5Zpx8+7e/+lSniQP8nrromkCI2wkBpQ/fq4C6lrC9AnHIb9YKcFg2tDPTkU v3HZQQCcZ0md0jL/+dcqg6qqOhWxi8ytxDHs7j78Z4MjmPdhcsp+1FZiIhD45+7M7cby U22dhJQKM6+wZPpIOZIKsHaTGa0YOzktuTUXPfO61OHynjblAJwRowZEfQi+NfaU0xJe NVSp4P/DnOotdIWyk5DkLpxaw0FETmaS1D7AcDfZCZ5az2X3Q6zrInm/DF59+W9t9XjE WqIWuzEGWzNtYsjoXoECCKllKdkY7haFC3NENM8I901SIBngDYoEmqi1jUHghn0C8Wsn rUYQ== 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 b4-20020a170903228400b0016f1eb1317esi570400plh.471.2022.11.03.04.58.19; Thu, 03 Nov 2022 04:58:33 -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 S230465AbiKCLcH (ORCPT + 97 others); Thu, 3 Nov 2022 07:32:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbiKCLcF (ORCPT ); Thu, 3 Nov 2022 07:32:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BAEF511838; Thu, 3 Nov 2022 04:32:04 -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 D034823A; Thu, 3 Nov 2022 04:32:10 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.69.97]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7ECE3F5A1; Thu, 3 Nov 2022 04:32:02 -0700 (PDT) Date: Thu, 3 Nov 2022 11:31:55 +0000 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: [PATCH] rseq: Use pr_warn_once() when deprecated/unknown ABI flags are encountered Message-ID: References: <20221102130635.7379-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102130635.7379-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 Wed, Nov 02, 2022 at 09:06:35AM -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 > Acked-by: Mark Rutland > Acked-by: Paul E. McKenney It would be nice ot have this merged; my Syzkaller runs are still hitting the WARN_ON_ONCE() periodically, preventing some useful fuzzing. Is the plan still for this to go via -tip? Thanks, 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 >