Received: by 10.213.65.68 with SMTP id h4csp292635imn; Mon, 12 Mar 2018 14:04:15 -0700 (PDT) X-Google-Smtp-Source: AG47ELsE+UJtmtksy8aa5JrCG3s/ZdtLZte/50ZGx0b47/d0xB8hItpXXtTGkkcxWUdJztrWe2mv X-Received: by 10.98.74.140 with SMTP id c12mr9435546pfj.44.1520888655151; Mon, 12 Mar 2018 14:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520888655; cv=none; d=google.com; s=arc-20160816; b=Rbp3DtqaQdNXzOyoETmIgfnEPLfF115Nl1XVSVKIuwwTZcaabDAk9FNcLdYz9CXMMy c5s4jC7uf1mqtWx8ySSt5lV+9v+Llz5k+bVMF+8r29SGp5uqaktEIkj0hKM1oqp5+pXl dbbD+B5ecvY4/8o8SKWFaHrFb0PHybJt03L0Sp2aoQvr8dGLKKtqAYkb7ome9wQRASyL dZKhSSiVkDwNf6bWYZiVS6AvhLPdyITQOTiOGAXPAwKHhlZ9dGJLCprEVK91En3W1kXo JWKgoHnxK/9Mv3Of6MU60lyLrplIf3TO7hs+gVcXFqqttoTruzuGdRD98Xwt09dHYhMr PNwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=T10Ohm9CYaNJENTtvndbOEXt+HRnU4N+NTM56uAsEzo=; b=WFjDTpAGU+RFR1cCRgPd/vQphnSaRor8TAz7aDkCk48nbc+99lx7Fw8hO0z8jyS65G sdX8yGnXjDpLU7PxH4siUEYO45zRfYRw/ecTJxGyEozGXzsbidYBczAtNWivEGmgQA9G X+HHcPMAXj1Lo+zbiFRUjaWXIxFqia7qKjbHaYesYdyw4uzx1utWI3O0RrO/nqs9snAB 1tgKm+/GXYr+UUoEujLDGFR+u0WCcL+fGscUhyTOBnHmTZ61s7vmg9sU/tB81/UFNA7x cus1l5jUg/UHqBUAYJ7j2Lz5GXM9oP6ifHnbfiqk4SDqmjNxZM7lxSDZp4Z7ez/79t1R gwWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h125si6375612pfc.133.2018.03.12.14.03.58; Mon, 12 Mar 2018 14:04:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932486AbeCLVC5 (ORCPT + 99 others); Mon, 12 Mar 2018 17:02:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49258 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932408AbeCLVC4 (ORCPT ); Mon, 12 Mar 2018 17:02:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A31328011454; Mon, 12 Mar 2018 21:02:55 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-75.bos.redhat.com [10.18.17.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73DA32026E03; Mon, 12 Mar 2018 21:02:55 +0000 (UTC) Subject: Re: [PATCH v4 2/6] proc/sysctl: Check for invalid flags bits To: "Luis R. Rodriguez" Cc: Kees Cook , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Al Viro , Matthew Wilcox References: <1520885744-1546-1-git-send-email-longman@redhat.com> <1520885744-1546-3-git-send-email-longman@redhat.com> <20180312204614.GZ4449@wotan.suse.de> <2621ea58-174f-bfe9-8c34-12501bb775fa@redhat.com> <20180312205920.GD4449@wotan.suse.de> From: Waiman Long Organization: Red Hat Message-ID: Date: Mon, 12 Mar 2018 17:02:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20180312205920.GD4449@wotan.suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Mar 2018 21:02:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Mar 2018 21:02:55 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'longman@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/12/2018 04:59 PM, Luis R. Rodriguez wrote: > On Mon, Mar 12, 2018 at 04:54:51PM -0400, Waiman Long wrote: >> On 03/12/2018 04:46 PM, Luis R. Rodriguez wrote: >>> On Mon, Mar 12, 2018 at 04:15:40PM -0400, Waiman Long wrote: >>>> Checking code is added to check for invalid flags in the ctl_table >>>> and return error if an unknown flag is used. >>> This should be merged with the first patch otherwise there are atomic >>> points in time on the commit log history where invalid values are allowed >>> and that makes no sense. >>> >>> This can probably be expanded to verify semantics further. Details >>> below. >>>> Signed-off-by: Waiman Long >>>> --- >>>> fs/proc/proc_sysctl.c | 12 ++++++++++++ >>>> 1 file changed, 12 insertions(+) >>>> >>>> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c >>>> index 493c975..67c0c82 100644 >>>> --- a/fs/proc/proc_sysctl.c >>>> +++ b/fs/proc/proc_sysctl.c >>>> @@ -1092,6 +1092,16 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table) >>>> return err; >>>> } >>>> >>>> +static int sysctl_check_flags(const char *path, struct ctl_table *table) >>>> +{ >>>> + int err = 0; >>>> + >>>> + if (table->flags & ~CTL_TABLE_FLAGS_ALL) >>>> + err = sysctl_err(path, table, "invalid flags"); >>> What if a range for the upper limit is set but not the lower limit and >>> the user goes over the lower limit? >>> >>> How about the inverse? >>> >>> Do we need both ranges set? >>> >>> Luis >> This check is just to make sure that no invalid flag bit is set. Range >> clamping is just one of flag bits, though this is the only one currently >> supported. In fact, it is allowed that the minimum or maximum can be >> left unspecified. In this case, no minimum or maximum checking will be >> done. So I don't see anything related to range checking should be put here. > What if minimum is greater than maximum? > > Luis Yes, you are right. That is a valid check. I am going to add that in the next patch. Cheers, Longman