Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp777212ybk; Fri, 15 May 2020 13:16:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnDAAbQmPA/7dWKPbAGY/UEbnYS5nsyR1zT8IRgKyY0vqKJi05FuMZsjl4o47a6e/TJm/6 X-Received: by 2002:a17:906:410a:: with SMTP id j10mr4477697ejk.378.1589573768513; Fri, 15 May 2020 13:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589573768; cv=none; d=google.com; s=arc-20160816; b=GmKxURW/vLeiPFISJrESib+z7qVqjy+RBTwHWejRsW7y7rZObbjiLRSxH6dHX+wxCM 2/xtUeEgXyooilea+jVBaJ91reldHJcM46aeZ9u68vuvEeWwqPm6LXIaOW5PxoD2ECUI 8oK5PTYsk0lEupCgyt4ppWwBLVeOxygphSHs0sWvmUtEpqmPY1f7bgK2w78bW2GvlhQP ChODb84dx2CsNesNfy0CCgTWfLKcQwrCQKlFgtl9qqDvwneldkASy3Zngsz2tF6Yjz4t ls6uBGgsz8/w63AeZlRT8S94KFewaw4XixKR22mW45CPGCmHUZ55Eg3NWPGDPnCJA5k6 Fj8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Yw39Uc/+TC7P3BEHd41hdNfhMhuGKtLtgEQ12NZPdw0=; b=TdDhrJxC1I3O4TodbYZIvJrfomxglizgxKNDAerEfbkAmT37ZE5tONT+n7w5JnIQtd KxlKD7LIgbQOFZYKBQoek3rLMhvedNV+OW0zAFkbKK1nirGkmAkVyH+OZ28v6OQWPzOq thA2kFSDrkhlydridWicM4KLO8vJs3GN8qtvOzlA9RuJu70Me65Wi6h7e3RSAo6dr8wK yqmPYgW3WgWLb3TeqrIa9L9oOCdweMySGpGDgXEIbmTqjp2QFXHzimveL11eBIMnRG1R rV4XKP8TOCUHuAa3je6zGJOUtbghb9JKo50QIXD53s9/AVQPL5mUuACgms/ASsaeEmPe KjkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si1929533edt.100.2020.05.15.13.15.43; Fri, 15 May 2020 13:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726236AbgEOUOY (ORCPT + 99 others); Fri, 15 May 2020 16:14:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgEOUOY (ORCPT ); Fri, 15 May 2020 16:14:24 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04CA9C061A0C; Fri, 15 May 2020 13:14:23 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jZgiT-009GPf-NM; Fri, 15 May 2020 20:13:57 +0000 Date: Fri, 15 May 2020 21:13:57 +0100 From: Al Viro To: Tetsuo Handa Cc: Alexey Gladkov , "Eric W. Biederman" , syzbot , jmorris@namei.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org, linux-security-module@vger.kernel.org, serge@hallyn.com, sfr@canb.auug.org.au, syzkaller-bugs@googlegroups.com, linux-fsdevel Subject: Re: linux-next boot error: general protection fault in tomoyo_get_local_path Message-ID: <20200515201357.GG23230@ZenIV.linux.org.uk> References: <0000000000002f0c7505a5b0e04c@google.com> <72cb7aea-92bd-d71b-2f8a-63881a35fad8@i-love.sakura.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <72cb7aea-92bd-d71b-2f8a-63881a35fad8@i-love.sakura.ne.jp> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 16, 2020 at 12:36:28AM +0900, Tetsuo Handa wrote: > On 2020/05/16 0:18, Tetsuo Handa wrote: > > This is > > > > if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { > > char *ep; > > const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10); > > struct pid_namespace *proc_pidns = proc_pid_ns(d_inode(dentry)); // <= here > > > > if (*ep == '/' && pid && pid == > > task_tgid_nr_ns(current, proc_pidns)) { > > > > which was added by commit c59f415a7cb6e1e1 ("Use proc_pid_ns() to get pid_namespace from the proc superblock"). > > > > @@ -161,9 +162,10 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer, > > if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { > > char *ep; > > const pid_t pid = (pid_t) simple_strtoul(pos + 1, &ep, 10); > > + struct pid_namespace *proc_pidns = proc_pid_ns(d_inode(dentry)); > > > > if (*ep == '/' && pid && pid == > > - task_tgid_nr_ns(current, sb->s_fs_info)) { > > + task_tgid_nr_ns(current, proc_pidns)) { > > pos = ep - 5; > > if (pos < buffer) > > goto out; > > > > Alexey and Eric, any clue? > > > > A similar bug (racing inode destruction with open() on proc filesystem) was fixed as > commit 6f7c41374b62fd80 ("tomoyo: Don't use nifty names on sockets."). Then, it might > not be safe to replace dentry->d_sb->s_fs_info with dentry->d_inode->i_sb->s_fs_info . Could you explain why do you want to bother with d_inode() anyway? Anything that does dentry->d_inode->i_sb can bloody well use dentry->d_sb. And that's never changed over the struct dentry lifetime - ->d_sb is set on allocation and never modified afterwards.