From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933098AbdELWxp (ORCPT ); Fri, 12 May 2017 18:53:45 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36861 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933017AbdELWxn (ORCPT ); Fri, 12 May 2017 18:53:43 -0400 Date: Sat, 13 May 2017 01:53:40 +0300 From: Cyrill Gorcunov To: Jann Horn Cc: linux-fsdevel@vger.kernel.org, kernel list , Linux API , Al Viro , akpm@linuxfoundation.org, avagin@virtuozzo.com, xemul@virtuozzo.com, Michael Kerrisk-manpages , avagin@openvz.org, jbaron@akamai.com, Andy Lutomirski Subject: Re: [patch v4 resend 2/2] kcmp: Add KCMP_EPOLL_TFD mode to compare epoll target files Message-ID: <20170512225340.GD1881@uranus.lan> References: <20170424154423.511592110@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 13, 2017 at 12:41:30AM +0200, Jann Horn wrote: > [resending as plaintext] > > I realize that the existing kcmp code has the same issue, but: > > Why are you not taking a reference to filp or filp_tgt? This can end up > performing a comparison between a pointer to a freed struct file and a > pointer to a struct file that was allocated afterwards, right? So it can > return a false "is equal" result when the two files aren't actually the same > if one of the target tasks is running? This looks like it unnecessarily > exposes information about whether an allocation reuses the memory of > a previously freed allocation. It work with unlocked data on purpose for speed sake. Moreover even if we grap a reference it is valid _only_ during comparision operation, next we drop ref and it can be easily freed by os. Thus it's up to a caller to keep references to files/task and other resources used. Cyrill