Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp151410ybi; Tue, 2 Jul 2019 18:04:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRvPEexQ9PTKQqXg2mjMKnnWSsaMGVh91yc0y5H2slneECEgyYeKtiKzLAdK14ovshHIIQ X-Received: by 2002:a17:902:7b84:: with SMTP id w4mr37502006pll.22.1562115854664; Tue, 02 Jul 2019 18:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562115854; cv=none; d=google.com; s=arc-20160816; b=pLzqDjmQ2ZQAfJPZnY6ZjUoq57IhrVnQzLfSvJoXNF3/h2TqNW3nu+Wf5/NPCmKVDi sBCpGcNtafgtvtFHXyekWFCvbbMQhRoQqXfj9yuFhfEp+d5feEgg2nD1WLA/Jr76btuM XaqqB+Vsl8KfJRduNg7ZgN3JOiCQY4YDlxsR9umig1SJbaYBmNc4WmS8KFYXy5V9okNA bOn7U2kGUuXHTTu7Oj2TYwiATY52XHZ00ihZSpt1CkhNpJtUorIqFQPvLGn1B1FticX5 DGC3Jp5AS5ZWU1T31Re3+7MTZZ7pf0Cg0dJajd/NocrUO0XX+15oGRJBqeTn5+OGtvWb hk+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=tQLGr8HhNTHzKcZpESdixxXqIYrLKCLLpoUYBj5QxVk=; b=b9usCxvT/k50SUfSGtRw9QVfy7Fd24DpiaiLQ3T6hdxPzvML7kOU1IZb8zOmd9TOG3 e1l7askZ7YDFqRwKIRFLO54ygyP4dN/N4Oo86eFNb9YQGoF9zJwxE9SU350XTslYu09C 52vXhQpUl5Rd5qPgrcuUqinTCZ0z0n8jrVjrGW/t+AA/DK4+NqLYLiCStNyDddBaueXM FbSpbv/Pa0/9kcIQo3NTXtOtT5JgPsh6073OMBPynYGSDzNZhxn2vpxG0G2dxhcgujte PzIpGFcAyIhCbo9aCIk08Q5eBJLrboU0jXsPl6XpwhjcoocAFwLKr2PreA1KtWR7Ny7d ByFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pVL9BX1m; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 18si381508pgy.84.2019.07.02.18.03.59; Tue, 02 Jul 2019 18:04:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=pVL9BX1m; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727246AbfGCBDF (ORCPT + 99 others); Tue, 2 Jul 2019 21:03:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:51750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726652AbfGCBDF (ORCPT ); Tue, 2 Jul 2019 21:03:05 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF65A21874; Tue, 2 Jul 2019 20:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562098428; bh=JSSTummgovKzjJ78cGvRjxWkWBFR6+oqkDGCqnix+5g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pVL9BX1mfkWNMZ4JuOXEP1bLnhu3I9BVToumxa1kjdZNRBH56OgKPIrtlVhivYmCX ByFpnYvXObta8eYhxDF+YD3vem2AyauZtEzCHZHVRal/nPjba1ZSg4n+ipbJJB+Ury uo7TwFjCDC96bjssFiG+pA6PpZbeBceSeH91LZd4= Date: Tue, 2 Jul 2019 13:13:48 -0700 From: Andrew Morton To: Matteo Croce Cc: Alexey Dobriyan , LKML , Kees Cook , Aaron Tomlin Subject: Re: [PATCH] proc/sysctl: add shared variables for range check Message-Id: <20190702131348.9004db6da7e1cbeb7db5ca9f@linux-foundation.org> In-Reply-To: References: <20190702170228.GA4404@avx2> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2 Jul 2019 19:21:33 +0200 Matteo Croce wrote: > On Tue, Jul 2, 2019 at 7:13 PM Alexey Dobriyan wrote: > > > > > -static long zero; > > > static long long_max = LONG_MAX; > > > > > > struct ctl_table epoll_table[] = { > > > @@ -301,7 +300,7 @@ struct ctl_table epoll_table[] = { > > > .maxlen = sizeof(max_user_watches), > > > .mode = 0644, > > > .proc_handler = proc_doulongvec_minmax, > > > - .extra1 = &zero, > > > + .extra1 = SYSCTL_ZERO, > > > .extra2 = &long_max, > > > > This looks wrong: proc_doulongvec_minmax() expects "long"s. > > The whole patch needs rechecking. > > > > > +/* shared constants to be used in various sysctls */ > > > +const =======>int<========== sysctl_vals[] = { 0, 1, INT_MAX }; > > > +EXPORT_SYMBOL(sysctl_vals); > > Yes, you're right, that chunk must be dropped. > Anyway I've checked the patch, this was the only long field touched. Yup. akpm3:/usr/src/25> find . -name "*.c" | xargs grep -C4 SYSCTL_ZERO|grep long ./fs/eventpoll.c- .proc_handler = proc_doulongvec_minmax, ./fs/eventpoll.c- .extra2 = &long_max, I did this: --- a/fs/eventpoll.c~proc-sysctl-add-shared-variables-for-range-check-fix-4 +++ a/fs/eventpoll.c @@ -291,6 +291,7 @@ static LIST_HEAD(tfile_check_list); #include +static long long_zero; static long long_max = LONG_MAX; struct ctl_table epoll_table[] = { @@ -300,7 +301,7 @@ struct ctl_table epoll_table[] = { .maxlen = sizeof(max_user_watches), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - .extra1 = SYSCTL_ZERO, + .extra1 = &long_zero, .extra2 = &long_max, }, { } I renamed it to avoid using "&zero," in this situation.