Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Eric Biggers Newsgroups: linux.kernel Subject: Re: [PATCH] ext4 crypto: migrate into vfs's crypto engine Date: Sat, 07 May 2016 04:40:01 +0200 Message-ID: References: X-Original-To: Jaegeuk Kim Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Hig2OYUGOTZYd07uLDem2Fq5mRtpIaZveKKDLQ2cyNg=; b=0FrcnvDN4pm8z1titNLS0BpDefetCSkFz5znkCPzq5I1dDYMXeza/26W+EigzMfzDn 41TA3ZlN5TMp++F/+v64PdJ0rQwBEva+EnX7WfXomAGA1nzSfqMD3RBHHPDrF8huVHiG 1Orl4KR6bhrPDXWnDgcH+E+AD5Z8vz5nhJO240YGZGNxaifKlD5M0hqHidFkZN8iMI/W DMoGEiYejntG1dY6dY53GRhvSwMklAH+90MYo7nixGbBmSHTrnls5kD7EfO6I4nKEU8l ErOIy50WyhJAV1LeqGCOaMFCgNaEsOeMmbGHiOk/GiRKK7lXv3y8+TaWtoxw9BcChc/B kLAg== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Hig2OYUGOTZYd07uLDem2Fq5mRtpIaZveKKDLQ2cyNg=; b=VrpRgaJYtbuA2aaEAlPNga3epHDq6s4aSSlQwqwxqFy6Kr+4UnwoWqd+e82tWedYXV O3p2E4TaJrDT289qTi5L6CLa3cI/cgKrjkeLc14vFhHiLynzohkq/6tDZPSxj0la1EEw wCs0MPF745lRH6WuJGzzIihc+PZ3g7i9EKQNdROMKyBoI3D0uEy15EMWvB8NZ+ues1NE jxEVIBoTXXfUNtOfAJMltpbpX4kT34mISCWnZNe4+zgKLykfkEKCIgXsGjoEnQzPF2oK a6sF1kaFVo1KK47dC099hA+oSufy8Ju3DHsQug7Ov5gGwR/OH3SSrA+TMHHXF9j3P5NJ 9J7Q== X-Gm-Message-State: AOPr4FXxkqm9Ew143O6l79laffqcprv7PbzfLfaXsuo7bVJ/lbhGVEbKoueEbnBX+4utlg== X-Received: by 10.50.1.105 with SMTP id 9mr244291igl.1.1462588264241; Fri, 06 May 2016 19:31:04 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 75 Organization: linux.* mail to news gateway X-Original-Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, linux-ext4@vger.kernel.org X-Original-Date: Fri, 6 May 2016 21:31:02 -0500 X-Original-Message-ID: <20160507023102.GB906@zzz> X-Original-References: <1461629736-16523-1-git-send-email-jaegeuk@kernel.org> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1396225 Hi Jaegeuk, On Mon, Apr 25, 2016 at 05:15:36PM -0700, Jaegeuk Kim wrote: > This patch removes the most parts of internal crypto codes. > And then, it modifies and adds some ext4-specific crypt codes to use the generic > facility. Except for the key name prefix issue that Ted pointed out, this overall seems good, although I didn't read into every detail and haven't yet tested the code. A few comments: There are compiler errors and warnings in the function 'dx_show_leaf()', which is not compiled by default. In ext4_lookup(): > /* > * DCACHE_ENCRYPTED_WITH_KEY is set if the dentry is > * created while the directory was encrypted and we > * don't have access to the key. > */ > if (fscrypt_has_encryption_key(dir)) > fscrypt_set_encrypted_dentry(dentry); Shouldn't this say "and we have access to the key"? Or is the code wrong? In ext4_empty_dir(): > bool err = false; Since this is a bool it should not be called "err". Maybe call it "empty" instead. In ext4_finish_bio(): > if (!page->mapping) { > /* The bounce data pages are unmapped. */ > data_page = page; > fscrypt_pullback_bio_page(&page, false); > } ... >#ifdef CONFIG_EXT4_FS_ENCRYPTION > if (data_page) > fscrypt_restore_control_page(data_page); >#endif Does this always do the same thing as the previous code? Does !page->mapping always imply that the page was involved in encrypted I/O? In ext4_encrypted_get_link(): > if ((cstr.len + > sizeof(struct fscrypt_symlink_data) - 1) > > max_size) { Make this one line? In ext4_file_mmap() > int err = fscrypt_get_encryption_info(inode); > if (err) > return 0; Should the error code be propagated to the caller? In ext4_ioctl(): > case EXT4_IOC_GET_ENCRYPTION_POLICY: { >#ifdef CONFIG_EXT4_FS_ENCRYPTION > struct fscrypt_policy policy; > int err = 0; > > if (!ext4_encrypted_inode(inode)) > return -ENOENT; This is existing code and I do not know if it can be changed, but I feel that ENOENT is a not good error code here. If the ext4_encrypted_inode() check were to be removed, the implementation would match f2fs and the error code would be ENODATA instead. - Eric