From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 16 Aug 2018 15:32:23 +0300 From: Alexey Dobriyan To: Srikanth K H Cc: mcgrof@kernel.org, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 1/1] Preventive patch in the proc file-system to handle NULL check. Message-ID: <20180816123223.GA15817@avx2> References: <1534412053-22457-1-git-send-email-srikanth.h@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1534412053-22457-1-git-send-email-srikanth.h@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: On Thu, Aug 16, 2018 at 03:04:13PM +0530, Srikanth K H wrote: > If the make directory for "sys" interface fail's then its > dereferenced without even checking for its validity which > will lead to crash, hence added preventive code to check > for NULL and accordingly dereference. > --- a/fs/proc/proc_sysctl.c > +++ b/fs/proc/proc_sysctl.c > @@ -1692,6 +1692,8 @@ int __init proc_sys_init(void) > struct proc_dir_entry *proc_sys_root; > > proc_sys_root = proc_mkdir("sys", NULL); > + if (!proc_sys_root) > + return -ENOMEM; > proc_sys_root->proc_iops = &proc_sys_dir_operations; > proc_sys_root->proc_fops = &proc_sys_dir_file_operations; > proc_sys_root->nlink = 0; It is fine to crash because /proc is not modular.