Received: by 10.192.165.148 with SMTP id m20csp338389imm; Fri, 20 Apr 2018 07:36:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/09+pRLS3R2X/LZugLsElLXOczmb+qjtRQedRAW2JVS+4/pl6eHJD2ckG82L0U4bpopjGz X-Received: by 10.101.100.132 with SMTP id e4mr3556592pgv.102.1524234976352; Fri, 20 Apr 2018 07:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524234976; cv=none; d=google.com; s=arc-20160816; b=lnYN3ehVP6SJ3Op8z4c5y+vyPxFNaiGDwCZVIvtmHqN8IaNjluCkZkCbgjiChpzjhg Jv5yEXQcyj32Ih39pjyc0BqQul/qcDwML6gTUe9pMsNsa5LzMG11IGvS9IVtkSz12oU+ ThWlf2sYDXKQYMAFMYrY1leClbdkIv4UoAtmPujOuRLiPWQYEFRw9Ryy150mRV3z2dVL 8WiApC7//MEa07aTGUDfWNNsESCeCn6reXzfeuvzduoqKjSAdZbGqWNcu3l1FJdeOnjR QC2HbuuENOFtyv5tZOnN8bGqjyn3SNt7oOQJxm+PSSW7pijLEPKOtsLmOLwMx4c0Axy+ YM/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=dr0ynnroQXHQj6nX/h/eoes/fDu5RijsxYtjXISfMm4=; b=YAg2XgxWyXn3pkAx2DROZekH4Z4H/U/GIyw6HQ0yxVMSX6f34L/HKzmUpx6b7xJESE 7YiT2Aj/g3GroNJD4Qt5zJERRtvJfzy0YvYBATqqOvOVearwwYN5BzQsVVcCiKGAvKPH lcpm8Yr7rwlUGEjrY+t3bDJ2AGWOAc8/SReGxyePSZe2JpCK5f55Q92PQ7RQTNjlEwC/ VPfU3BzFaxpoAh0UGmazXBeaHBYZGxAHDJB8G10nW0FsayuK8EdyKVbZiRDXWVB37YaR dOJ5Jxh4XsMuuBjzj7P8F6KVKGd12RFP/cKl66W6PlmtkKegIgyl93kimYIVET4WSouC iGRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=K5tdctae; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u185si5385754pfu.339.2018.04.20.07.36.00; Fri, 20 Apr 2018 07:36:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=K5tdctae; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755447AbeDTOea (ORCPT + 99 others); Fri, 20 Apr 2018 10:34:30 -0400 Received: from mail-oi0-f41.google.com ([209.85.218.41]:39866 "EHLO mail-oi0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755421AbeDTOe1 (ORCPT ); Fri, 20 Apr 2018 10:34:27 -0400 Received: by mail-oi0-f41.google.com with SMTP id n65-v6so8219840oig.6 for ; Fri, 20 Apr 2018 07:34:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=dr0ynnroQXHQj6nX/h/eoes/fDu5RijsxYtjXISfMm4=; b=K5tdctaeL9xF9Vs7NaHVcrlwVSiiVSEsDwDyf7XQ7tuP+Di2Pgy4dzWpldjhRco4+m iJMlopi+8rcLqQU80liRQ5Z0Qgi6LaFkUp9Ub64xJtWT/CGudBTbhN+Dwhdha2JnblaH pZ32qjmDhRWJ76XaY7QxpmL6J1jEZhN+n1NZ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=dr0ynnroQXHQj6nX/h/eoes/fDu5RijsxYtjXISfMm4=; b=OKAVxSswNRQ+kARq2wSM59Ynq7AsfYmGRtAN9JOFwDckjCAN5wrwmpJSeLTh0kTrNu P7ks8XcJnAri3W2hSUM+KzqFbzDbWFGY4WdR1grlByndHIJRhqjq6XINFHkiRS3M50nM ySFW1Y1MVn6UER7fGqxlxmLr7y8mSeXgD/iMkpwKupRjtX5cO+aCJ70+xSD66FeTPceB WmX6+zhie0Nc/1mDy9CjbbRczn7RPJEq3bcg85qGM90grU5/PWYoQrU+97vey19D1Eqx ZqsYqIEu1Y6dSyKZaQL4YYlwMq2A6N6B9dJLttGVD441ScirgmGVjBytuOJS9hGO8a9H vjzA== X-Gm-Message-State: ALQs6tD6Skth9f9DybabBi42Cn+89x2P/XKK5dL/k6pDOyxA+x4SsUO7 3VKNdWU/9R3NaYH/X7iHg7NjyPTjYCVjM24VymPHbw== X-Received: by 2002:aca:6b04:: with SMTP id g4-v6mr5994393oic.118.1524234866649; Fri, 20 Apr 2018 07:34:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:5303:0:0:0:0:0 with HTTP; Fri, 20 Apr 2018 07:34:25 -0700 (PDT) X-Originating-IP: [176.63.54.97] In-Reply-To: References: <20180418174014.1592871-1-songliubraving@fb.com> From: Miklos Szeredi Date: Fri, 20 Apr 2018 16:34:25 +0200 Message-ID: Subject: Re: [PATCH v2] tracing: fix bad use of igrab in trace_uprobe.c To: Song Liu Cc: LKML , Kernel Team , Steven Rostedt , Ingo Molnar , Howard McLauchlan , Josef Bacik , Srikar Dronamraju Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 19, 2018 at 6:37 PM, Song Liu wrote: > > >> On Apr 19, 2018, at 7:44 AM, Miklos Szeredi wrote: >> >> On Thu, Apr 19, 2018 at 10:58 AM, Miklos Szeredi wrote: >>> On Wed, Apr 18, 2018 at 7:40 PM, Song Liu wrote: >>>> *arg++ = '\0'; >>>> filename = argv[1]; >>>> ret = kern_path(filename, LOOKUP_FOLLOW, &path); >>>> if (ret) >>>> - goto fail_address_parse; >>>> - >>>> - inode = igrab(d_real_inode(path.dentry)); >> >> Also, where has the d_real_inode() gone? >> >> Looks like we need tu->inode back, since the return value of >> d_real_inode() may change over time. I'd do the "tu->inode = >> d_real_inode(tu->path.dentry)" just before first use (i.e. when >> enabling the tracepoint). >> > > Do we need mechanism to prevent the return value of d_real_inode() > to change? Would the following sequence happen? > > create trace_uprobe > enable trace_uprobe (uprobe_register) > d_real changes > disable trace_uprobe (uprobe_unregister get wrong inode?) Yes. > > Another case might be: > > create trace_uprobe > enable trace_uprobe (uprobe_register) > disable trace_uprobe (uprobe_unregister) > d_real changes > enable trace_uprobe (do we need new inode for uprobe_register) Probably a good idea to use the new one, but doesn't really matter. Do the one that's simpler. This corner case is simply not interesting (modifying a binary while it is being debugged with uprobe). Let's just concentrate on making this crash and leak free. Thanks, Miklos