Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp973637ybj; Thu, 7 May 2020 11:45:18 -0700 (PDT) X-Google-Smtp-Source: APiQypIR3uRPE1keHqQS7mMvxEzNICMSC59SGCjLB2kxTPkeVT6UwiZP8INd6KKw117JkioD7MUT X-Received: by 2002:a05:6402:1fb:: with SMTP id i27mr3482976edy.37.1588877117914; Thu, 07 May 2020 11:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588877117; cv=none; d=google.com; s=arc-20160816; b=BsGUECk91y39nLqJmuwsq/ySyK0YVKWBYy9Emi6KOHC2Efu2dIDnpNNAJ5xIYRxQF0 eFccz6w4YUqRdGwPokSGZ7UD+G80htwmrncjCnYWwnu4EF+39Fro29gcdmK30evNB4id Xvkidjfji+UiCQIZANXTk9ng13ZzpAfjVdVCOw8xPuPf7nGvgCTeLs1SfzN2RrHnf6Li gudEhhIdrz7sW94OyjLR3sYgET9eXE6QBUDjUAa3FEmV7TBfJbtSTOo9HzP3tWNfQISx A0lJvL1BJzhmtCDtIJ65p+QBuMGvUYPWya/25HP/jcnniueUkNkIvyt8FqONjUJ39qn1 E8gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Jh97DkO75QGZr6UViEI6oioQHzU0u8jFEO5QZXD5xsY=; b=QJgANgOaxzM3Hu/TL//pnvcCCU9dx5z4ZvFadaTn65VlzrQzBsCLsd4b1yXOpHyq8g L5Ti/7Nnpwspo6Wxrdx2zvGnFi4tWzJTcDL+glHmCdbdn47JJZOtovi/mp+5NgQLyc54 iz5nGGoWYgDRrALBy69zt5lqJgWfKaxIgt1PLBs461iPUUclRVri89AFigCsXtnzCoXP /a0HKT7XFTsgNADDMipXqtcWY+f1nO/BZvYE9PJ2fEObCc4AJNZvarwmbmlyDlSJGw3R UcBUDqiAriOMRnyaobRr1SD6+LqcJN6rD6ko6sr+sluA1lN2GA4LrrdDsSWj1qY/VLzI 0OLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MXC2AagN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si3783390ede.603.2020.05.07.11.44.54; Thu, 07 May 2020 11:45:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MXC2AagN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbgEGSnY (ORCPT + 99 others); Thu, 7 May 2020 14:43:24 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:55562 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728324AbgEGSnX (ORCPT ); Thu, 7 May 2020 14:43:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588877002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Jh97DkO75QGZr6UViEI6oioQHzU0u8jFEO5QZXD5xsY=; b=MXC2AagNZJ2Sr2nah3oaYT+KfF1GJIsEJoVRDknesLkdp0yBMohg/A9lPx7MkHs14GiXai mg+8P2Vf9CwLB8I3UTOuStQhJMgLIYy+i6wUmanJUKh53NPFUApbpquyIOPYY/qbboGSHz qNou6sRDinJQOHTZ7SHPGyrgDKuIfkI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-hOsW7xkTMlefJxkiXvcjgg-1; Thu, 07 May 2020 14:43:18 -0400 X-MC-Unique: hOsW7xkTMlefJxkiXvcjgg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7101319200C1; Thu, 7 May 2020 18:43:16 +0000 (UTC) Received: from optiplex-lnx (unknown [10.3.128.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E61AE70559; Thu, 7 May 2020 18:43:10 +0000 (UTC) Date: Thu, 7 May 2020 14:43:07 -0400 From: Rafael Aquini To: Luis Chamberlain Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, dyoung@redhat.com, bhe@redhat.com, corbet@lwn.net, keescook@chromium.org, akpm@linux-foundation.org, cai@lca.pw, rdunlap@infradead.org Subject: Re: [PATCH v2] kernel: add panic_on_taint Message-ID: <20200507184307.GF205881@optiplex-lnx> References: <20200507180631.308441-1-aquini@redhat.com> <20200507182257.GX11244@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200507182257.GX11244@42.do-not-panic.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 07, 2020 at 06:22:57PM +0000, Luis Chamberlain wrote: > On Thu, May 07, 2020 at 02:06:31PM -0400, Rafael Aquini wrote: > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > > index 8a176d8727a3..b80ab660d727 100644 > > --- a/kernel/sysctl.c > > +++ b/kernel/sysctl.c > > @@ -1217,6 +1217,13 @@ static struct ctl_table kern_table[] = { > > .extra1 = SYSCTL_ZERO, > > .extra2 = SYSCTL_ONE, > > }, > > + { > > + .procname = "panic_on_taint", > > + .data = &panic_on_taint, > > + .maxlen = sizeof(unsigned long), > > + .mode = 0644, > > + .proc_handler = proc_doulongvec_minmax, > > + }, > > You sent this out before I could reply to the other thread on v1. > My thoughts on the min / max values, or lack here: > > Valid range doesn't mean "currently allowed defined" masks. > > For example, if you expect to panic due to a taint, but a new taint type > you want was not added on an older kernel you would be under a very > *false* sense of security that your kernel may not have hit such a > taint, but the reality of the situation was that the kernel didn't > support that taint flag only added in future kernels. > > You may need to define a new flag (MAX_TAINT) which should be the last > value + 1, the allowed max values would be > > (2^MAX_TAINT)-1 > > or > > (1< > Since this is to *PANIC* I think we do want to test ranges and ensure > only valid ones are allowed. > Ok. I'm thinking in: diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 8a176d8727a3..ee492431e7b0 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1217,6 +1217,15 @@ static struct ctl_table kern_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, + { + .procname = "panic_on_taint", + .data = &panic_on_taint, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = (1 << TAINT_FLAGS_COUNT << 1) - 1, + }, Would that address your concerns wrt this one? Cheers! -- Rafael