Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755810Ab2HOSnp (ORCPT ); Wed, 15 Aug 2012 14:43:45 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:57007 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754911Ab2HOSng (ORCPT ); Wed, 15 Aug 2012 14:43:36 -0400 MIME-Version: 1.0 In-Reply-To: <20120815194426.52fd7936@pyramind.ukuu.org.uk> References: <20120726134748.GA20605@localhost> <20120810015222.GA19286@localhost> <20120815030110.GA24836@localhost> <20120815130159.GA3221@redhat.com> <1345041021.31459.88.camel@twins> <20120815175651.GA17814@redhat.com> <20120815194426.52fd7936@pyramind.ukuu.org.uk> Date: Wed, 15 Aug 2012 11:43:34 -0700 X-Google-Sender-Auth: SwEzhQe03rU7GbzxOyLtaAAu91A Message-ID: Subject: Re: yama_ptrace_access_check(): possible recursive locking detected From: Kees Cook To: Alan Cox Cc: Oleg Nesterov , Peter Zijlstra , Fengguang Wu , LKML Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1185 Lines: 32 On Wed, Aug 15, 2012 at 11:44 AM, Alan Cox wrote: >> It sounds like get_task_comm shouldn't have locking at all then? It >> should just do a length-limited copy and make sure there is a trailing >> 0-byte? > > It has locking so that it has a consistent state and more importantly it > has an accessor function > > Directly accessing it is asking for bugs in future. If you hold the > needed lock then just add an > > __get_task_comm() > > method that asserts the lock is held. That way the rest of the behaviour > remains properly encapsulated for when someone changes it. But what's been discussed is that no lock is needed if the caller doesn't care about the accuracy of the contents, which is the situation I'm in. Looking at other readers of ->comm, they just either use it directly or copy it directly. Only when accuracy matters does the kernel use get_task_comm. -Kees -- Kees Cook Chrome OS Security -- 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/