ima: open a new file instance if no read permissions
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Tue, 9 Oct 2018 15:12:33 +0000 (10:12 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2018 19:08:46 +0000 (11:08 -0800)
commit8b259b99654cbd19b5958061ed6190dc514d6286
tree0193de92aaa2afbc02b9074328bc13d7d3f4f05e
parent13d3c98fa8037ecd5c8d4ed165150fad95f59e6f
ima: open a new file instance if no read permissions

commit a408e4a86b36bf98ad15b9ada531cf0e5118ac67 upstream.

Open a new file instance as opposed to changing file->f_mode when
the file is not readable.  This is done to accomodate overlayfs
stacked file operations change.  The real struct file is hidden
behind the overlays struct file.  So, any file->f_mode manipulations are
not reflected on the real struct file.  Open the file again in read mode
if original file cannot be read, read and calculate the hash.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: stable@vger.kernel.org (linux-4.19)
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/integrity/ima/ima_crypto.c