Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp748729ybk; Fri, 15 May 2020 12:28:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoUcUbULqC17t32avKQvSnba1xofyt6rzOHLuIdlyuCIfWUqmLSTxw5cYNwEWTJUU89Iqe X-Received: by 2002:aa7:c60c:: with SMTP id h12mr4109394edq.243.1589570916107; Fri, 15 May 2020 12:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589570916; cv=none; d=google.com; s=arc-20160816; b=WPzuSTbbL/qrV2iURm7GBENXoiGxnDcbW3b+YLTdygRJRwjErdQw5FiMwRSeDA83eh NN/3FSD4Zd7jXx0OCy6Tn+sDuxgki7mq0tnYQh5YCXm1/zha58vxqRGH9QKZxHluVnyQ 8Z3JxvMUrz/RWW+vi8oG5ATb5w76K3HiYjrmOfcT5FKQCUbH1UivdUBVj4Lgs+OjKI0N SmYnlIYCvMBGbLtsjmDKoZeXxXKMCa5fnrH0+FhfLtyUbo9mNnymGLt9YxATq7w752zw bn7g0uYvTYvzb/2nNXA6FLR2vBhY0IS6ubfpSwIVLvjgn+EXvuIoMOtYYiM0iMdiutea vh2A== 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=bzhnHhdwppEVGnAjt714aP6TOVRHVp0mXIPxwkzkms4=; b=t2jMlGQ+a4iXKsVHwQBsiLv8t3Z7TRvcIOsH9w6ZWpc0l6MIOeq+fFsDHUlVA+HJUF 4OXdU7/QXEgvCNPNEPo0eGQW2s1WxCTStdb74MyJ2P9J47Pmj/tN8XARXOApzzaCdGwk yUDHPCpdLsXz2zTLrb2IyUf7//zIPENnRwm+2ltgUPXFUemfmbDDYzR+Khg2Emqcdsit bl8JhiXL01vYpcNqbEo9323AUyRmmlc7zp+aB88XWc38L/G4xOhABI6U5ePaZ243pRC+ UnkogLnXL1XLGjOb78jeLmmAANwoDo6m6bGfMCQYpWp8o8ymQoA2/QMUYowOt0uxlvCC zxog== 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u3si1815485edp.525.2020.05.15.12.28.12; Fri, 15 May 2020 12:28:36 -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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726236AbgEOT0L (ORCPT + 99 others); Fri, 15 May 2020 15:26:11 -0400 Received: from raptor.unsafe.ru ([5.9.43.93]:50062 "EHLO raptor.unsafe.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgEOT0K (ORCPT ); Fri, 15 May 2020 15:26:10 -0400 Received: from comp-core-i7-2640m-0182e6 (ip-89-102-33-211.net.upcbroadband.cz [89.102.33.211]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by raptor.unsafe.ru (Postfix) with ESMTPSA id 4FC8020A0B; Fri, 15 May 2020 19:26:05 +0000 (UTC) Date: Fri, 15 May 2020 21:25:59 +0200 From: Alexey Gladkov To: "Eric W. Biederman" Cc: Tetsuo Handa , 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: <20200515192559.e5ofmmzxdviierkb@comp-core-i7-2640m-0182e6> References: <0000000000002f0c7505a5b0e04c@google.com> <87lfltcbc4.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lfltcbc4.fsf@x220.int.ebiederm.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.1 (raptor.unsafe.ru [5.9.43.93]); Fri, 15 May 2020 19:26:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 01:16:59PM -0500, Eric W. Biederman wrote: > Tetsuo Handa writes: > > > 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? > > Looking at the stack backtrace this is happening as part of creating a > file or a device node. The dentry that is passed in most likely > comes from d_alloc_parallel. So we have d_inode == NULL. > > I want to suggest doing the very simple fix: > > - if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/') { > + if (sb->s_magic == PROC_SUPER_MAGIC && *pos == '/' && denty->d_inode) { > > But I don't know if there are any other security hooks early in lookup, > that could be called for an already existing dentry. > > So it looks like we need a version proc_pid_ns that works for a dentry, > or a superblock. > > Alex do you think you can code up an patch against my proc-next branch > to fix this? Sure. -- Rgrds, legion