public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Kees Cook <keescook@chromium.org>, James Morris <jmorris@namei.org>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Joe Perches <joe@perches.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Kalle Valo <kvalo@codeaurora.org>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Guenter Roeck <linux@roeck-us.net>, Jiri Slaby <jslaby@suse.com>,
	Paul Moore <pmoore@redhat.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Casey Schaufler <casey@schaufler-ca.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH 5/6] fs: define a string representation of the kernel_read_file_id enumeration
Date: Thu, 21 Apr 2016 16:26:28 +0300	[thread overview]
Message-ID: <1461245188.6620.316.camel@linux.intel.com> (raw)
In-Reply-To: <1461192388-13900-6-git-send-email-keescook@chromium.org>

On Wed, 2016-04-20 at 15:46 -0700, Kees Cook wrote:
> From: Mimi Zohar <zohar@linux.vnet.ibm.com>
> 
> A string representation of the kernel_read_file_id enumeration is
> needed for displaying messages (eg. pr_info, auditing) that can be
> used by multiple LSMs and the integrity subsystem.  To simplify
> keeping the list of strings up to date with the enumeration, this
> patch defines two new preprocessing macros named __fid_enumify and
> __fid_stringify to create the enumeration and an array of strings.
> kernel_read_file_id_str() returns a string based on the enumeration.
> 
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> [kees: removed removal of my old version, constified pointer values]
> Signed-off-by: Kees Cook <keescook@chromium.org>


I got this

In file included from /home/andy/prj/linux-
topic/include/linux/seq_file.h:10:0,
                 from /home/andy/prj/linux-
topic/include/linux/pinctrl/consumer.h:17,
                 from /home/andy/prj/linux-
topic/include/linux/pinctrl/devinfo.h:21,
                 from /home/andy/prj/linux-
topic/include/linux/device.h:24,
                 from /home/andy/prj/linux-
topic/include/linux/dmaengine.h:20,
                 from /home/andy/prj/linux-
topic/drivers/dma/dw/core.c:15:
/home/andy/prj/linux-topic/include/linux/fs.h:2627:74: warning: type
qualifiers ignored on function return type [-Wignored-qualifiers]
 static inline const char * const kernel_read_file_id_str(enum
kernel_read_file_id id)

> ---
>  include/linux/fs.h | 31 +++++++++++++++++++++++++------
>  1 file changed, 25 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 70e61b58baaf..518716b4834e 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2590,15 +2590,34 @@ static inline void i_readcount_inc(struct
> inode *inode)
>  #endif
>  extern int do_pipe_flags(int *, int);
>  
> +#define __kernel_read_file_id(id) \
> +	id(UNKNOWN, unknown)		\
> +	id(FIRMWARE, firmware)		\
> +	id(MODULE, kernel-module)		\
> +	id(KEXEC_IMAGE, kexec-image)		\
> +	id(KEXEC_INITRAMFS, kexec-initramfs)	\
> +	id(POLICY, security-policy)		\
> +	id(MAX_ID, )
> +
> +#define __fid_enumify(ENUM, dummy) READING_ ## ENUM,
> +#define __fid_stringify(dummy, str) #str,
> +
>  enum kernel_read_file_id {
> -	READING_FIRMWARE = 1,
> -	READING_MODULE,
> -	READING_KEXEC_IMAGE,
> -	READING_KEXEC_INITRAMFS,
> -	READING_POLICY,
> -	READING_MAX_ID
> +	__kernel_read_file_id(__fid_enumify)
> +};
> +
> +static const char * const kernel_read_file_str[] = {
> +	__kernel_read_file_id(__fid_stringify)
>  };
>  
> +static inline const char * const kernel_read_file_id_str(enum
> kernel_read_file_id id)
> +{
> +	if (id < 0 || id >= READING_MAX_ID)
> +		return kernel_read_file_str[READING_UNKNOWN];
> +
> +	return kernel_read_file_str[id];
> +}
> +
>  extern int kernel_read(struct file *, loff_t, char *, unsigned long);
>  extern int kernel_read_file(struct file *, void **, loff_t *, loff_t,
>  			    enum kernel_read_file_id);

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2016-04-21 13:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20 22:46 [PATCH v5 0/6] LSM: LoadPin for kernel file loading restrictions Kees Cook
2016-04-20 22:46 ` [PATCH 1/6] string_helpers: add kstrdup_quotable Kees Cook
2016-04-20 22:46 ` [PATCH 2/6] string_helpers: add kstrdup_quotable_cmdline Kees Cook
2016-04-20 22:46 ` [PATCH 3/6] string_helpers: add kstrdup_quotable_file Kees Cook
2016-04-20 22:46 ` [PATCH 4/6] Yama: consolidate error reporting Kees Cook
2016-04-20 22:46 ` [PATCH 5/6] fs: define a string representation of the kernel_read_file_id enumeration Kees Cook
2016-04-21 13:26   ` Andy Shevchenko [this message]
2016-04-21 16:47     ` Kees Cook
2016-04-21 17:13       ` Andy Shevchenko
2016-04-20 22:46 ` [PATCH 6/6] LSM: LoadPin for kernel file loading restrictions Kees Cook
2016-04-21  0:20 ` [PATCH v5 0/6] " James Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461245188.6620.316.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=casey@schaufler-ca.com \
    --cc=corbet@lwn.net \
    --cc=jmorris@namei.org \
    --cc=joe@perches.com \
    --cc=jslaby@suse.com \
    --cc=keescook@chromium.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linux@roeck-us.net \
    --cc=mchehab@osg.samsung.com \
    --cc=pmoore@redhat.com \
    --cc=sds@tycho.nsa.gov \
    --cc=serge@hallyn.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vkuznets@redhat.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox