* [PATCH 1/1] efivarfs: fix statfs() on efivarfs
@ 2023-09-09 18:08 Heinrich Schuchardt
2023-09-09 22:30 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2023-09-09 18:08 UTC (permalink / raw)
To: Matthew Garrett, Jeremy Kerr, Ard Biesheuvel
Cc: Anisse Astier, linux-efi, linux-kernel, Heinrich Schuchardt
Some firmware (notably U-Boot) provides GetVariable() and
GetNextVariableName() but not QueryVariableInfo().
With commit d86ff3333cb1 ("efivarfs: expose used and total size") the
statfs syscall was broken for such firmware.
If QueryVariableInfo() does not exist or returns an error, just report the
file-system size as 0 as statfs_simple() previously did.
Fixes: d86ff3333cb1 ("efivarfs: expose used and total size")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
Tested on riscv64 StarFive VisionFive 2 with
Linux 6.5 and U-Boot v2023.10-rc4.
---
fs/efivarfs/super.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index e028fafa04f3..7f3064b948ab 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -32,11 +32,6 @@ static int efivarfs_statfs(struct dentry *dentry, struct kstatfs *buf)
u64 storage_space, remaining_space, max_variable_size;
efi_status_t status;
- status = efivar_query_variable_info(attr, &storage_space, &remaining_space,
- &max_variable_size);
- if (status != EFI_SUCCESS)
- return efi_status_to_err(status);
-
/*
* This is not a normal filesystem, so no point in pretending it has a block
* size; we declare f_bsize to 1, so that we can then report the exact value
@@ -44,10 +39,19 @@ static int efivarfs_statfs(struct dentry *dentry, struct kstatfs *buf)
*/
buf->f_bsize = 1;
buf->f_namelen = NAME_MAX;
- buf->f_blocks = storage_space;
- buf->f_bfree = remaining_space;
buf->f_type = dentry->d_sb->s_magic;
+ /* Some UEFI firmware does not implement QueryVariable() */
+ if (efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) {
+ status = efivar_query_variable_info(attr, &storage_space,
+ &remaining_space,
+ &max_variable_size);
+ if (status == EFI_SUCCESS) {
+ buf->f_blocks = storage_space;
+ buf->f_bfree = remaining_space;
+ }
+ }
+
/*
* In f_bavail we declare the free space that the kernel will allow writing
* when the storage_paranoia x86 quirk is active. To use more, users
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] efivarfs: fix statfs() on efivarfs
2023-09-09 18:08 [PATCH 1/1] efivarfs: fix statfs() on efivarfs Heinrich Schuchardt
@ 2023-09-09 22:30 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2023-09-09 22:30 UTC (permalink / raw)
To: Heinrich Schuchardt, Matthew Garrett, Jeremy Kerr, Ard Biesheuvel
Cc: llvm, oe-kbuild-all, Anisse Astier, linux-efi, linux-kernel,
Heinrich Schuchardt
Hi Heinrich,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.5 next-20230908]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Heinrich-Schuchardt/efivarfs-fix-statfs-on-efivarfs/20230910-020949
base: linus/master
patch link: https://lore.kernel.org/r/20230909180812.10904-1-heinrich.schuchardt%40canonical.com
patch subject: [PATCH 1/1] efivarfs: fix statfs() on efivarfs
config: riscv-randconfig-r003-20230910 (https://download.01.org/0day-ci/archive/20230910/202309100610.zLYrHmqr-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230910/202309100610.zLYrHmqr-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309100610.zLYrHmqr-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/efivarfs/super.c:45:6: warning: variable 'remaining_space' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/efivarfs/super.c:60:6: note: uninitialized use occurs here
if (remaining_space > efivar_reserved_space())
^~~~~~~~~~~~~~~
fs/efivarfs/super.c:45:2: note: remove the 'if' if its condition is always true
if (efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/efivarfs/super.c:32:36: note: initialize the variable 'remaining_space' to silence this warning
u64 storage_space, remaining_space, max_variable_size;
^
= 0
1 warning generated.
vim +45 fs/efivarfs/super.c
26
27 static int efivarfs_statfs(struct dentry *dentry, struct kstatfs *buf)
28 {
29 const u32 attr = EFI_VARIABLE_NON_VOLATILE |
30 EFI_VARIABLE_BOOTSERVICE_ACCESS |
31 EFI_VARIABLE_RUNTIME_ACCESS;
32 u64 storage_space, remaining_space, max_variable_size;
33 efi_status_t status;
34
35 /*
36 * This is not a normal filesystem, so no point in pretending it has a block
37 * size; we declare f_bsize to 1, so that we can then report the exact value
38 * sent by EFI QueryVariableInfo in f_blocks and f_bfree
39 */
40 buf->f_bsize = 1;
41 buf->f_namelen = NAME_MAX;
42 buf->f_type = dentry->d_sb->s_magic;
43
44 /* Some UEFI firmware does not implement QueryVariable() */
> 45 if (efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO)) {
46 status = efivar_query_variable_info(attr, &storage_space,
47 &remaining_space,
48 &max_variable_size);
49 if (status == EFI_SUCCESS) {
50 buf->f_blocks = storage_space;
51 buf->f_bfree = remaining_space;
52 }
53 }
54
55 /*
56 * In f_bavail we declare the free space that the kernel will allow writing
57 * when the storage_paranoia x86 quirk is active. To use more, users
58 * should boot the kernel with efi_no_storage_paranoia.
59 */
60 if (remaining_space > efivar_reserved_space())
61 buf->f_bavail = remaining_space - efivar_reserved_space();
62 else
63 buf->f_bavail = 0;
64
65 return 0;
66 }
67 static const struct super_operations efivarfs_ops = {
68 .statfs = efivarfs_statfs,
69 .drop_inode = generic_delete_inode,
70 .evict_inode = efivarfs_evict_inode,
71 };
72
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-09 22:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-09 18:08 [PATCH 1/1] efivarfs: fix statfs() on efivarfs Heinrich Schuchardt
2023-09-09 22:30 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).