[PATCH] regulator: qcom_smd: fix for_each_child.cocci warnings
by Julia Lawall
From: kernel test robot <lkp(a)intel.com>
drivers/regulator/qcom_smd-regulator.c:1318:1-33: WARNING: Function "for_each_available_child_of_node" should have of_node_put() before return around line 1321.
Semantic patch information:
False positives can be due to function calls within the for_each
loop that may encapsulate an of_node_put.
Generated by: scripts/coccinelle/iterators/for_each_child.cocci
Fixes: 14e2976fbabd ("regulator: qcom_smd: Align probe function with rpmh-regulator")
CC: Konrad Dybcio <konrad.dybcio(a)somainline.org>
Reported-by: kernel test robot <lkp(a)intel.com>
Signed-off-by: kernel test robot <lkp(a)intel.com>
Signed-off-by: Julia Lawall <julia.lawall(a)inria.fr>
---
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 112450df61b7373529b0fe4c122ad13b89d80a8a
commit: 14e2976fbabdacb01335d7f91eeebbc89c67ddb1 regulator: qcom_smd: Align probe function with rpmh-regulator
:::::: branch date: 13 hours ago
:::::: commit date: 9 days ago
qcom_smd-regulator.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -1317,8 +1317,10 @@ static int rpm_reg_probe(struct platform
for_each_available_child_of_node(dev->of_node, node) {
vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
- if (!vreg)
+ if (!vreg) {
+ of_node_put(node);
return -ENOMEM;
+ }
ret = rpm_regulator_init_vreg(vreg, dev, node, rpm, vreg_data);
7 months, 4 weeks
[kees:for-next/memcpy 9/9] include/linux/fortify-string.h:324:4: warning: call to __read_overflow2_field declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()?
by kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/memcpy
head: 6303361147fc8984dd259b54c189592cd0551ab6
commit: 6303361147fc8984dd259b54c189592cd0551ab6 [9/9] fortify: Work around Clang inlining bugs
config: arm-randconfig-c002-20220124 (https://download.01.org/0day-ci/archive/20220125/202201251831.4t5TPp18-lk...)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id...
git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
git fetch --no-tags kees for-next/memcpy
git checkout 6303361147fc8984dd259b54c189592cd0551ab6
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/net/wireless/ath/ath9k/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
In file included from drivers/net/wireless/ath/ath9k/xmit.c:17:
In file included from include/linux/dma-mapping.h:6:
In file included from include/linux/string.h:253:
>> include/linux/fortify-string.h:324:4: warning: call to __read_overflow2_field declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
__read_overflow2_field(q_size_field, size);
^
>> include/linux/fortify-string.h:324:4: warning: call to __read_overflow2_field declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
2 warnings generated.
vim +/warning +324 include/linux/fortify-string.h
6f6f253efa1346 Kees Cook 2021-06-16 255
6f6f253efa1346 Kees Cook 2021-06-16 256 /*
6f6f253efa1346 Kees Cook 2021-06-16 257 * __builtin_object_size() must be captured here to avoid evaluating argument
6f6f253efa1346 Kees Cook 2021-06-16 258 * side-effects further into the macro layers.
6f6f253efa1346 Kees Cook 2021-06-16 259 */
6f6f253efa1346 Kees Cook 2021-06-16 260 #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
6f6f253efa1346 Kees Cook 2021-06-16 261 __builtin_object_size(p, 0), __builtin_object_size(p, 1))
a28a6e860c6cf2 Francis Laniel 2021-02-25 262
602670289b69b2 Kees Cook 2021-04-20 263 /*
602670289b69b2 Kees Cook 2021-04-20 264 * To make sure the compiler can enforce protection against buffer overflows,
602670289b69b2 Kees Cook 2021-04-20 265 * memcpy(), memmove(), and memset() must not be used beyond individual
602670289b69b2 Kees Cook 2021-04-20 266 * struct members. If you need to copy across multiple members, please use
602670289b69b2 Kees Cook 2021-04-20 267 * struct_group() to create a named mirror of an anonymous struct union.
602670289b69b2 Kees Cook 2021-04-20 268 * (e.g. see struct sk_buff.)
602670289b69b2 Kees Cook 2021-04-20 269 *
602670289b69b2 Kees Cook 2021-04-20 270 * Mitigation coverage
602670289b69b2 Kees Cook 2021-04-20 271 * Bounds checking at:
602670289b69b2 Kees Cook 2021-04-20 272 * +-------+-------+-------+-------+
602670289b69b2 Kees Cook 2021-04-20 273 * | Compile time | Run time |
602670289b69b2 Kees Cook 2021-04-20 274 * memcpy() argument sizes: | write | read | write | read |
602670289b69b2 Kees Cook 2021-04-20 275 * +-------+-------+-------+-------+
602670289b69b2 Kees Cook 2021-04-20 276 * memcpy(known, known, constant) | y | y | n/a | n/a |
602670289b69b2 Kees Cook 2021-04-20 277 * memcpy(unknown, known, constant) | n | y | V | n/a |
602670289b69b2 Kees Cook 2021-04-20 278 * memcpy(known, unknown, constant) | y | n | n/a | V |
602670289b69b2 Kees Cook 2021-04-20 279 * memcpy(unknown, unknown, constant) | n | n | V | V |
602670289b69b2 Kees Cook 2021-04-20 280 * memcpy(known, known, dynamic) | n | n | b | B |
602670289b69b2 Kees Cook 2021-04-20 281 * memcpy(unknown, known, dynamic) | n | n | V | B |
602670289b69b2 Kees Cook 2021-04-20 282 * memcpy(known, unknown, dynamic) | n | n | b | V |
602670289b69b2 Kees Cook 2021-04-20 283 * memcpy(unknown, unknown, dynamic) | n | n | V | V |
602670289b69b2 Kees Cook 2021-04-20 284 * +-------+-------+-------+-------+
602670289b69b2 Kees Cook 2021-04-20 285 *
602670289b69b2 Kees Cook 2021-04-20 286 * y = deterministic compile-time bounds checking
602670289b69b2 Kees Cook 2021-04-20 287 * n = cannot do deterministic compile-time bounds checking
602670289b69b2 Kees Cook 2021-04-20 288 * n/a = no run-time bounds checking needed since compile-time deterministic
602670289b69b2 Kees Cook 2021-04-20 289 * b = perform run-time bounds checking
602670289b69b2 Kees Cook 2021-04-20 290 * B = can perform run-time bounds checking, but current unenforced
602670289b69b2 Kees Cook 2021-04-20 291 * V = vulnerable to run-time overflow
602670289b69b2 Kees Cook 2021-04-20 292 *
602670289b69b2 Kees Cook 2021-04-20 293 */
602670289b69b2 Kees Cook 2021-04-20 294 __FORTIFY_INLINE void fortify_memcpy_chk(__kernel_size_t size,
602670289b69b2 Kees Cook 2021-04-20 295 const size_t p_size,
602670289b69b2 Kees Cook 2021-04-20 296 const size_t q_size,
602670289b69b2 Kees Cook 2021-04-20 297 const size_t p_size_field,
602670289b69b2 Kees Cook 2021-04-20 298 const size_t q_size_field,
602670289b69b2 Kees Cook 2021-04-20 299 const char *func)
a28a6e860c6cf2 Francis Laniel 2021-02-25 300 {
a28a6e860c6cf2 Francis Laniel 2021-02-25 301 if (__builtin_constant_p(size)) {
602670289b69b2 Kees Cook 2021-04-20 302 /*
602670289b69b2 Kees Cook 2021-04-20 303 * Length argument is a constant expression, so we
602670289b69b2 Kees Cook 2021-04-20 304 * can perform compile-time bounds checking where
602670289b69b2 Kees Cook 2021-04-20 305 * buffer sizes are known.
602670289b69b2 Kees Cook 2021-04-20 306 */
602670289b69b2 Kees Cook 2021-04-20 307
602670289b69b2 Kees Cook 2021-04-20 308 /* Error when size is larger than enclosing struct. */
602670289b69b2 Kees Cook 2021-04-20 309 if (p_size > p_size_field && p_size < size)
a28a6e860c6cf2 Francis Laniel 2021-02-25 310 __write_overflow();
602670289b69b2 Kees Cook 2021-04-20 311 if (q_size > q_size_field && q_size < size)
a28a6e860c6cf2 Francis Laniel 2021-02-25 312 __read_overflow2();
602670289b69b2 Kees Cook 2021-04-20 313
602670289b69b2 Kees Cook 2021-04-20 314 /* Warn when write size argument larger than dest field. */
602670289b69b2 Kees Cook 2021-04-20 315 if (p_size_field < size)
602670289b69b2 Kees Cook 2021-04-20 316 __write_overflow_field(p_size_field, size);
602670289b69b2 Kees Cook 2021-04-20 317 /*
602670289b69b2 Kees Cook 2021-04-20 318 * Warn for source field over-read when building with W=1
602670289b69b2 Kees Cook 2021-04-20 319 * or when an over-write happened, so both can be fixed at
602670289b69b2 Kees Cook 2021-04-20 320 * the same time.
602670289b69b2 Kees Cook 2021-04-20 321 */
602670289b69b2 Kees Cook 2021-04-20 322 if ((IS_ENABLED(KBUILD_EXTRA_WARN1) || p_size_field < size) &&
602670289b69b2 Kees Cook 2021-04-20 323 q_size_field < size)
602670289b69b2 Kees Cook 2021-04-20 @324 __read_overflow2_field(q_size_field, size);
a28a6e860c6cf2 Francis Laniel 2021-02-25 325 }
602670289b69b2 Kees Cook 2021-04-20 326 /*
602670289b69b2 Kees Cook 2021-04-20 327 * At this point, length argument may not be a constant expression,
602670289b69b2 Kees Cook 2021-04-20 328 * so run-time bounds checking can be done where buffer sizes are
602670289b69b2 Kees Cook 2021-04-20 329 * known. (This is not an "else" because the above checks may only
602670289b69b2 Kees Cook 2021-04-20 330 * be compile-time warnings, and we want to still warn for run-time
602670289b69b2 Kees Cook 2021-04-20 331 * overflows.)
602670289b69b2 Kees Cook 2021-04-20 332 */
602670289b69b2 Kees Cook 2021-04-20 333
602670289b69b2 Kees Cook 2021-04-20 334 /*
602670289b69b2 Kees Cook 2021-04-20 335 * Always stop accesses beyond the struct that contains the
602670289b69b2 Kees Cook 2021-04-20 336 * field, when the buffer's remaining size is known.
602670289b69b2 Kees Cook 2021-04-20 337 * (The -1 test is to optimize away checks where the buffer
602670289b69b2 Kees Cook 2021-04-20 338 * lengths are unknown.)
602670289b69b2 Kees Cook 2021-04-20 339 */
602670289b69b2 Kees Cook 2021-04-20 340 if ((p_size != (size_t)(-1) && p_size < size) ||
602670289b69b2 Kees Cook 2021-04-20 341 (q_size != (size_t)(-1) && q_size < size))
602670289b69b2 Kees Cook 2021-04-20 342 fortify_panic(func);
a28a6e860c6cf2 Francis Laniel 2021-02-25 343 }
a28a6e860c6cf2 Francis Laniel 2021-02-25 344
:::::: The code at line 324 was first introduced by commit
:::::: 602670289b69b2fded3a0b2240c4877e3a015ac6 fortify: Detect struct member overflows in memcpy() at compile-time
:::::: TO: Kees Cook <keescook(a)chromium.org>
:::::: CC: Kees Cook <keescook(a)chromium.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
7 months, 4 weeks
arch/powerpc/kernel/time.c:846:9: sparse: sparse: incorrect type in initializer (different address spaces)
by kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dd81e1c7d5fb126e5fbc5c9e334d7b3ec29a16a0
commit: 4ebbd075bcde7884e078d4360510b989f559bfec KVM: PPC: Book3S HV P9: Use host timer accounting to avoid decrementer read
date: 9 weeks ago
config: powerpc64-randconfig-s031-20220125 (https://download.01.org/0day-ci/archive/20220125/202201251708.BOnUdbSj-lk...)
compiler: powerpc64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit...
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 4ebbd075bcde7884e078d4360510b989f559bfec
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=powerpc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
sparse warnings: (new ones prefixed by >>)
arch/powerpc/kernel/time.c:90:5: sparse: sparse: symbol 'decrementer_max' was not declared. Should it be static?
>> arch/powerpc/kernel/time.c:846:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:846:9: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:846:9: sparse: got unsigned long long *
>> arch/powerpc/kernel/time.c:846:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:846:9: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:846:9: sparse: got unsigned long long *
>> arch/powerpc/kernel/time.c:846:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:846:9: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:846:9: sparse: got unsigned long long *
>> arch/powerpc/kernel/time.c:846:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:846:9: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:846:9: sparse: got unsigned long long *
>> arch/powerpc/kernel/time.c:846:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:846:9: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:846:9: sparse: got unsigned long long *
arch/powerpc/kernel/time.c:626:24: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:626:24: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:626:24: sparse: got unsigned long long *
arch/powerpc/kernel/time.c:557:24: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got unsigned long long * @@
arch/powerpc/kernel/time.c:557:24: sparse: expected void const [noderef] __percpu *__vpp_verify
arch/powerpc/kernel/time.c:557:24: sparse: got unsigned long long *
vim +846 arch/powerpc/kernel/time.c
4a4cfe3836916e1 Tony Breeds 2007-09-22 842
d831d0b83f20588 Tony Breeds 2007-09-21 843 static int decrementer_set_next_event(unsigned long evt,
d831d0b83f20588 Tony Breeds 2007-09-21 844 struct clock_event_device *dev)
d831d0b83f20588 Tony Breeds 2007-09-21 845 {
6601ec1c2ba9294 Christophe Leroy 2020-09-29 @846 __this_cpu_write(decrementers_next_tb, get_tb() + evt);
d831d0b83f20588 Tony Breeds 2007-09-21 847 set_dec(evt);
0215f7d8c53fb19 Benjamin Herrenschmidt 2014-01-14 848
0215f7d8c53fb19 Benjamin Herrenschmidt 2014-01-14 849 /* We may have raced with new irq work */
0215f7d8c53fb19 Benjamin Herrenschmidt 2014-01-14 850 if (test_irq_work_pending())
0215f7d8c53fb19 Benjamin Herrenschmidt 2014-01-14 851 set_dec(1);
0215f7d8c53fb19 Benjamin Herrenschmidt 2014-01-14 852
d831d0b83f20588 Tony Breeds 2007-09-21 853 return 0;
d831d0b83f20588 Tony Breeds 2007-09-21 854 }
d831d0b83f20588 Tony Breeds 2007-09-21 855
:::::: The code at line 846 was first introduced by commit
:::::: 6601ec1c2ba929430f5585ce7f9d9960b0e0a01d powerpc: Remove get_tb_or_rtc()
:::::: TO: Christophe Leroy <christophe.leroy(a)csgroup.eu>
:::::: CC: Michael Ellerman <mpe(a)ellerman.id.au>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
7 months, 4 weeks
Re: [PATCH 06/10] staging: r8188eu: remove DBG_88E calls from os_dep/ioctl_linux.c
by kernel test robot
Hi Phillip,
I love your patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.17-rc1 next-20220124]
[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]
url: https://github.com/0day-ci/linux/commits/Phillip-Potter/Cleanup-and-remov...
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git fa783154524a71ab74e293cd8251155e5971952b
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220125/202201251730.AgK9qxSH-lk...)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1724ade2c1f2fa95e0e314ed9229700d6...
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Phillip-Potter/Cleanup-and-removal-of-DBG_88E-macro/20220125-125206
git checkout 1724ade2c1f2fa95e0e314ed9229700d6158fbbc
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/staging/r8188eu/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/r8188eu/os_dep/ioctl_linux.c: In function 'rtw_wx_set_mlme':
>> drivers/staging/r8188eu/os_dep/ioctl_linux.c:1022:13: warning: variable 'reason' set but not used [-Wunused-but-set-variable]
1022 | u16 reason;
| ^~~~~~
vim +/reason +1022 drivers/staging/r8188eu/os_dep/ioctl_linux.c
2b42bd58b32155 Phillip Potter 2021-07-28 1016
2b42bd58b32155 Phillip Potter 2021-07-28 1017 static int rtw_wx_set_mlme(struct net_device *dev,
2b42bd58b32155 Phillip Potter 2021-07-28 1018 struct iw_request_info *info,
2b42bd58b32155 Phillip Potter 2021-07-28 1019 union iwreq_data *wrqu, char *extra)
2b42bd58b32155 Phillip Potter 2021-07-28 1020 {
2b42bd58b32155 Phillip Potter 2021-07-28 1021 int ret = 0;
2b42bd58b32155 Phillip Potter 2021-07-28 @1022 u16 reason;
2b42bd58b32155 Phillip Potter 2021-07-28 1023 struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
2b42bd58b32155 Phillip Potter 2021-07-28 1024 struct iw_mlme *mlme = (struct iw_mlme *)extra;
2b42bd58b32155 Phillip Potter 2021-07-28 1025
d8062f6adca1ef Michael Straube 2021-07-30 1026 if (!mlme)
2b42bd58b32155 Phillip Potter 2021-07-28 1027 return -1;
2b42bd58b32155 Phillip Potter 2021-07-28 1028
2b42bd58b32155 Phillip Potter 2021-07-28 1029 reason = mlme->reason_code;
2b42bd58b32155 Phillip Potter 2021-07-28 1030
2b42bd58b32155 Phillip Potter 2021-07-28 1031 switch (mlme->cmd) {
2b42bd58b32155 Phillip Potter 2021-07-28 1032 case IW_MLME_DEAUTH:
2b42bd58b32155 Phillip Potter 2021-07-28 1033 if (!rtw_set_802_11_disassociate(padapter))
2b42bd58b32155 Phillip Potter 2021-07-28 1034 ret = -1;
2b42bd58b32155 Phillip Potter 2021-07-28 1035 break;
2b42bd58b32155 Phillip Potter 2021-07-28 1036 case IW_MLME_DISASSOC:
2b42bd58b32155 Phillip Potter 2021-07-28 1037 if (!rtw_set_802_11_disassociate(padapter))
2b42bd58b32155 Phillip Potter 2021-07-28 1038 ret = -1;
2b42bd58b32155 Phillip Potter 2021-07-28 1039 break;
2b42bd58b32155 Phillip Potter 2021-07-28 1040 default:
2b42bd58b32155 Phillip Potter 2021-07-28 1041 return -EOPNOTSUPP;
2b42bd58b32155 Phillip Potter 2021-07-28 1042 }
2b42bd58b32155 Phillip Potter 2021-07-28 1043 return ret;
2b42bd58b32155 Phillip Potter 2021-07-28 1044 }
2b42bd58b32155 Phillip Potter 2021-07-28 1045
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
7 months, 4 weeks
[kbuild] [allisonhenderson-xfs-work:delayed_attrs_v26_extended 28/30] fs/xfs/xfs_ioctl.c:1753 xfs_ioc_get_parent_pointer() warn: maybe return -EFAULT instead of the bytes remaining?
by Dan Carpenter
tree: https://github.com/allisonhenderson/xfs_work.git delayed_attrs_v26_extended
head: 19459f5cfa422b0a6a9cd3898892e43ecb49f8f3
commit: 38f492d29e0c25066170d87572b7ade7bf2af72b [28/30] xfs: Add parent pointer ioctl
config: nios2-randconfig-m031-20220124 (https://download.01.org/0day-ci/archive/20220125/202201250715.EbP8D1XT-lk... )
compiler: nios2-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
New smatch warnings:
fs/xfs/xfs_ioctl.c:1753 xfs_ioc_get_parent_pointer() warn: maybe return -EFAULT instead of the bytes remaining?
Old smatch warnings:
arch/nios2/include/asm/thread_info.h:71 current_thread_info() error: uninitialized symbol 'sp'.
vim +1753 fs/xfs/xfs_ioctl.c
38f492d29e0c25 Allison Henderson 2021-07-23 1686 STATIC int
38f492d29e0c25 Allison Henderson 2021-07-23 1687 xfs_ioc_get_parent_pointer(
38f492d29e0c25 Allison Henderson 2021-07-23 1688 struct file *filp,
38f492d29e0c25 Allison Henderson 2021-07-23 1689 void __user *arg)
38f492d29e0c25 Allison Henderson 2021-07-23 1690 {
38f492d29e0c25 Allison Henderson 2021-07-23 1691 struct xfs_pptr_info *ppi = NULL;
38f492d29e0c25 Allison Henderson 2021-07-23 1692 int error = 0;
38f492d29e0c25 Allison Henderson 2021-07-23 1693 struct xfs_inode *ip = XFS_I(file_inode(filp));
38f492d29e0c25 Allison Henderson 2021-07-23 1694 struct xfs_mount *mp = ip->i_mount;
38f492d29e0c25 Allison Henderson 2021-07-23 1695
38f492d29e0c25 Allison Henderson 2021-07-23 1696 if (!capable(CAP_SYS_ADMIN))
38f492d29e0c25 Allison Henderson 2021-07-23 1697 return -EPERM;
38f492d29e0c25 Allison Henderson 2021-07-23 1698
38f492d29e0c25 Allison Henderson 2021-07-23 1699 /* Allocate an xfs_pptr_info to put the user data */
38f492d29e0c25 Allison Henderson 2021-07-23 1700 ppi = kmem_alloc(sizeof(struct xfs_pptr_info), 0);
38f492d29e0c25 Allison Henderson 2021-07-23 1701 if (!ppi)
38f492d29e0c25 Allison Henderson 2021-07-23 1702 return -ENOMEM;
38f492d29e0c25 Allison Henderson 2021-07-23 1703
38f492d29e0c25 Allison Henderson 2021-07-23 1704 /* Copy the data from the user */
38f492d29e0c25 Allison Henderson 2021-07-23 1705 error = copy_from_user(ppi, arg, sizeof(struct xfs_pptr_info));
38f492d29e0c25 Allison Henderson 2021-07-23 1706 if (error)
38f492d29e0c25 Allison Henderson 2021-07-23 1707 goto out;
38f492d29e0c25 Allison Henderson 2021-07-23 1708
38f492d29e0c25 Allison Henderson 2021-07-23 1709 /* Check size of buffer requested by user */
38f492d29e0c25 Allison Henderson 2021-07-23 1710 if (XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size) > XFS_XATTR_LIST_MAX) {
38f492d29e0c25 Allison Henderson 2021-07-23 1711 error = -ENOMEM;
38f492d29e0c25 Allison Henderson 2021-07-23 1712 goto out;
38f492d29e0c25 Allison Henderson 2021-07-23 1713 }
38f492d29e0c25 Allison Henderson 2021-07-23 1714
38f492d29e0c25 Allison Henderson 2021-07-23 1715 /*
38f492d29e0c25 Allison Henderson 2021-07-23 1716 * Now that we know how big the trailing buffer is, expand
38f492d29e0c25 Allison Henderson 2021-07-23 1717 * our kernel xfs_pptr_info to be the same size
38f492d29e0c25 Allison Henderson 2021-07-23 1718 */
38f492d29e0c25 Allison Henderson 2021-07-23 1719 ppi = krealloc(ppi, XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size),
38f492d29e0c25 Allison Henderson 2021-07-23 1720 GFP_NOFS | __GFP_NOFAIL);
38f492d29e0c25 Allison Henderson 2021-07-23 1721 if (!ppi)
38f492d29e0c25 Allison Henderson 2021-07-23 1722 return -ENOMEM;
38f492d29e0c25 Allison Henderson 2021-07-23 1723
38f492d29e0c25 Allison Henderson 2021-07-23 1724 if (ppi->pi_flags != 0 && ppi->pi_flags != XFS_PPTR_IFLAG_HANDLE) {
38f492d29e0c25 Allison Henderson 2021-07-23 1725 error = -EINVAL;
38f492d29e0c25 Allison Henderson 2021-07-23 1726 goto out;
38f492d29e0c25 Allison Henderson 2021-07-23 1727 }
38f492d29e0c25 Allison Henderson 2021-07-23 1728
38f492d29e0c25 Allison Henderson 2021-07-23 1729 if (ppi->pi_flags == XFS_PPTR_IFLAG_HANDLE) {
38f492d29e0c25 Allison Henderson 2021-07-23 1730 error = xfs_iget(mp, NULL, ppi->pi_handle.ha_fid.fid_ino,
38f492d29e0c25 Allison Henderson 2021-07-23 1731 0, 0, &ip);
38f492d29e0c25 Allison Henderson 2021-07-23 1732 if (error)
38f492d29e0c25 Allison Henderson 2021-07-23 1733 goto out;
38f492d29e0c25 Allison Henderson 2021-07-23 1734 }
38f492d29e0c25 Allison Henderson 2021-07-23 1735
38f492d29e0c25 Allison Henderson 2021-07-23 1736 if (ip->i_ino == mp->m_sb.sb_rootino)
38f492d29e0c25 Allison Henderson 2021-07-23 1737 ppi->pi_flags |= XFS_PPTR_OFLAG_ROOT;
38f492d29e0c25 Allison Henderson 2021-07-23 1738
38f492d29e0c25 Allison Henderson 2021-07-23 1739 /* Get the parent pointers */
38f492d29e0c25 Allison Henderson 2021-07-23 1740 error = xfs_attr_get_parent_pointer(ip, ppi);
38f492d29e0c25 Allison Henderson 2021-07-23 1741
38f492d29e0c25 Allison Henderson 2021-07-23 1742 if (error)
38f492d29e0c25 Allison Henderson 2021-07-23 1743 goto out;
38f492d29e0c25 Allison Henderson 2021-07-23 1744
38f492d29e0c25 Allison Henderson 2021-07-23 1745 /* Copy the parent pointers back to the user */
38f492d29e0c25 Allison Henderson 2021-07-23 1746 error = copy_to_user(arg, ppi,
38f492d29e0c25 Allison Henderson 2021-07-23 1747 XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size));
38f492d29e0c25 Allison Henderson 2021-07-23 1748 if (error)
38f492d29e0c25 Allison Henderson 2021-07-23 1749 goto out;
This should be
if (copy_to_user(arg, ppi, XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size))) {
err = -EFAULT;
goto out;
}
38f492d29e0c25 Allison Henderson 2021-07-23 1750
38f492d29e0c25 Allison Henderson 2021-07-23 1751 out:
38f492d29e0c25 Allison Henderson 2021-07-23 1752 kmem_free(ppi);
38f492d29e0c25 Allison Henderson 2021-07-23 @1753 return error;
38f492d29e0c25 Allison Henderson 2021-07-23 1754 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org
7 months, 4 weeks
[intel-tdx:kvm-upstream-workaround 155/162] arch/x86/kvm/mmu/tdp_mmu.c:774:32: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first
by kernel test robot
tree: https://github.com/intel/tdx.git kvm-upstream-workaround
head: 9ba9d8e36b0fa25f5f20109a0ae61619a421f550
commit: 6d8632a26d7060510bfe4fbb3011c2d6e2d2f079 [155/162] KVM, x86/tdp_mmu: optimize remote tlb flush
config: x86_64-randconfig-a015-20220124 (https://download.01.org/0day-ci/archive/20220125/202201251603.34lAUK9o-lk...)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel/tdx/commit/6d8632a26d7060510bfe4fbb3011c2d6e2d2f079
git remote add intel-tdx https://github.com/intel/tdx.git
git fetch --no-tags intel-tdx kvm-upstream-workaround
git checkout 6d8632a26d7060510bfe4fbb3011c2d6e2d2f079
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/kvm/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
>> arch/x86/kvm/mmu/tdp_mmu.c:774:32: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses]
is_large_pte(iter->old_spte) ? PT_PAGE_SIZE_MASK : 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
arch/x86/kvm/mmu/tdp_mmu.c:774:32: note: place parentheses around the '|' expression to silence this warning
is_large_pte(iter->old_spte) ? PT_PAGE_SIZE_MASK : 0;
^
)
arch/x86/kvm/mmu/tdp_mmu.c:774:32: note: place parentheses around the '?:' expression to evaluate it first
is_large_pte(iter->old_spte) ? PT_PAGE_SIZE_MASK : 0;
^
( )
1 warning generated.
vim +774 arch/x86/kvm/mmu/tdp_mmu.c
745
746 #define tdp_root_for_each_pte(_iter, _root, _start, _end) \
747 for_each_tdp_pte(_iter, _root->spt, _root->role.level, _start, _end)
748
749 /*
750 * Note temporarily blocked private SPTE is consider as valid leaf,
751 * although !is_shadow_present_pte() returns true for it, since the
752 * target page (which the mapping maps to ) is still there.
753 */
754 #define tdp_root_for_each_leaf_pte(_iter, _root, _start, _end) \
755 tdp_root_for_each_pte(_iter, _root, _start, _end) \
756 if ((!is_shadow_present_pte(_iter.old_spte) && \
757 !is_zapped_private_pte(_iter.old_spte)) || \
758 !is_last_spte(_iter.old_spte, _iter.level)) \
759 continue; \
760 else
761
762 #define tdp_mmu_for_each_pte(_iter, _mmu, _private, _start, _end) \
763 for_each_tdp_pte(_iter, \
764 __va((_private) ? _mmu->private_root_hpa : _mmu->root_hpa), \
765 _mmu->shadow_root_level, _start, _end)
766
767 static u64 zapped_private_spte(struct kvm *kvm, const struct tdp_iter *iter)
768 {
769 if (!kvm_gfn_stolen_mask(kvm))
770 return shadow_init_value;
771
772 return shadow_init_value | SPTE_PRIVATE_ZAPPED |
773 (spte_to_pfn(iter->old_spte) << PAGE_SHIFT) |
> 774 is_large_pte(iter->old_spte) ? PT_PAGE_SIZE_MASK : 0;
775 }
776
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
7 months, 4 weeks
Re: [PATCH 04/10] staging: r8188eu: remove all DBG_88E calls from hal dir
by kernel test robot
Hi Phillip,
I love your patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v5.17-rc1 next-20220124]
[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]
url: https://github.com/0day-ci/linux/commits/Phillip-Potter/Cleanup-and-remov...
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git fa783154524a71ab74e293cd8251155e5971952b
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220125/202201251642.5tYQO4Fb-lk...)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/041fe115dad9245f83646e7674341f280...
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Phillip-Potter/Cleanup-and-removal-of-DBG_88E-macro/20220125-125206
git checkout 041fe115dad9245f83646e7674341f28094d62a5
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/staging/r8188eu/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/r8188eu/hal/rtl8188e_cmd.c: In function 'rtl8188e_set_FwMediaStatus_cmd':
>> drivers/staging/r8188eu/hal/rtl8188e_cmd.c:195:20: warning: variable 'macid' set but not used [-Wunused-but-set-variable]
195 | u8 opmode, macid;
| ^~~~~
>> drivers/staging/r8188eu/hal/rtl8188e_cmd.c:195:12: warning: variable 'opmode' set but not used [-Wunused-but-set-variable]
195 | u8 opmode, macid;
| ^~~~~~
vim +/macid +195 drivers/staging/r8188eu/hal/rtl8188e_cmd.c
8cd574e6af5463 Phillip Potter 2021-07-28 192
8cd574e6af5463 Phillip Potter 2021-07-28 193 void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt)
8cd574e6af5463 Phillip Potter 2021-07-28 194 {
8cd574e6af5463 Phillip Potter 2021-07-28 @195 u8 opmode, macid;
8cd574e6af5463 Phillip Potter 2021-07-28 196 u16 mst_rpt = le16_to_cpu(mstatus_rpt);
8cd574e6af5463 Phillip Potter 2021-07-28 197 opmode = (u8)mst_rpt;
8cd574e6af5463 Phillip Potter 2021-07-28 198 macid = (u8)(mst_rpt >> 8);
8cd574e6af5463 Phillip Potter 2021-07-28 199
8cd574e6af5463 Phillip Potter 2021-07-28 200 FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt);
8cd574e6af5463 Phillip Potter 2021-07-28 201 }
8cd574e6af5463 Phillip Potter 2021-07-28 202
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
7 months, 4 weeks
fs/ntfs3/fsntfs.c:2248:41: warning: taking address of packed member 'de' of class or structure 'NTFS_DE_SII' may result in an unaligned pointer value
by kernel test robot
Hi Konstantin,
FYI, the error/warning still remains.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: dd81e1c7d5fb126e5fbc5c9e334d7b3ec29a16a0
commit: 6e5be40d32fb1907285277c02e74493ed43d77fe fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile
date: 5 months ago
config: mips-buildonly-randconfig-r001-20220122 (https://download.01.org/0day-ci/archive/20220124/202201242326.uQ3OazUi-lk...)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 7b3d30728816403d1fd73cc5082e9fb761262bce)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit...
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6e5be40d32fb1907285277c02e74493ed43d77fe
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash fs/ntfs3/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
fs/ntfs3/fsntfs.c:1874:9: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
size_t cnt, off;
^
>> fs/ntfs3/fsntfs.c:2248:41: warning: taking address of packed member 'de' of class or structure 'NTFS_DE_SII' may result in an unaligned pointer value [-Waddress-of-packed-member]
err = indx_insert_entry(indx_sii, ni, &sii_e.de, NULL, NULL);
^~~~~~~~
2 warnings generated.
vim +2248 fs/ntfs3/fsntfs.c
82cae269cfa953 Konstantin Komarov 2021-08-13 2075
82cae269cfa953 Konstantin Komarov 2021-08-13 2076 /*
82cae269cfa953 Konstantin Komarov 2021-08-13 2077 * ntfs_insert_security
82cae269cfa953 Konstantin Komarov 2021-08-13 2078 *
82cae269cfa953 Konstantin Komarov 2021-08-13 2079 * inserts security descriptor into $Secure::SDS
82cae269cfa953 Konstantin Komarov 2021-08-13 2080 *
82cae269cfa953 Konstantin Komarov 2021-08-13 2081 * SECURITY Descriptor Stream data is organized into chunks of 256K bytes
82cae269cfa953 Konstantin Komarov 2021-08-13 2082 * and it contains a mirror copy of each security descriptor. When writing
82cae269cfa953 Konstantin Komarov 2021-08-13 2083 * to a security descriptor at location X, another copy will be written at
82cae269cfa953 Konstantin Komarov 2021-08-13 2084 * location (X+256K).
82cae269cfa953 Konstantin Komarov 2021-08-13 2085 * When writing a security descriptor that will cross the 256K boundary,
82cae269cfa953 Konstantin Komarov 2021-08-13 2086 * the pointer will be advanced by 256K to skip
82cae269cfa953 Konstantin Komarov 2021-08-13 2087 * over the mirror portion.
82cae269cfa953 Konstantin Komarov 2021-08-13 2088 */
82cae269cfa953 Konstantin Komarov 2021-08-13 2089 int ntfs_insert_security(struct ntfs_sb_info *sbi,
82cae269cfa953 Konstantin Komarov 2021-08-13 2090 const struct SECURITY_DESCRIPTOR_RELATIVE *sd,
82cae269cfa953 Konstantin Komarov 2021-08-13 2091 u32 size_sd, __le32 *security_id, bool *inserted)
82cae269cfa953 Konstantin Komarov 2021-08-13 2092 {
82cae269cfa953 Konstantin Komarov 2021-08-13 2093 int err, diff;
82cae269cfa953 Konstantin Komarov 2021-08-13 2094 struct ntfs_inode *ni = sbi->security.ni;
82cae269cfa953 Konstantin Komarov 2021-08-13 2095 struct ntfs_index *indx_sdh = &sbi->security.index_sdh;
82cae269cfa953 Konstantin Komarov 2021-08-13 2096 struct ntfs_index *indx_sii = &sbi->security.index_sii;
82cae269cfa953 Konstantin Komarov 2021-08-13 2097 struct NTFS_DE_SDH *e;
82cae269cfa953 Konstantin Komarov 2021-08-13 2098 struct NTFS_DE_SDH sdh_e;
82cae269cfa953 Konstantin Komarov 2021-08-13 2099 struct NTFS_DE_SII sii_e;
82cae269cfa953 Konstantin Komarov 2021-08-13 2100 struct SECURITY_HDR *d_security;
82cae269cfa953 Konstantin Komarov 2021-08-13 2101 u32 new_sec_size = size_sd + SIZEOF_SECURITY_HDR;
82cae269cfa953 Konstantin Komarov 2021-08-13 2102 u32 aligned_sec_size = Quad2Align(new_sec_size);
82cae269cfa953 Konstantin Komarov 2021-08-13 2103 struct SECURITY_KEY hash_key;
82cae269cfa953 Konstantin Komarov 2021-08-13 2104 struct ntfs_fnd *fnd_sdh = NULL;
82cae269cfa953 Konstantin Komarov 2021-08-13 2105 const struct INDEX_ROOT *root_sdh;
82cae269cfa953 Konstantin Komarov 2021-08-13 2106 const struct INDEX_ROOT *root_sii;
82cae269cfa953 Konstantin Komarov 2021-08-13 2107 u64 mirr_off, new_sds_size;
82cae269cfa953 Konstantin Komarov 2021-08-13 2108 u32 next, left;
82cae269cfa953 Konstantin Komarov 2021-08-13 2109
82cae269cfa953 Konstantin Komarov 2021-08-13 2110 static_assert((1 << Log2OfSecurityDescriptorsBlockSize) ==
82cae269cfa953 Konstantin Komarov 2021-08-13 2111 SecurityDescriptorsBlockSize);
82cae269cfa953 Konstantin Komarov 2021-08-13 2112
82cae269cfa953 Konstantin Komarov 2021-08-13 2113 hash_key.hash = security_hash(sd, size_sd);
82cae269cfa953 Konstantin Komarov 2021-08-13 2114 hash_key.sec_id = SECURITY_ID_INVALID;
82cae269cfa953 Konstantin Komarov 2021-08-13 2115
82cae269cfa953 Konstantin Komarov 2021-08-13 2116 if (inserted)
82cae269cfa953 Konstantin Komarov 2021-08-13 2117 *inserted = false;
82cae269cfa953 Konstantin Komarov 2021-08-13 2118 *security_id = SECURITY_ID_INVALID;
82cae269cfa953 Konstantin Komarov 2021-08-13 2119
82cae269cfa953 Konstantin Komarov 2021-08-13 2120 /* Allocate a temporal buffer*/
82cae269cfa953 Konstantin Komarov 2021-08-13 2121 d_security = ntfs_zalloc(aligned_sec_size);
82cae269cfa953 Konstantin Komarov 2021-08-13 2122 if (!d_security)
82cae269cfa953 Konstantin Komarov 2021-08-13 2123 return -ENOMEM;
82cae269cfa953 Konstantin Komarov 2021-08-13 2124
82cae269cfa953 Konstantin Komarov 2021-08-13 2125 mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_SECURITY);
82cae269cfa953 Konstantin Komarov 2021-08-13 2126
82cae269cfa953 Konstantin Komarov 2021-08-13 2127 fnd_sdh = fnd_get();
82cae269cfa953 Konstantin Komarov 2021-08-13 2128 if (!fnd_sdh) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2129 err = -ENOMEM;
82cae269cfa953 Konstantin Komarov 2021-08-13 2130 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2131 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2132
82cae269cfa953 Konstantin Komarov 2021-08-13 2133 root_sdh = indx_get_root(indx_sdh, ni, NULL, NULL);
82cae269cfa953 Konstantin Komarov 2021-08-13 2134 if (!root_sdh) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2135 err = -EINVAL;
82cae269cfa953 Konstantin Komarov 2021-08-13 2136 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2137 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2138
82cae269cfa953 Konstantin Komarov 2021-08-13 2139 root_sii = indx_get_root(indx_sii, ni, NULL, NULL);
82cae269cfa953 Konstantin Komarov 2021-08-13 2140 if (!root_sii) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2141 err = -EINVAL;
82cae269cfa953 Konstantin Komarov 2021-08-13 2142 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2143 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2144
82cae269cfa953 Konstantin Komarov 2021-08-13 2145 /*
82cae269cfa953 Konstantin Komarov 2021-08-13 2146 * Check if such security already exists
82cae269cfa953 Konstantin Komarov 2021-08-13 2147 * use "SDH" and hash -> to get the offset in "SDS"
82cae269cfa953 Konstantin Komarov 2021-08-13 2148 */
82cae269cfa953 Konstantin Komarov 2021-08-13 2149 err = indx_find(indx_sdh, ni, root_sdh, &hash_key, sizeof(hash_key),
82cae269cfa953 Konstantin Komarov 2021-08-13 2150 &d_security->key.sec_id, &diff, (struct NTFS_DE **)&e,
82cae269cfa953 Konstantin Komarov 2021-08-13 2151 fnd_sdh);
82cae269cfa953 Konstantin Komarov 2021-08-13 2152 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2153 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2154
82cae269cfa953 Konstantin Komarov 2021-08-13 2155 while (e) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2156 if (le32_to_cpu(e->sec_hdr.size) == new_sec_size) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2157 err = ntfs_read_run_nb(sbi, &ni->file.run,
82cae269cfa953 Konstantin Komarov 2021-08-13 2158 le64_to_cpu(e->sec_hdr.off),
82cae269cfa953 Konstantin Komarov 2021-08-13 2159 d_security, new_sec_size, NULL);
82cae269cfa953 Konstantin Komarov 2021-08-13 2160 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2161 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2162
82cae269cfa953 Konstantin Komarov 2021-08-13 2163 if (le32_to_cpu(d_security->size) == new_sec_size &&
82cae269cfa953 Konstantin Komarov 2021-08-13 2164 d_security->key.hash == hash_key.hash &&
82cae269cfa953 Konstantin Komarov 2021-08-13 2165 !memcmp(d_security + 1, sd, size_sd)) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2166 *security_id = d_security->key.sec_id;
82cae269cfa953 Konstantin Komarov 2021-08-13 2167 /*such security already exists*/
82cae269cfa953 Konstantin Komarov 2021-08-13 2168 err = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2169 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2170 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2171 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2172
82cae269cfa953 Konstantin Komarov 2021-08-13 2173 err = indx_find_sort(indx_sdh, ni, root_sdh,
82cae269cfa953 Konstantin Komarov 2021-08-13 2174 (struct NTFS_DE **)&e, fnd_sdh);
82cae269cfa953 Konstantin Komarov 2021-08-13 2175 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2176 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2177
82cae269cfa953 Konstantin Komarov 2021-08-13 2178 if (!e || e->key.hash != hash_key.hash)
82cae269cfa953 Konstantin Komarov 2021-08-13 2179 break;
82cae269cfa953 Konstantin Komarov 2021-08-13 2180 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2181
82cae269cfa953 Konstantin Komarov 2021-08-13 2182 /* Zero unused space */
82cae269cfa953 Konstantin Komarov 2021-08-13 2183 next = sbi->security.next_off & (SecurityDescriptorsBlockSize - 1);
82cae269cfa953 Konstantin Komarov 2021-08-13 2184 left = SecurityDescriptorsBlockSize - next;
82cae269cfa953 Konstantin Komarov 2021-08-13 2185
82cae269cfa953 Konstantin Komarov 2021-08-13 2186 /* Zero gap until SecurityDescriptorsBlockSize */
82cae269cfa953 Konstantin Komarov 2021-08-13 2187 if (left < new_sec_size) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2188 /* zero "left" bytes from sbi->security.next_off */
82cae269cfa953 Konstantin Komarov 2021-08-13 2189 sbi->security.next_off += SecurityDescriptorsBlockSize + left;
82cae269cfa953 Konstantin Komarov 2021-08-13 2190 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2191
82cae269cfa953 Konstantin Komarov 2021-08-13 2192 /* Zero tail of previous security */
82cae269cfa953 Konstantin Komarov 2021-08-13 2193 //used = ni->vfs_inode.i_size & (SecurityDescriptorsBlockSize - 1);
82cae269cfa953 Konstantin Komarov 2021-08-13 2194
82cae269cfa953 Konstantin Komarov 2021-08-13 2195 /*
82cae269cfa953 Konstantin Komarov 2021-08-13 2196 * Example:
82cae269cfa953 Konstantin Komarov 2021-08-13 2197 * 0x40438 == ni->vfs_inode.i_size
82cae269cfa953 Konstantin Komarov 2021-08-13 2198 * 0x00440 == sbi->security.next_off
82cae269cfa953 Konstantin Komarov 2021-08-13 2199 * need to zero [0x438-0x440)
82cae269cfa953 Konstantin Komarov 2021-08-13 2200 * if (next > used) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2201 * u32 tozero = next - used;
82cae269cfa953 Konstantin Komarov 2021-08-13 2202 * zero "tozero" bytes from sbi->security.next_off - tozero
82cae269cfa953 Konstantin Komarov 2021-08-13 2203 */
82cae269cfa953 Konstantin Komarov 2021-08-13 2204
82cae269cfa953 Konstantin Komarov 2021-08-13 2205 /* format new security descriptor */
82cae269cfa953 Konstantin Komarov 2021-08-13 2206 d_security->key.hash = hash_key.hash;
82cae269cfa953 Konstantin Komarov 2021-08-13 2207 d_security->key.sec_id = cpu_to_le32(sbi->security.next_id);
82cae269cfa953 Konstantin Komarov 2021-08-13 2208 d_security->off = cpu_to_le64(sbi->security.next_off);
82cae269cfa953 Konstantin Komarov 2021-08-13 2209 d_security->size = cpu_to_le32(new_sec_size);
82cae269cfa953 Konstantin Komarov 2021-08-13 2210 memcpy(d_security + 1, sd, size_sd);
82cae269cfa953 Konstantin Komarov 2021-08-13 2211
82cae269cfa953 Konstantin Komarov 2021-08-13 2212 /* Write main SDS bucket */
82cae269cfa953 Konstantin Komarov 2021-08-13 2213 err = ntfs_sb_write_run(sbi, &ni->file.run, sbi->security.next_off,
82cae269cfa953 Konstantin Komarov 2021-08-13 2214 d_security, aligned_sec_size);
82cae269cfa953 Konstantin Komarov 2021-08-13 2215
82cae269cfa953 Konstantin Komarov 2021-08-13 2216 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2217 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2218
82cae269cfa953 Konstantin Komarov 2021-08-13 2219 mirr_off = sbi->security.next_off + SecurityDescriptorsBlockSize;
82cae269cfa953 Konstantin Komarov 2021-08-13 2220 new_sds_size = mirr_off + aligned_sec_size;
82cae269cfa953 Konstantin Komarov 2021-08-13 2221
82cae269cfa953 Konstantin Komarov 2021-08-13 2222 if (new_sds_size > ni->vfs_inode.i_size) {
82cae269cfa953 Konstantin Komarov 2021-08-13 2223 err = attr_set_size(ni, ATTR_DATA, SDS_NAME,
82cae269cfa953 Konstantin Komarov 2021-08-13 2224 ARRAY_SIZE(SDS_NAME), &ni->file.run,
82cae269cfa953 Konstantin Komarov 2021-08-13 2225 new_sds_size, &new_sds_size, false, NULL);
82cae269cfa953 Konstantin Komarov 2021-08-13 2226 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2227 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2228 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2229
82cae269cfa953 Konstantin Komarov 2021-08-13 2230 /* Write copy SDS bucket */
82cae269cfa953 Konstantin Komarov 2021-08-13 2231 err = ntfs_sb_write_run(sbi, &ni->file.run, mirr_off, d_security,
82cae269cfa953 Konstantin Komarov 2021-08-13 2232 aligned_sec_size);
82cae269cfa953 Konstantin Komarov 2021-08-13 2233 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2234 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2235
82cae269cfa953 Konstantin Komarov 2021-08-13 2236 /* Fill SII entry */
82cae269cfa953 Konstantin Komarov 2021-08-13 2237 sii_e.de.view.data_off =
82cae269cfa953 Konstantin Komarov 2021-08-13 2238 cpu_to_le16(offsetof(struct NTFS_DE_SII, sec_hdr));
82cae269cfa953 Konstantin Komarov 2021-08-13 2239 sii_e.de.view.data_size = cpu_to_le16(SIZEOF_SECURITY_HDR);
82cae269cfa953 Konstantin Komarov 2021-08-13 2240 sii_e.de.view.res = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2241 sii_e.de.size = cpu_to_le16(SIZEOF_SII_DIRENTRY);
82cae269cfa953 Konstantin Komarov 2021-08-13 2242 sii_e.de.key_size = cpu_to_le16(sizeof(d_security->key.sec_id));
82cae269cfa953 Konstantin Komarov 2021-08-13 2243 sii_e.de.flags = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2244 sii_e.de.res = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2245 sii_e.sec_id = d_security->key.sec_id;
82cae269cfa953 Konstantin Komarov 2021-08-13 2246 memcpy(&sii_e.sec_hdr, d_security, SIZEOF_SECURITY_HDR);
82cae269cfa953 Konstantin Komarov 2021-08-13 2247
82cae269cfa953 Konstantin Komarov 2021-08-13 @2248 err = indx_insert_entry(indx_sii, ni, &sii_e.de, NULL, NULL);
82cae269cfa953 Konstantin Komarov 2021-08-13 2249 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2250 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2251
82cae269cfa953 Konstantin Komarov 2021-08-13 2252 /* Fill SDH entry */
82cae269cfa953 Konstantin Komarov 2021-08-13 2253 sdh_e.de.view.data_off =
82cae269cfa953 Konstantin Komarov 2021-08-13 2254 cpu_to_le16(offsetof(struct NTFS_DE_SDH, sec_hdr));
82cae269cfa953 Konstantin Komarov 2021-08-13 2255 sdh_e.de.view.data_size = cpu_to_le16(SIZEOF_SECURITY_HDR);
82cae269cfa953 Konstantin Komarov 2021-08-13 2256 sdh_e.de.view.res = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2257 sdh_e.de.size = cpu_to_le16(SIZEOF_SDH_DIRENTRY);
82cae269cfa953 Konstantin Komarov 2021-08-13 2258 sdh_e.de.key_size = cpu_to_le16(sizeof(sdh_e.key));
82cae269cfa953 Konstantin Komarov 2021-08-13 2259 sdh_e.de.flags = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2260 sdh_e.de.res = 0;
82cae269cfa953 Konstantin Komarov 2021-08-13 2261 sdh_e.key.hash = d_security->key.hash;
82cae269cfa953 Konstantin Komarov 2021-08-13 2262 sdh_e.key.sec_id = d_security->key.sec_id;
82cae269cfa953 Konstantin Komarov 2021-08-13 2263 memcpy(&sdh_e.sec_hdr, d_security, SIZEOF_SECURITY_HDR);
82cae269cfa953 Konstantin Komarov 2021-08-13 2264 sdh_e.magic[0] = cpu_to_le16('I');
82cae269cfa953 Konstantin Komarov 2021-08-13 2265 sdh_e.magic[1] = cpu_to_le16('I');
82cae269cfa953 Konstantin Komarov 2021-08-13 2266
82cae269cfa953 Konstantin Komarov 2021-08-13 2267 fnd_clear(fnd_sdh);
82cae269cfa953 Konstantin Komarov 2021-08-13 2268 err = indx_insert_entry(indx_sdh, ni, &sdh_e.de, (void *)(size_t)1,
82cae269cfa953 Konstantin Komarov 2021-08-13 2269 fnd_sdh);
82cae269cfa953 Konstantin Komarov 2021-08-13 2270 if (err)
82cae269cfa953 Konstantin Komarov 2021-08-13 2271 goto out;
82cae269cfa953 Konstantin Komarov 2021-08-13 2272
82cae269cfa953 Konstantin Komarov 2021-08-13 2273 *security_id = d_security->key.sec_id;
82cae269cfa953 Konstantin Komarov 2021-08-13 2274 if (inserted)
82cae269cfa953 Konstantin Komarov 2021-08-13 2275 *inserted = true;
82cae269cfa953 Konstantin Komarov 2021-08-13 2276
82cae269cfa953 Konstantin Komarov 2021-08-13 2277 /* Update Id and offset for next descriptor */
82cae269cfa953 Konstantin Komarov 2021-08-13 2278 sbi->security.next_id += 1;
82cae269cfa953 Konstantin Komarov 2021-08-13 2279 sbi->security.next_off += aligned_sec_size;
82cae269cfa953 Konstantin Komarov 2021-08-13 2280
82cae269cfa953 Konstantin Komarov 2021-08-13 2281 out:
82cae269cfa953 Konstantin Komarov 2021-08-13 2282 fnd_put(fnd_sdh);
82cae269cfa953 Konstantin Komarov 2021-08-13 2283 mark_inode_dirty(&ni->vfs_inode);
82cae269cfa953 Konstantin Komarov 2021-08-13 2284 ni_unlock(ni);
82cae269cfa953 Konstantin Komarov 2021-08-13 2285 ntfs_free(d_security);
82cae269cfa953 Konstantin Komarov 2021-08-13 2286
82cae269cfa953 Konstantin Komarov 2021-08-13 2287 return err;
82cae269cfa953 Konstantin Komarov 2021-08-13 2288 }
82cae269cfa953 Konstantin Komarov 2021-08-13 2289
:::::: The code at line 2248 was first introduced by commit
:::::: 82cae269cfa953032fbb8980a7d554d60fb00b17 fs/ntfs3: Add initialization of super block
:::::: TO: Konstantin Komarov <almaz.alexandrovich(a)paragon-software.com>
:::::: CC: Konstantin Komarov <almaz.alexandrovich(a)paragon-software.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
7 months, 4 weeks