Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp930702ybb; Wed, 25 Mar 2020 12:16:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsF/bnbwQlSsF2s2tU6HPAzDyNh6GEMi5Snatw7DF6lEJwbPYL/McAtGwzV0fJSNuw4rXrR X-Received: by 2002:a4a:3150:: with SMTP id v16mr2514930oog.71.1585163812837; Wed, 25 Mar 2020 12:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585163812; cv=none; d=google.com; s=arc-20160816; b=klKyZdMELTqDhUHIMCbaT2SAVAXBnBgda2o8WJXpYbJXrE+C1jAusCOX5mxaGmMZB/ acFfeo/TMRgmhcjqZuGF+EifbJBMh9y3Ky/ybias4i87BLNYJ8RSYcn5Y+9EjHtsRmJY 7sO1B7mRooUQaxIhIwKwi8V8Z1+EyHvaNj4d2o6fQ04hQyo2U8kfewZ6MO4Yig3lgU8i NcviH1bZLSJwZoWukvz3+ur2CUI25NBD0TTQICMWAhh8Fd44EiLMcOW6ZXx83w7V4VtR +I2qV3U1TaTQ8QTVEDcUJJJbx5JNSO8/91AfcFxRMNHIxc1S9gLLO8QONP4D/ItYrMHi 4pTA== 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=/CSnYJ72yMBY5GskbXfCv8g/G/mmEEpCrCFQo2L0Aws=; b=twqBP+ir0LYi1j5JDAnMJOlcw8+fzpwxatOx2rZZAumC6gPlByXrkIFCnrAt+zM0qg 00KqXuhaZ4pVuELoAM3UIJeXjlWJTKnY/2KCxWrn283mBfJ+O1fFkilHjSLD1UjbLtaK UHY5Qr3gvf8kSjtPyWLhIu5PWxwN3dxxnIFdjEDNiciFc461UwS4SN8LbjD84TcZkju6 2ZSjzgmYIlILtdiy2MGLNgML/r6IKOGF6hJepiwSZAeVWJcnVGEJbTHJ8P2N5/SRxM31 x37SUD6zzFEeLqWV6giwBV6tclZ5oQRApZPj+yzK2cKMdfoWXjLjAovtoyMeOgNrP8BX FLGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YdgTKJCI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si3795otc.58.2020.03.25.12.16.39; Wed, 25 Mar 2020 12:16:52 -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=@chromium.org header.s=google header.b=YdgTKJCI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727488AbgCYTQV (ORCPT + 99 others); Wed, 25 Mar 2020 15:16:21 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46614 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbgCYTQV (ORCPT ); Wed, 25 Mar 2020 15:16:21 -0400 Received: by mail-pg1-f193.google.com with SMTP id k191so1605622pgc.13 for ; Wed, 25 Mar 2020 12:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/CSnYJ72yMBY5GskbXfCv8g/G/mmEEpCrCFQo2L0Aws=; b=YdgTKJCIKwSBYuNKrvm+Yt8937ehN0RPqPBaX9M9Q14Ku0AZPia/hqQDs58KLJaWqN BCJYs12445mr3vOefmZ1wZ1vBbhdQRVsbxjZFE/ES2F0BKD2p7LwqyVuo+e8WYYbpjW/ HtnNRacXs+AIqCrCJGVmVZJ1pHSbWBrGZ7boE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/CSnYJ72yMBY5GskbXfCv8g/G/mmEEpCrCFQo2L0Aws=; b=MGx2UB++I/cwLtBCO1rT3emsbWVCoC0Nb9vduUeed6PZFjUt7q5DYyoSD3GsW5xRsO lIIDZRt/M+inRsADzwQNyrO6R2NL5KP58yxloXqKSocZScx9EqL511aSdxnwKhTWkmdH E3fTFrzZxoLiSWLOVTO6avnhssh0WPJOwPQQ5YrWd0hRwkstUM31l4MftfNSiVvO0im2 N8S3WSqmlCQpKRCwu0vcmPt+uaUYiBW0rE+El/8GoDWyUfJPCMt/COGdJTvUujMxhvxw R1dW9XuSSc7/YfIPHJSnV7pFtTemMkAKZWVTWqVvXO150OIQ4VmeiwVe7ZzSgDUJIRAi QgAA== X-Gm-Message-State: ANhLgQ0r6qnM9Fv4sfnwJShHNIoKXnGm3ZaLZdizeP3bkgZeGlTLPfYb ZIcS6TZtlWp/QMkqkRXIS9xGng== X-Received: by 2002:a63:778e:: with SMTP id s136mr4408159pgc.155.1585163780203; Wed, 25 Mar 2020 12:16:20 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 144sm19093396pfx.184.2020.03.25.12.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 12:16:18 -0700 (PDT) Date: Wed, 25 Mar 2020 12:16:17 -0700 From: Kees Cook To: Alexey Gladkov Cc: LKML , Kernel Hardening , Linux API , Linux FS Devel , Linux Security Module , Akinobu Mita , Alexander Viro , Alexey Dobriyan , Alexey Gladkov , Andrew Morton , Andy Lutomirski , Daniel Micay , Djalal Harouni , "Dmitry V . Levin" , "Eric W . Biederman" , Greg Kroah-Hartman , Ingo Molnar , "J . Bruce Fields" , Jeff Layton , Jonathan Corbet , Linus Torvalds , Oleg Nesterov Subject: Re: [PATCH v9 9/8] proc: use named enums for better readability Message-ID: <202003251216.FD5E296@keescook> References: <20200325174245.298009-1-gladkov.alexey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200325174245.298009-1-gladkov.alexey@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 06:42:45PM +0100, Alexey Gladkov wrote: > Signed-off-by: Alexey Gladkov I love these kinds of cleanups. :) Reviewed-by: Kees Cook -Kees > --- > fs/proc/base.c | 2 +- > fs/proc/inode.c | 2 +- > fs/proc/root.c | 4 ++-- > include/linux/proc_fs.h | 6 +++--- > include/uapi/linux/proc_fs.h | 2 +- > 5 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index a836979e42fe..608d60fb79fb 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -699,7 +699,7 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr) > */ > static bool has_pid_permissions(struct proc_fs_info *fs_info, > struct task_struct *task, > - int hide_pid_min) > + enum proc_hidepid hide_pid_min) > { > /* > * If 'hidpid' mount option is set force a ptrace check, > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index a462fd111719..7870e0be0a1f 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c > @@ -165,7 +165,7 @@ void proc_invalidate_siblings_dcache(struct hlist_head *inodes, spinlock_t *lock > deactivate_super(old_sb); > } > > -static inline const char *hidepid2str(int v) > +static inline const char *hidepid2str(enum proc_hidepid v) > { > switch (v) { > case HIDEPID_OFF: return "off"; > diff --git a/fs/proc/root.c b/fs/proc/root.c > index 42f3ee05c584..de7cee435621 100644 > --- a/fs/proc/root.c > +++ b/fs/proc/root.c > @@ -32,9 +32,9 @@ > struct proc_fs_context { > struct proc_fs_info *fs_info; > unsigned int mask; > - int hidepid; > + enum proc_hidepid hidepid; > int gid; > - int pidonly; > + enum proc_pidonly pidonly; > }; > > enum proc_param { > diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h > index d259817ec913..b9f7ecd7f61f 100644 > --- a/include/linux/proc_fs.h > +++ b/include/linux/proc_fs.h > @@ -29,7 +29,7 @@ struct proc_ops { > }; > > /* definitions for proc mount option pidonly */ > -enum { > +enum proc_pidonly { > PROC_PIDONLY_OFF = 0, > PROC_PIDONLY_ON = 1, > }; > @@ -39,8 +39,8 @@ struct proc_fs_info { > struct dentry *proc_self; /* For /proc/self */ > struct dentry *proc_thread_self; /* For /proc/thread-self */ > kgid_t pid_gid; > - int hide_pid; > - int pidonly; > + enum proc_hidepid hide_pid; > + enum proc_pidonly pidonly; > }; > > static inline struct proc_fs_info *proc_sb_info(struct super_block *sb) > diff --git a/include/uapi/linux/proc_fs.h b/include/uapi/linux/proc_fs.h > index dc6d717aa6ec..f5fe0e8dcfe4 100644 > --- a/include/uapi/linux/proc_fs.h > +++ b/include/uapi/linux/proc_fs.h > @@ -3,7 +3,7 @@ > #define _UAPI_PROC_FS_H > > /* definitions for hide_pid field */ > -enum { > +enum proc_hidepid { > HIDEPID_OFF = 0, > HIDEPID_NO_ACCESS = 1, > HIDEPID_INVISIBLE = 2, > -- > 2.25.2 > -- Kees Cook