Re: [PATCH 1/5] proc: make /proc/*/cmdline go through LSM

From: Andy Shevchenko
Date: Wed Feb 21 2018 - 14:28:48 EST


On Wed, Feb 21, 2018 at 9:23 PM, Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:
> /proc/*/cmdline is not different from /proc/*/environ as it accesses
> target task's memory (and can access the very same region of memory)
> but it doesn't go through ptrace_may_access() and thus doesn't go through LSM.

> +static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
> +{
> + struct mm_struct *mm = proc_mem_open(inode, mode);
> +
> + if (IS_ERR(mm))
> + return PTR_ERR(mm);

So, is it possible to have it NULL?..

> +
> + file->private_data = mm;
> + return 0;
> +}

> +static int mem_release(struct inode *inode, struct file *file)
> +{
> + struct mm_struct *mm = file->private_data;

> + if (mm)

...or I don't get this check.

> + mmdrop(mm);
> + return 0;
> +}

--
With Best Regards,
Andy Shevchenko