From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757302AbcIVMZe (ORCPT ); Thu, 22 Sep 2016 08:25:34 -0400 Received: from b.ns.miles-group.at ([95.130.255.144]:44723 "EHLO radon.swed.at" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756883AbcIVMZa (ORCPT ); Thu, 22 Sep 2016 08:25:30 -0400 From: Richard Weinberger Subject: ext4, f2fs: fscrypt_has_permitted_context() check in file open To: "Theodore Ts'o" , Jaegeuk Kim Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel , "linux-kernel@vger.kernel.org" Message-ID: <6789d30e-f95d-d8bd-cd6e-664a89c0dfd1@nod.at> Date: Thu, 22 Sep 2016 14:24:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! Both ext4 and f2fs check in the file open code the context of the parent directory too: ext4: if (ext4_encrypted_inode(d_inode(dir)) && !fscrypt_has_permitted_context(d_inode(dir), inode)) { ext4_warning(inode->i_sb, "Inconsistent encryption contexts: %lu/%lu", (unsigned long) d_inode(dir)->i_ino, (unsigned long) inode->i_ino); dput(dir); return -EPERM; } f2fs: if (f2fs_encrypted_inode(d_inode(dir)) && !fscrypt_has_permitted_context(d_inode(dir), inode)) { dput(dir); return -EPERM; } Why do we need this check? AFAIK this situation can never happen unless due to a bug in the filesystem code. Thanks, //richard