From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752519AbZJZQb4 (ORCPT ); Mon, 26 Oct 2009 12:31:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751573AbZJZQbz (ORCPT ); Mon, 26 Oct 2009 12:31:55 -0400 Received: from cantor.suse.de ([195.135.220.2]:37150 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752002AbZJZQby (ORCPT ); Mon, 26 Oct 2009 12:31:54 -0400 Date: Mon, 26 Oct 2009 17:31:57 +0100 From: Jan Kara To: Pavel Machek Cc: kernel list , linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, jamie@shareable.org Subject: Re: symlinks with permissions Message-ID: <20091026163157.GB7233@duck.suse.cz> References: <20091025062953.GC1391@ucw.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091025062953.GC1391@ucw.cz> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sun 25-10-09 07:29:53, Pavel Machek wrote: > ...yes, they do exist, in /proc/self/fd/* . Unfortunately, their > permissions are not actually checked during open, resulting in > (obscure) security hole: if you have fd open for reading, you can > reopen it for write, even through unix permissions would not allow > that. > > Now... I'd like to close the hole. One way would be to actually check > symlink permissions on open -- because those symlinks already have > correct permissions. Hmm, I'm not sure I understand the problem. Symlink is just a file containing a path. So if you try to open a symlink, you will actually open a file to which the path points. So what security problem is here? Either you can open the file symlink points to for writing or you cannot... Anyway, if you want to play with this, fs/proc/base.c:proc_pid_follow_link is probably the function you are interested in. Honza -- Jan Kara SUSE Labs, CR