From: Al Viro Subject: Re: [PATCH 05/24] devtmpfs: open code ksys_chdir and ksys_chroot Date: Tue, 21 Jul 2020 18:16:27 +0100 Message-ID: <20200721171627.GZ2786714@ZenIV.linux.org.uk> References: <20200721162818.197315-1-hch@lst.de> <20200721162818.197315-6-hch@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Linus Torvalds Cc: Christoph Hellwig , Greg Kroah-Hartman , "Rafael J. Wysocki" , Linux Kernel Mailing List , linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel , Linux API List-Id: linux-raid.ids On Tue, Jul 21, 2020 at 09:49:17AM -0700, Linus Torvalds wrote: > On Tue, Jul 21, 2020 at 9:28 AM Christoph Hellwig wrote: > > > > + > > + /* traverse into overmounted root and then chroot to it */ > > + if (!kern_path("/..", LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path) && > > + !inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR) && > > + ns_capable(current_user_ns(), CAP_SYS_CHROOT) && > > + !security_path_chroot(&path)) { > > + set_fs_pwd(current->fs, &path); > > + set_fs_root(current->fs, &path); > > + } > > + path_put(&path); > > This looks wrong. It is wrong. kern_path() leaves *path unmodified in case of error, and that struct path is uninitialized here.