]> git.baikalelectronics.ru Git - kernel.git/commit
tmpfs: fix the issue that the mount and remount results are inconsistent.
authorZhaoLong Wang <wangzhaolong1@huawei.com>
Wed, 29 Jun 2022 12:43:24 +0000 (20:43 +0800)
committerakpm <akpm@linux-foundation.org>
Mon, 18 Jul 2022 22:07:51 +0000 (15:07 -0700)
commit7939f7f8c65c15e2c7367e817a8f613eca555d38
treee0513d8ba6fe55a789ccd5c4529991cfc256c0c4
parent5bcf07bbf45f80201db5cd88a50e7c11e67f69d9
tmpfs: fix the issue that the mount and remount results are inconsistent.

An undefined-behavior issue has not been completely fixed since commit
ee15730b75ab ("tmpfs: fix undefined-behaviour in shmem_reconfigure()").
In the commit, check in the shmem_reconfigure() is added in remount
process to avoid the Ubsan problem.  However, the check is not added to
the mount process.  It causes inconsistent results between mount and
remount.  The operations to reproduce the problem in user mode as follows:

If nr_blocks is set to 0x8000000000000000, the mounting is successful.

  # mount tmpfs /dev/shm/ -t tmpfs -o nr_blocks=0x8000000000000000

However, when -o remount is used, the mount fails because of the
check in the shmem_reconfigure()

  # mount tmpfs /dev/shm/ -t tmpfs -o remount,nr_blocks=0x8000000000000000
  mount: /dev/shm: mount point not mounted or bad option.

Therefore, add checks in the shmem_parse_one() function and remove the
check in shmem_reconfigure() to avoid this problem.

Link: https://lkml.kernel.org/r/20220629124324.1640807-1-wangzhaolong1@huawei.com
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Cc: Luo Meng <luomeng12@huawei.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Yu Kuai <yukuai3@huawei.com>
Cc: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: Zhang Yi <yi.zhang@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c