Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752487Ab0FWR6A (ORCPT ); Wed, 23 Jun 2010 13:58:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27409 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423Ab0FWR57 (ORCPT ); Wed, 23 Jun 2010 13:57:59 -0400 Date: Wed, 23 Jun 2010 19:56:02 +0200 From: Oleg Nesterov To: Jiri Slaby Cc: akpm@linux-foundation.org, adobriyan@gmail.com, nhorman@tuxdriver.com, linux-kernel@vger.kernel.org, Stephen Smalley , James Morris , Eric Paris Subject: Re: [PATCH v3 06/11] rlimits: do security check under task_lock Message-ID: <20100623175602.GA14824@redhat.com> References: <20100513155621.51ca77a4.akpm@linux-foundation.org> <1275855783-27316-1-git-send-email-jslaby@suse.cz> <20100607180855.GA6689@redhat.com> <4C222644.4040601@gmail.com> <20100623161254.GA10098@redhat.com> <4C224804.7030809@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C224804.7030809@gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1637 Lines: 44 On 06/23, Jiri Slaby wrote: > > On 06/23/2010 06:12 PM, Oleg Nesterov wrote: > > On 06/23, Jiri Slaby wrote: > >> > >> BTW this capable() has the exactly same problem with being called with > >> task_lock held. Is it OK to move it completely out of critical section? > >> I'm asking because it sets a current->flags SU bit used for accounting. > >> If I move it out of the section, it will set the bit always. > > > > Well, with all these delays I do not know what "exactly same problem" > > means ;) Please explain? > > As I wrote: that the capable() is called with task_lock held. Ah, got it, yes. > > selinux_task_setrlimit()->current_has_perm()->current_sid()->current_cred() I meant selinux_task_setrlimit(p)->current_has_perm(p)->task_sid(p)->__task_cred(p) > I still see no way how this is wrong. We want to check whether current > thread has capabilities to change (someone else's) rlimits. Yes. but what is "someone else" ? IIRC, one of your patches (correctly) changes security_task_setrlimit() to have the new argument, p == "someone else", correct? Now, the result of security check depends on __task_cred(p) above, and thus depends on which thread we choose to change rlimits. I think it makes more sense to always pass ->group_leader as an argument to security_task_setrlimit(p). But probably I missed something, I do not remember what exactly other patches do. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/