Re: [PATCH 05/22] btrfs: add the beginning of async discard, discard workqueue
by Philip Li
On Mon, Nov 25, 2019 at 05:47:00PM -0800, Nick Desaulniers wrote:
> On Mon, Nov 25, 2019 at 5:35 PM Philip Li <philip.li(a)intel.com> wrote:
> >
> > On Mon, Nov 25, 2019 at 11:39:08AM -0800, Nick Desaulniers wrote:
> > > On Mon, Nov 25, 2019 at 10:59 AM Dennis Zhou <dennis(a)kernel.org> wrote:
> > > >
> > > > On Thu, Nov 21, 2019 at 08:27:43PM -0800, Nick Desaulniers wrote:
> > > > > Hi Dennis,
> > > > > Below is a 0day bot report from a build w/ Clang. Warning looks legit,
> > > > > can you please take a look?
> > > > >
> > > >
> > > > Ah thanks for this! Yeah that was a miss when I switched from flags ->
> > > > an enum and didn't update the declaration properly. I'll be sending out
> > > > a v4 as another fix for arm has some rebase conflicts.
> > > >
> > > > Is there a way to enable so I get these emails directly?
> > >
> > > + Rong, Philip
> > >
> > > The reports have only been sent to our mailing list where we've been
> > > manually triaging them. The issue with enabling them globally was
> > > that the script to reproduce the warning still doesn't mention how to
> > > build w/ Clang.
Hi Nick, i forgot one question. Is it still expected to use latest clang
to build test? Any possibility the issue is related to clang compiler itself?
Thanks
> > Thanks Nick for continuous caring on this. One thing we initially worry
> > is how to avoid duplicated reports to developer, like the one that can
> > be same as gcc's finding. We haven't found a way to effectively handle
> > this.
>
> Thanks for maintaining an invaluable tool.
>
> How would the reports be duplicated? Does 0day bot build with GCC,
> then rebuild with Clang?
>
> Regardless, does it matter? If I make a mistake, and get two build
> failure emails from 0day bot instead of one, does it matter? Sometimes
> developers may just get one, as some warnings are unique to each
> compiler. Maybe it runs the risk of folks ignoring the email if the
> volume is too much, but do authors generally ignore 0day bot emails?
> (I'd hope not).
>
> >
> > >
> > > In general the reports have been high value (I ignore most reports
> > > with -Wimplicit-function-declaration, which is the most frequent as it
> > > shows the patch was not compile tested at all).
> > Do we mean the report with -Wimplicit-function-declaration can be duplicated
> > to gcc, so we can ignore them to avoid duplication to developer?
>
> Many of the warnings GCC has Clang does as well.
> -Wimplicit-function-declaration is the most common warning I see in
> triage, which developers would see regardless of toolchain had they
> compiled first before pushing. It might be interesting to see maybe
> the intersection or common flags between GCC and Clang, and only email
> Clang reports for warnings unique to clang? I think CFLAGS can even
> be passed into make invocations so you could do:
> $ make CC=clang KBUILD_CFLAGS=<list of flags common to GCC and Clang;
> -Wno-implicit-function-declaration -Wno-...>
> such that any resulting warnings were unique to Clang. I'd expect
> such a list to quickly get stale over time though.
>
> >
> > >
> > > Rong, Philip, it's been a while since we talked about this last. Is
> > > there a general timeline of when these reports will be turned on
> > > globally? Even if the directions to reproduce aren't quite right,
> > For the timeline, it's not decided due to the duplication concern. We tend
> > to look into next year after other priorities are solved for this year.
> >
> > > generally there's enough info in the existing bugs where authors can
> > > rewrite their patch without even needing to rebuild with Clang (though
> > > having correct directions to reproduce would be nice, we could wait
> > > until someone asked for them explicitly).
> > >
> > > --
> > > Thanks,
> > > ~Nick Desaulniers
>
>
>
> --
> Thanks,
> ~Nick Desaulniers
1 year, 3 months
Re: [PATCH 05/22] btrfs: add the beginning of async discard, discard workqueue
by Philip Li
On Mon, Nov 25, 2019 at 05:47:00PM -0800, Nick Desaulniers wrote:
> On Mon, Nov 25, 2019 at 5:35 PM Philip Li <philip.li(a)intel.com> wrote:
> >
> > On Mon, Nov 25, 2019 at 11:39:08AM -0800, Nick Desaulniers wrote:
> > > On Mon, Nov 25, 2019 at 10:59 AM Dennis Zhou <dennis(a)kernel.org> wrote:
> > > >
> > > > On Thu, Nov 21, 2019 at 08:27:43PM -0800, Nick Desaulniers wrote:
> > > > > Hi Dennis,
> > > > > Below is a 0day bot report from a build w/ Clang. Warning looks legit,
> > > > > can you please take a look?
> > > > >
> > > >
> > > > Ah thanks for this! Yeah that was a miss when I switched from flags ->
> > > > an enum and didn't update the declaration properly. I'll be sending out
> > > > a v4 as another fix for arm has some rebase conflicts.
> > > >
> > > > Is there a way to enable so I get these emails directly?
> > >
> > > + Rong, Philip
> > >
> > > The reports have only been sent to our mailing list where we've been
> > > manually triaging them. The issue with enabling them globally was
> > > that the script to reproduce the warning still doesn't mention how to
> > > build w/ Clang.
> > Thanks Nick for continuous caring on this. One thing we initially worry
> > is how to avoid duplicated reports to developer, like the one that can
> > be same as gcc's finding. We haven't found a way to effectively handle
> > this.
>
> Thanks for maintaining an invaluable tool.
>
> How would the reports be duplicated? Does 0day bot build with GCC,
> then rebuild with Clang?
no, they are built separately. For duplication, i refer to the issue
can be detected by both tool, and gcc reports out already (or clang first).
>
> Regardless, does it matter? If I make a mistake, and get two build
> failure emails from 0day bot instead of one, does it matter? Sometimes
> developers may just get one, as some warnings are unique to each
> compiler. Maybe it runs the risk of folks ignoring the email if the
> volume is too much, but do authors generally ignore 0day bot emails?
> (I'd hope not).
:-) this is a good point, and recently we are working to make the
service more stable to generate reports in time.
>
> >
> > >
> > > In general the reports have been high value (I ignore most reports
> > > with -Wimplicit-function-declaration, which is the most frequent as it
> > > shows the patch was not compile tested at all).
> > Do we mean the report with -Wimplicit-function-declaration can be duplicated
> > to gcc, so we can ignore them to avoid duplication to developer?
>
> Many of the warnings GCC has Clang does as well.
> -Wimplicit-function-declaration is the most common warning I see in
> triage, which developers would see regardless of toolchain had they
> compiled first before pushing. It might be interesting to see maybe
> the intersection or common flags between GCC and Clang, and only email
> Clang reports for warnings unique to clang? I think CFLAGS can even
> be passed into make invocations so you could do:
> $ make CC=clang KBUILD_CFLAGS=<list of flags common to GCC and Clang;
> -Wno-implicit-function-declaration -Wno-...>
> such that any resulting warnings were unique to Clang. I'd expect
> such a list to quickly get stale over time though.
thanks for the idea, we will look into this.
>
> >
> > >
> > > Rong, Philip, it's been a while since we talked about this last. Is
> > > there a general timeline of when these reports will be turned on
> > > globally? Even if the directions to reproduce aren't quite right,
> > For the timeline, it's not decided due to the duplication concern. We tend
> > to look into next year after other priorities are solved for this year.
> >
> > > generally there's enough info in the existing bugs where authors can
> > > rewrite their patch without even needing to rebuild with Clang (though
> > > having correct directions to reproduce would be nice, we could wait
> > > until someone asked for them explicitly).
> > >
> > > --
> > > Thanks,
> > > ~Nick Desaulniers
>
>
>
> --
> Thanks,
> ~Nick Desaulniers
1 year, 3 months
Re: [PATCH 05/22] btrfs: add the beginning of async discard, discard workqueue
by Philip Li
On Mon, Nov 25, 2019 at 11:39:08AM -0800, Nick Desaulniers wrote:
> On Mon, Nov 25, 2019 at 10:59 AM Dennis Zhou <dennis(a)kernel.org> wrote:
> >
> > On Thu, Nov 21, 2019 at 08:27:43PM -0800, Nick Desaulniers wrote:
> > > Hi Dennis,
> > > Below is a 0day bot report from a build w/ Clang. Warning looks legit,
> > > can you please take a look?
> > >
> >
> > Ah thanks for this! Yeah that was a miss when I switched from flags ->
> > an enum and didn't update the declaration properly. I'll be sending out
> > a v4 as another fix for arm has some rebase conflicts.
> >
> > Is there a way to enable so I get these emails directly?
>
> + Rong, Philip
>
> The reports have only been sent to our mailing list where we've been
> manually triaging them. The issue with enabling them globally was
> that the script to reproduce the warning still doesn't mention how to
> build w/ Clang.
Thanks Nick for continuous caring on this. One thing we initially worry
is how to avoid duplicated reports to developer, like the one that can
be same as gcc's finding. We haven't found a way to effectively handle
this.
>
> In general the reports have been high value (I ignore most reports
> with -Wimplicit-function-declaration, which is the most frequent as it
> shows the patch was not compile tested at all).
Do we mean the report with -Wimplicit-function-declaration can be duplicated
to gcc, so we can ignore them to avoid duplication to developer?
>
> Rong, Philip, it's been a while since we talked about this last. Is
> there a general timeline of when these reports will be turned on
> globally? Even if the directions to reproduce aren't quite right,
For the timeline, it's not decided due to the duplication concern. We tend
to look into next year after other priorities are solved for this year.
> generally there's enough info in the existing bugs where authors can
> rewrite their patch without even needing to rebuild with Clang (though
> having correct directions to reproduce would be nice, we could wait
> until someone asked for them explicitly).
>
> --
> Thanks,
> ~Nick Desaulniers
1 year, 3 months
Re: [atishp04:efi_stub 1/1] drivers/firmware/efi/libstub/arm-stub.c:203:7: warning: variable 'secure_boot' is uninitialized when used here
by Rong Chen
Hi Nick,
On 11/22/19 3:10 AM, Nick Desaulniers wrote:
> On Wed, Nov 20, 2019 at 2:46 PM Atish Patra <Atish.Patra(a)wdc.com> wrote:
>> On Mon, 2019-11-18 at 22:39 -0800, Nick Desaulniers wrote:
>>> Atish, below is a report from 0day bot from a build with Clang. The
>>> warning looks legit, can you please take a look?
>>>
>> Hi Nick,
>> Thanks for the email. This is a work in progress branch. Is there way
>> not to trigger kbuild tests on this branch ?
> That's a common question that Rong or Philip can answer (I forgot what
> the answer has been in the past). Rong/Philip, it may be good to have
> a URL/link that I can point people to in the future, since it's a FAQ.
We have blacklisted "efi_stub" and "wip_.*" branches for Atish. In
general, branches named as ".*experimental.*" or ".*dont-build"
won't be tested by default. and we have a doc to introduce basic
configurations: https://github.com/intel/lkp-tests/wiki/Repo-Spec
Best Regards,
Rong Chen
>
>> --
>> Regards,
>> Atish
>>
>>
>>> On Mon, Nov 18, 2019 at 10:17 PM kbuild test robot <lkp(a)intel.com>
>>> wrote:
>>>> CC: kbuild-all(a)lists.01.org
>>>> TO: Atish Patra <atish.patra(a)wdc.com>
>>>>
>>>> tree: https://github.com/atishp04/linux efi_stub
>>>> head: 7dbf2060ab3115d2edcfba8f0f677a321a1611f1
>>>> commit: 7dbf2060ab3115d2edcfba8f0f677a321a1611f1 [1/1] Add efi stub
>>>> config: arm64-defconfig (attached as .config)
>>>> compiler: clang version 10.0.0 (git://gitmirror/llvm_project
>>>> 0213adde218530bc31e5c4e50b49704c6bb2f2e9)
>>>> reproduce:
>>>> wget
>>>> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross
>>>> -O ~/bin/make.cross
>>>> chmod +x ~/bin/make.cross
>>>> git checkout 7dbf2060ab3115d2edcfba8f0f677a321a1611f1
>>>> # save the attached .config to linux build tree
>>>> make.cross ARCH=arm64
>>>>
>>>> If you fix the issue, kindly add following tag
>>>> Reported-by: kbuild test robot <lkp(a)intel.com>
>>>>
>>>> All warnings (new ones prefixed by >>):
>>>>
>>>> drivers/firmware/efi/libstub/arm-stub.c:132:22: warning: unused
>>>> variable 'si' [-Wunused-variable]
>>>> struct screen_info *si;
>>>> ^
>>>>>> drivers/firmware/efi/libstub/arm-stub.c:203:7: warning:
>>>>>> variable 'secure_boot' is uninitialized when used here [-
>>>>>> Wuninitialized]
>>>> secure_boot != efi_secureboot_mode_disabled) {
>>>> ^~~~~~~~~~~
>>>> drivers/firmware/efi/libstub/arm-stub.c:131:2: note: variable
>>>> 'secure_boot' is declared here
>>>> enum efi_secureboot_mode secure_boot;
>>>> ^
>>>> 2 warnings generated.
>>>>
>>>> vim +/secure_boot +203 drivers/firmware/efi/libstub/arm-stub.c
>>>>
>>>> b844470f22061e drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-09-21 92
>>>> b844470f22061e drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-09-21 93
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 94 /*
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 95 * This function handles the
>>>> architcture specific differences between arm and
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 96 * arm64 regarding where the kernel
>>>> image must be loaded and any memory that
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 97 * must be reserved. On failure it is
>>>> required to free all
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 98 * all allocations it has made.
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 99 */
>>>> bd669475d14e32 drivers/firmware/efi/arm-stub.c Ard
>>>> Biesheuvel 2014-07-02 100 efi_status_t
>>>> handle_kernel_image(efi_system_table_t *sys_table,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 101 unsigned long
>>>> *image_addr,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 102 unsigned long
>>>> *image_size,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 103 unsigned long
>>>> *reserve_addr,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 104 unsigned long
>>>> *reserve_size,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 105 unsigned long dram_base,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 106 efi_loaded_image_t
>>>> *image);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 107 /*
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 108 * EFI entry point for the arm/arm64
>>>> EFI stubs. This is the entrypoint
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 109 * that is described in the PE/COFF
>>>> header. Most of the code is the same
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 110 * for both archictectures, with the
>>>> arch-specific code provided in the
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 111 * handle_kernel_image() function.
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 112 */
>>>> ddeeefe2dfbe1f drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2015-01-12 113 unsigned long efi_entry(void *handle,
>>>> efi_system_table_t *sys_table,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 114 unsigned
>>>> long *image_addr)
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 115 {
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 116 efi_loaded_image_t *image;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 117 efi_status_t status;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 118 unsigned long image_size = 0;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 119 unsigned long dram_base;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 120 /* addr/point and size pairs
>>>> for memory management*/
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 121 unsigned long initrd_addr;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 122 u64 initrd_size = 0;
>>>> 345c736edd07b6 drivers/firmware/efi/arm-stub.c Ard
>>>> Biesheuvel 2014-04-03 123 unsigned long fdt_addr =
>>>> 0; /* Original DTB */
>>>> a643375f4b1755 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2015-03-04 124 unsigned long fdt_size = 0;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 125 char *cmdline_ptr = NULL;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 126 int cmdline_size = 0;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 127 unsigned long new_fdt_addr;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 128 efi_guid_t loaded_image_proto =
>>>> LOADED_IMAGE_PROTOCOL_GUID;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 129 unsigned long reserve_addr = 0;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 130 unsigned long reserve_size = 0;
>>>> de8cb458625c16 drivers/firmware/efi/libstub/arm-stub.c David
>>>> Howells 2017-02-06 131 enum efi_secureboot_mode
>>>> secure_boot;
>>>> f0827e18a7a1da drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-04-25 @132 struct screen_info *si;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 133
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 134 /* Check if we were booted by
>>>> the EFI firmware */
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 135 if (sys_table->hdr.signature !=
>>>> EFI_SYSTEM_TABLE_SIGNATURE)
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 136 goto fail;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 137
>>>> b9d6769b5678db drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-02-17 138 status =
>>>> check_platform_features(sys_table);
>>>> b9d6769b5678db drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-02-17 139 if (status != EFI_SUCCESS)
>>>> b9d6769b5678db drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-02-17 140 goto fail;
>>>> b9d6769b5678db drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-02-17 141
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 142 /*
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 143 * Get a handle to the loaded
>>>> image protocol. This is used to get
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 144 * information about the
>>>> running image, such as size and the command
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 145 * line.
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 146 */
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 147 status = sys_table->boottime-
>>>>> handle_protocol(handle,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 148 &loaded_image_prot
>>>> o, (void *)&image);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 149 if (status != EFI_SUCCESS) {
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 150 pr_efi_err(sys_table,
>>>> "Failed to get loaded image protocol\n");
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 151 goto fail;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 152 }
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 153
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 154 dram_base =
>>>> get_dram_base(sys_table);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 155 if (dram_base == EFI_ERROR) {
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 156 pr_efi_err(sys_table,
>>>> "Failed to find DRAM base\n");
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 157 goto fail;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 158 }
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 159
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 160 /*
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 161 * Get the command line from
>>>> EFI, using the LOADED_IMAGE
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 162 * protocol. We are going to
>>>> copy the command line into the
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 163 * device tree, so this can be
>>>> allocated anywhere.
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 164 */
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 165 cmdline_ptr =
>>>> efi_convert_cmdline(sys_table, image, &cmdline_size);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 166 if (!cmdline_ptr) {
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 167 pr_efi_err(sys_table,
>>>> "getting command line via LOADED_IMAGE_PROTOCOL\n");
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 168 goto fail;
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 169 }
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 170
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 171 if
>>>> (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 172 IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 173 cmdline_size == 0)
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 174 efi_parse_options(CONFIG_CMDLINE);
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 175
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 176 if
>>>> (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0)
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 177 efi_parse_options(cmdline_ptr);
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 178
>>>> eeff7d634f4750 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 179 pr_efi(sys_table, "Booting
>>>> Linux Kernel...\n");
>>>> 7dbf2060ab3115 drivers/firmware/efi/libstub/arm-stub.c Atish
>>>> Patra 2019-11-18 180 #if 0
>>>> f0827e18a7a1da drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-04-25 181 si =
>>>> setup_graphics(sys_table);
>>>> 7dbf2060ab3115 drivers/firmware/efi/libstub/arm-stub.c Atish
>>>> Patra 2019-11-18 182 #endif
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 183 status =
>>>> handle_kernel_image(sys_table, image_addr, &image_size,
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-
>>>> 26 184 &reserve_addr,
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-
>>>> 26 185 &reserve_size,
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-
>>>> 26 186 dram_base, image);
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 187 if (status != EFI_SUCCESS) {
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 188 pr_efi_err(sys_table,
>>>> "Failed to relocate kernel\n");
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 189 goto
>>>> fail_free_cmdline;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 190 }
>>>> 7dbf2060ab3115 drivers/firmware/efi/libstub/arm-stub.c Atish
>>>> Patra 2019-11-18 191 #if 0
>>>> ccc829ba3624be drivers/firmware/efi/libstub/arm-stub.c Matthew
>>>> Garrett 2017-08-25 192 /* Ask the firmware to clear
>>>> memory on unclean shutdown */
>>>> ccc829ba3624be drivers/firmware/efi/libstub/arm-stub.c Matthew
>>>> Garrett 2017-08-
>>>> 25 193 efi_enable_reset_attack_mitigation(sys_table);
>>>> ccc829ba3624be drivers/firmware/efi/libstub/arm-stub.c Matthew
>>>> Garrett 2017-08-25 194
>>>> 73a6492589c87c drivers/firmware/efi/libstub/arm-stub.c Linn
>>>> Crosetto 2016-04-25 195 secure_boot =
>>>> efi_get_secureboot(sys_table);
>>>> 7dbf2060ab3115 drivers/firmware/efi/libstub/arm-stub.c Atish
>>>> Patra 2019-11-18 196 #endif
>>>> 345c736edd07b6 drivers/firmware/efi/arm-stub.c Ard
>>>> Biesheuvel 2014-04-03 197 /*
>>>> de8cb458625c16 drivers/firmware/efi/libstub/arm-stub.c David
>>>> Howells 2017-02-06 198 * Unauthenticated device tree
>>>> data is a security hazard, so ignore
>>>> de8cb458625c16 drivers/firmware/efi/libstub/arm-stub.c David
>>>> Howells 2017-02-06 199 * 'dtb=' unless UEFI Secure
>>>> Boot is disabled. We assume that secure
>>>> de8cb458625c16 drivers/firmware/efi/libstub/arm-stub.c David
>>>> Howells 2017-02-06 200 * boot is enabled if we can't
>>>> determine its state.
>>>> 345c736edd07b6 drivers/firmware/efi/arm-stub.c Ard
>>>> Biesheuvel 2014-04-03 201 */
>>>> 3d7ee348aa4127 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-07-11 202 if
>>>> (!IS_ENABLED(CONFIG_EFI_ARMSTUB_DTB_LOADER) ||
>>>> 3d7ee348aa4127 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-07-11 @203 secure_boot !=
>>>> efi_secureboot_mode_disabled) {
>>>> 3d7ee348aa4127 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-07-11 204 if
>>>> (strstr(cmdline_ptr, "dtb="))
>>>> 73a6492589c87c drivers/firmware/efi/libstub/arm-stub.c Linn
>>>> Crosetto 2016-04-
>>>> 25 205 pr_efi(sys_table, "Ignoring DTB
>>>> from command line.\n");
>>>> 345c736edd07b6 drivers/firmware/efi/arm-stub.c Ard
>>>> Biesheuvel 2014-04-03 206 } else {
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 207 status =
>>>> handle_cmdline_files(sys_table, image, cmdline_ptr,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 208 "dtb=",
>>>> a643375f4b1755 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2015-03-
>>>> 04 209 ~0UL,
>>>> &fdt_addr, &fdt_size);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 210
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 211 if (status !=
>>>> EFI_SUCCESS) {
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 212 pr_efi_err(sys_table, "Failed to
>>>> load device tree!\n");
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 213 goto
>>>> fail_free_image;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 214 }
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 215 }
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 216
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 217 if (fdt_addr) {
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 218 pr_efi(sys_table,
>>>> "Using DTB from command line\n");
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 219 } else {
>>>> 345c736edd07b6 drivers/firmware/efi/arm-stub.c Ard
>>>> Biesheuvel 2014-04-03 220 /* Look for a device
>>>> tree configuration table entry. */
>>>> a643375f4b1755 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2015-03-04 221 fdt_addr =
>>>> (uintptr_t)get_fdt(sys_table, &fdt_size);
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 222 if (fdt_addr)
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-
>>>> 23 223 pr_efi(sys_table, "Using DTB from
>>>> configuration table\n");
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 224 }
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 225
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 226 if (!fdt_addr)
>>>> 0bcaa9040d0586 drivers/firmware/efi/libstub/arm-stub.c Mark
>>>> Rutland 2014-10-23 227 pr_efi(sys_table,
>>>> "Generating empty DTB\n");
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 228
>>>> 138728dd4ee30d drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 229 status =
>>>> handle_cmdline_files(sys_table, image, cmdline_ptr, "initrd=",
>>>> 138728dd4ee30d drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 230 efi_get_max_initrd_a
>>>> ddr(dram_base,
>>>> 138728dd4ee30d drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 231
>>>> *image_addr),
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 232 (unsigned long
>>>> *)&initrd_addr,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 233 (unsigned long
>>>> *)&initrd_size);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 234 if (status != EFI_SUCCESS)
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 235 pr_efi_err(sys_table,
>>>> "Failed initrd from command line!\n");
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 236
>>>> 568bc4e87033d2 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-11-
>>>> 12 237 efi_random_get_seed(sys_table);
>>>> 568bc4e87033d2 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-11-12 238
>>>> 38fb6652229c21 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-10-25 239 /* hibernation expects the
>>>> runtime regions to stay in the same place */
>>>> 38fb6652229c21 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-10-25 240 if
>>>> (!IS_ENABLED(CONFIG_HIBERNATION) && !nokaslr()) {
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 241 /*
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 242 * Randomize the base
>>>> of the UEFI runtime services region.
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 243 * Preserve the 2 MB
>>>> alignment of the region by taking a
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 244 * shift of 21 bit
>>>> positions into account when scaling
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 245 * the headroom value
>>>> using a 32-bit random value.
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 246 */
>>>> 197decefdb79d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-17 247 static const u64
>>>> headroom = EFI_RT_VIRTUAL_LIMIT -
>>>> 197decefdb79d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 17 248 EFI_RT_VIRTUAL
>>>> _BASE -
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 249 EFI_RT_VIRTUAL
>>>> _SIZE;
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 250 u32 rnd;
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 251
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 252 status =
>>>> efi_get_random_bytes(sys_table, sizeof(rnd),
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 253 (u8 *)&rnd);
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 254 if (status ==
>>>> EFI_SUCCESS) {
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 255 virtmap_base =
>>>> EFI_RT_VIRTUAL_BASE +
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 256 (((headroom >> 21)
>>>> * rnd) >> (32 - 21));
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 257 }
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 258 }
>>>> e69176d68d26d6 drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-04 259
>>>> b844470f22061e drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-09-
>>>> 21 260 install_memreserve_table(sys_table);
>>>> b844470f22061e drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2018-09-21 261
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 262 new_fdt_addr = fdt_addr;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 263 status =
>>>> allocate_new_fdt_and_exit_boot(sys_table, handle,
>>>> 138728dd4ee30d drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2017-04-
>>>> 04 264 &new_fdt_addr,
>>>> efi_get_max_fdt_addr(dram_base),
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 265 initrd_addr, initrd_size,
>>>> cmdline_ptr,
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-
>>>> 15 266 fdt_addr, fdt_size);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 267
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 268 /*
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 269 * If all went well, we need to
>>>> return the FDT address to the
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 270 * calling function so it can
>>>> be passed to kernel as part of
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 271 * the kernel boot protocol.
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 272 */
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 273 if (status == EFI_SUCCESS)
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 274 return new_fdt_addr;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 275
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 276 pr_efi_err(sys_table, "Failed
>>>> to update FDT and exit boot services\n");
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 277
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 278 efi_free(sys_table,
>>>> initrd_size, initrd_addr);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 279 efi_free(sys_table, fdt_size,
>>>> fdt_addr);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 280
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 281 fail_free_image:
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 282 efi_free(sys_table, image_size,
>>>> *image_addr);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 283 efi_free(sys_table,
>>>> reserve_size, reserve_addr);
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 284 fail_free_cmdline:
>>>> 7dbf2060ab3115 drivers/firmware/efi/libstub/arm-stub.c Atish
>>>> Patra 2019-11-18 285 //free_screen_info(sys_table,
>>>> si);
>>>> 2b5fe07a78a09a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2016-01-26 286 efi_free(sys_table,
>>>> cmdline_size, (unsigned long)cmdline_ptr);
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 287 fail:
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 288 return EFI_ERROR;
>>>> 3c7f255039a2ad drivers/firmware/efi/arm-stub.c Mark
>>>> Salter 2014-04-15 289 }
>>>> f3cdfd239da56a drivers/firmware/efi/libstub/arm-stub.c Ard
>>>> Biesheuvel 2014-10-20 290
>>>>
>>>> :::::: The code at line 203 was first introduced by commit
>>>> :::::: 3d7ee348aa4127a7893c11261da9b76371a970e6 efi/libstub/arm:
>>>> Add opt-in Kconfig option for the DTB loader
>>>>
>>>> :::::: TO: Ard Biesheuvel <ard.biesheuvel(a)linaro.org>
>>>> :::::: CC: Ingo Molnar <mingo(a)kernel.org>
>>>>
>>>> ---
>>>> 0-DAY kernel test infrastructure Open Source
>>>> Technology Center
>>>> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel
>>>> Corporation
>>>
>
1 year, 3 months
Re: [PATCH 2/2] tty: add retry to tty_init_dev() to workaround a race condition
by Dan Carpenter
Hi Sudip,
[auto build test WARNING on v5.4-rc8]
[cannot apply to tty/tty-testing next-20191122]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Sudip-Mukherjee/tty-remove-unuse...
base: af42d3466bdc8f39806b26f593604fdc54140bcb
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
smatch warnings:
drivers/tty/tty_io.c:1360 tty_init_dev() error: we previously assumed 'tty->port' could be null (see line 1348)
# https://github.com/0day-ci/linux/commit/8de47da07f8c6fe6f631965cafb384cd0...
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 8de47da07f8c6fe6f631965cafb384cd0d72ce40
vim +1360 drivers/tty/tty_io.c
8de47da07f8c6f drivers/tty/tty_io.c Sudip Mukherjee 2019-11-20 1318 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx,
8de47da07f8c6f drivers/tty/tty_io.c Sudip Mukherjee 2019-11-20 1319 int retry)
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1320 {
bf970ee46e0fb3 drivers/char/tty_io.c Alan Cox 2008-10-13 1321 struct tty_struct *tty;
73ec06fc5f5c8e drivers/char/tty_io.c Alan Cox 2008-10-13 1322 int retval;
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1323
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1324 /*
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1325 * First time open is complex, especially for PTY devices.
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1326 * This code guarantees that either everything succeeds and the
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1327 * TTY is ready for operation, or else the table slots are vacated
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1328 * and the allocated memory released. (Except that the termios
16b00ae82dce0e drivers/tty/tty_io.c Johan Hovold 2017-03-30 1329 * may be retained.)
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1330 */
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1331
73ec06fc5f5c8e drivers/char/tty_io.c Alan Cox 2008-10-13 1332 if (!try_module_get(driver->owner))
73ec06fc5f5c8e drivers/char/tty_io.c Alan Cox 2008-10-13 1333 return ERR_PTR(-ENODEV);
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1334
2c964a2f4191f2 drivers/tty/tty_io.c Rasmus Villemoes 2014-07-10 1335 tty = alloc_tty_struct(driver, idx);
d5543503753983 drivers/tty/tty_io.c Jiri Slaby 2011-03-23 1336 if (!tty) {
d5543503753983 drivers/tty/tty_io.c Jiri Slaby 2011-03-23 1337 retval = -ENOMEM;
d5543503753983 drivers/tty/tty_io.c Jiri Slaby 2011-03-23 1338 goto err_module_put;
d5543503753983 drivers/tty/tty_io.c Jiri Slaby 2011-03-23 1339 }
^1da177e4c3f41 drivers/char/tty_io.c Linus Torvalds 2005-04-16 1340
89c8d91e31f267 drivers/tty/tty_io.c Alan Cox 2012-08-08 1341 tty_lock(tty);
73ec06fc5f5c8e drivers/char/tty_io.c Alan Cox 2008-10-13 1342 retval = tty_driver_install_tty(driver, tty);
d5543503753983 drivers/tty/tty_io.c Jiri Slaby 2011-03-23 1343 if (retval < 0)
c8b710b3e43481 drivers/tty/tty_io.c Peter Hurley 2016-01-09 1344 goto err_free_tty;
8b0a88d5912ab5 drivers/char/tty_io.c Alan Cox 2008-10-13 1345
04831dc154df9b drivers/tty/tty_io.c Jiri Slaby 2012-06-04 1346 if (!tty->port)
04831dc154df9b drivers/tty/tty_io.c Jiri Slaby 2012-06-04 1347 tty->port = driver->ports[idx];
8de47da07f8c6f drivers/tty/tty_io.c Sudip Mukherjee 2019-11-20 @1348 if (!tty->port && retry) {
^^^^^^^^^^
Check
8de47da07f8c6f drivers/tty/tty_io.c Sudip Mukherjee 2019-11-20 1349 retval = -EAGAIN;
8de47da07f8c6f drivers/tty/tty_io.c Sudip Mukherjee 2019-11-20 1350 goto err_release_driver;
8de47da07f8c6f drivers/tty/tty_io.c Sudip Mukherjee 2019-11-20 1351 }
04831dc154df9b drivers/tty/tty_io.c Jiri Slaby 2012-06-04 1352
5d4121c04b3577 drivers/tty/tty_io.c Jiri Slaby 2012-08-17 1353 WARN_RATELIMIT(!tty->port,
5d4121c04b3577 drivers/tty/tty_io.c Jiri Slaby 2012-08-17 1354 "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n",
5d4121c04b3577 drivers/tty/tty_io.c Jiri Slaby 2012-08-17 1355 __func__, tty->driver->name);
5d4121c04b3577 drivers/tty/tty_io.c Jiri Slaby 2012-08-17 1356
b027e2298bd588 drivers/tty/tty_io.c Gaurav Kohli 2018-01-23 1357 retval = tty_ldisc_lock(tty, 5 * HZ);
b027e2298bd588 drivers/tty/tty_io.c Gaurav Kohli 2018-01-23 1358 if (retval)
b027e2298bd588 drivers/tty/tty_io.c Gaurav Kohli 2018-01-23 1359 goto err_release_lock;
967fab6916681e drivers/tty/tty_io.c Jiri Slaby 2012-10-18 @1360 tty->port->itty = tty;
^^^^^^^^^^^^^^^^^^^^^^
Unchecked dereference.
967fab6916681e drivers/tty/tty_io.c Jiri Slaby 2012-10-18 1361
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 3 months
[zx2c4:jd/wireguard-azinc 1/3] drivers/net/wireguard/send.c:180 encrypt_packet() error: uninitialized symbol 'trailer'.
by Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/zx2c4/linux.git jd/wireguard-azinc
head: a513c826006403507e87a596ee8a00e57c39d6e4
commit: 2b36c25d88d5f0c47b6fd3e24ef026a10054a4b1 [1/3] net: WireGuard secure network tunnel
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
New smatch warnings:
drivers/net/wireguard/socket.c:413 wg_socket_init() warn: variable dereferenced before check 'new4' (see line 393)
drivers/net/wireguard/selftest/allowedips.c:419 randomized_test() error: double lock 'mutex:&mutex'
# https://git.kernel.org/pub/scm/linux/kernel/git/zx2c4/linux.git/commit/?i...
git remote add zx2c4 https://git.kernel.org/pub/scm/linux/kernel/git/zx2c4/linux.git
git remote update zx2c4
git checkout 2b36c25d88d5f0c47b6fd3e24ef026a10054a4b1
drivers/net/wireguard/socket.c
387
388 ret = udp_sock_create(wg->creating_net, &port4, &new4);
389 if (ret < 0) {
390 pr_err("%s: Could not create IPv4 socket\n", wg->dev->name);
391 return ret;
392 }
393 set_sock_opts(new4);
^^^^^^^^^^^^^^^^^^^
Dereferenced
394 setup_udp_tunnel_sock(wg->creating_net, new4, &cfg);
395
396 #if IS_ENABLED(CONFIG_IPV6)
397 if (ipv6_mod_enabled()) {
398 port6.local_udp_port = inet_sk(new4->sk)->inet_sport;
399 ret = udp_sock_create(wg->creating_net, &port6, &new6);
400 if (ret < 0) {
401 udp_tunnel_sock_release(new4);
402 if (ret == -EADDRINUSE && !port && retries++ < 100)
403 goto retry;
404 pr_err("%s: Could not create IPv6 socket\n",
405 wg->dev->name);
406 return ret;
407 }
408 set_sock_opts(new6);
409 setup_udp_tunnel_sock(wg->creating_net, new6, &cfg);
410 }
411 #endif
412
413 wg_socket_reinit(wg, new4 ? new4->sk : NULL, new6 ? new6->sk : NULL);
^^^^
This check can be removed.
414 return 0;
415 }
drivers/net/wireguard/selftest/allowedips.c
301 mutex_lock(&mutex);
302
303 for (i = 0; i < NUM_RAND_ROUTES; ++i) {
304 prandom_bytes(ip, 4);
305 cidr = prandom_u32_max(32) + 1;
306 peer = peers[prandom_u32_max(NUM_PEERS)];
307 if (wg_allowedips_insert_v4(&t, (struct in_addr *)ip, cidr,
308 peer, &mutex) < 0) {
309 pr_err("allowedips random self-test malloc: FAIL\n");
310 goto free;
^^^^^^^^^^
Mutex non necessarily released on error.
311 }
312 if (horrible_allowedips_insert_v4(&h, (struct in_addr *)ip,
313 cidr, peer) < 0) {
314 pr_err("allowedips random self-test malloc: FAIL\n");
315 goto free;
316 }
317 for (j = 0; j < NUM_MUTATED_ROUTES; ++j) {
318 memcpy(mutated, ip, 4);
319 prandom_bytes(mutate_mask, 4);
320 mutate_amount = prandom_u32_max(32);
321 for (k = 0; k < mutate_amount / 8; ++k)
[ snip ]
418 free:
419 mutex_lock(&mutex);
^^^^^^^^^^^^^^^^^^
Double lock.
420 wg_allowedips_free(&t, &mutex);
421 mutex_unlock(&mutex);
422 horrible_allowedips_free(&h);
423 if (peers) {
424 for (i = 0; i < NUM_PEERS; ++i)
425 kfree(peers[i]);
426 }
427 kfree(peers);
428 return ret;
429 }
430
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 3 months
Re: [PATCH v5 25/27] NFS: Add fs_context support.
by Dan Carpenter
Hi Scott,
url: https://github.com/0day-ci/linux/commits/Scott-Mayhew/nfs-Mount-API-conve...
base: af42d3466bdc8f39806b26f593604fdc54140bcb
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
smatch warnings:
fs/nfs/nfs4namespace.c:147 nfs4_validate_fspath() error: uninitialized symbol 'len'.
fs/nfs/nfs4namespace.c:149 nfs4_validate_fspath() error: 'fs_path' dereferencing possible ERR_PTR()
# https://github.com/0day-ci/linux/commit/deebb47534c8b45696a02a0d8aff35b23...
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout deebb47534c8b45696a02a0d8aff35b232b24e15
vim +/len +147 fs/nfs/nfs4namespace.c
b514f872f86d4b Al Viro 2011-03-16 129 static int nfs4_validate_fspath(struct dentry *dentry,
54ceac45159860 David Howells 2006-08-22 130 const struct nfs4_fs_locations *locations,
deebb47534c8b4 David Howells 2019-11-20 131 struct nfs_fs_context *ctx)
54ceac45159860 David Howells 2006-08-22 132 {
54ceac45159860 David Howells 2006-08-22 133 const char *path, *fs_path;
deebb47534c8b4 David Howells 2019-11-20 134 char *buf;
deebb47534c8b4 David Howells 2019-11-20 135 unsigned short len;
deebb47534c8b4 David Howells 2019-11-20 136 int n;
54ceac45159860 David Howells 2006-08-22 137
deebb47534c8b4 David Howells 2019-11-20 138 buf = kmalloc(4096, GFP_KERNEL);
deebb47534c8b4 David Howells 2019-11-20 139 path = nfs4_path(dentry, buf, 4096);
deebb47534c8b4 David Howells 2019-11-20 140 if (IS_ERR(path)) {
deebb47534c8b4 David Howells 2019-11-20 141 kfree(buf);
54ceac45159860 David Howells 2006-08-22 142 return PTR_ERR(path);
deebb47534c8b4 David Howells 2019-11-20 143 }
54ceac45159860 David Howells 2006-08-22 144
deebb47534c8b4 David Howells 2019-11-20 145 fs_path = nfs4_pathname_string(&locations->fs_path, &len);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Both warnings are because Smatch thinks nfs4_pathname_string() can
return an error pointer without initializing "len".
54ceac45159860 David Howells 2006-08-22 146
deebb47534c8b4 David Howells 2019-11-20 @147 n = strncmp(path, fs_path, len);
deebb47534c8b4 David Howells 2019-11-20 148 kfree(buf);
deebb47534c8b4 David Howells 2019-11-20 @149 kfree(fs_path);
deebb47534c8b4 David Howells 2019-11-20 150 if (n != 0) {
54ceac45159860 David Howells 2006-08-22 151 dprintk("%s: path %s does not begin with fsroot %s\n",
deebb47534c8b4 David Howells 2019-11-20 152 __func__, path, ctx->nfs_server.export_path);
54ceac45159860 David Howells 2006-08-22 153 return -ENOENT;
54ceac45159860 David Howells 2006-08-22 154 }
54ceac45159860 David Howells 2006-08-22 155
54ceac45159860 David Howells 2006-08-22 156 return 0;
54ceac45159860 David Howells 2006-08-22 157 }
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 3 months
[wireless-drivers-next:master 8/21] drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c:596 qtnf_pcie_skb_send() warn: variable dereferenced before check 'skb' (see line 560)
by Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-ne... master
head: 924ea58dadea23cc28b60d02b9c0896b7b168a6f
commit: 904628d3130b5aef0c9b06efa80e5a96f203e000 [8/21] qtnfmac: add interface ID to each packet
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp(a)intel.com>
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
New smatch warnings:
drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c:596 qtnf_pcie_skb_send() warn: variable dereferenced before check 'skb' (see line 560)
# https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-ne...
git remote add wireless-drivers-next https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-ne...
git remote update wireless-drivers-next
git checkout 904628d3130b5aef0c9b06efa80e5a96f203e000
vim +/skb +596 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c
904628d3130b5a drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2019-11-18 535 static int qtnf_pcie_skb_send(struct qtnf_bus *bus, struct sk_buff *skb)
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 536 {
addc7540708f52 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 537 struct qtnf_pcie_pearl_state *ps = get_bus_priv(bus);
c9ff6c9157c2e6 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 538 struct qtnf_pcie_bus_priv *priv = &ps->base;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 539 dma_addr_t txbd_paddr, skb_paddr;
d0b95bfa11786e drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 540 struct qtnf_pearl_tx_bd *txbd;
20da2ec06bfad2 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-09-18 541 unsigned long flags;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 542 int len, i;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 543 u32 info;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 544 int ret = 0;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 545
21077d09b4a67e drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 546 spin_lock_irqsave(&priv->tx_lock, flags);
20da2ec06bfad2 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-09-18 547
c9ff6c9157c2e6 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 548 if (!qtnf_tx_queue_ready(ps)) {
c35c0d54a77d0f drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-10-30 549 if (skb->dev) {
^^^^^^^^
c35c0d54a77d0f drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-10-30 550 netif_tx_stop_all_queues(skb->dev);
c35c0d54a77d0f drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-10-30 551 priv->tx_stopped = 1;
c35c0d54a77d0f drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-10-30 552 }
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 553
21077d09b4a67e drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 554 spin_unlock_irqrestore(&priv->tx_lock, flags);
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 555 return NETDEV_TX_BUSY;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 556 }
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 557
3cbc3a0f19ac73 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-15 558 i = priv->tx_bd_w_index;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 559 priv->tx_skb[i] = skb;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 @560 len = skb->len;
^^^^^^^^
Dereferenced without checking.
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 561
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 562 skb_paddr = pci_map_single(priv->pdev, skb->data,
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 563 skb->len, PCI_DMA_TODEVICE);
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 564 if (pci_dma_mapping_error(priv->pdev, skb_paddr)) {
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 565 pr_err("skb DMA mapping error: %pad\n", &skb_paddr);
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 566 ret = -ENOMEM;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 567 goto tx_done;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 568 }
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 569
c9ff6c9157c2e6 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 570 txbd = &ps->tx_bd_vbase[i];
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 571 txbd->addr = cpu_to_le32(QTN_HOST_LO32(skb_paddr));
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 572 txbd->addr_h = cpu_to_le32(QTN_HOST_HI32(skb_paddr));
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 573
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 574 info = (len & QTN_PCIE_TX_DESC_LEN_MASK) << QTN_PCIE_TX_DESC_LEN_SHIFT;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 575 txbd->info = cpu_to_le32(info);
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 576
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 577 /* sync up all descriptor updates before passing them to EP */
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 578 dma_wmb();
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 579
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 580 /* write new TX descriptor to PCIE_RX_FIFO on EP */
c9ff6c9157c2e6 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 581 txbd_paddr = ps->tx_bd_pbase + i * sizeof(struct qtnf_pearl_tx_bd);
f31039d4aea97d drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-29 582
f31039d4aea97d drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-29 583 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 584 writel(QTN_HOST_HI32(txbd_paddr),
c9ff6c9157c2e6 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 585 PCIE_HDP_HOST_WR_DESC0_H(ps->pcie_reg_base));
f31039d4aea97d drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-29 586 #endif
f31039d4aea97d drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-29 587 writel(QTN_HOST_LO32(txbd_paddr),
c9ff6c9157c2e6 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 588 PCIE_HDP_HOST_WR_DESC0(ps->pcie_reg_base));
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 589
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 590 if (++i >= priv->tx_bd_num)
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 591 i = 0;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 592
3cbc3a0f19ac73 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-15 593 priv->tx_bd_w_index = i;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 594
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 595 tx_done:
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 @596 if (ret && skb) {
^^^
Checked too late.
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 597 pr_err_ratelimited("drop skb\n");
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 598 if (skb->dev)
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 599 skb->dev->stats.tx_dropped++;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 600 dev_kfree_skb_any(skb);
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 601 }
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 602
0593da274d4d7f drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-08-15 603 priv->tx_done_count++;
21077d09b4a67e drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 604 spin_unlock_irqrestore(&priv->tx_lock, flags);
20da2ec06bfad2 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Sergey Matyukevich 2017-09-18 605
789763b683eb77 drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c Igor Mitsyanko 2018-09-24 606 qtnf_pearl_data_tx_reclaim(ps);
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 607
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 608 return NETDEV_TX_OK;
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 609 }
98f44cb0655cbe drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c Igor Mitsyanko 2017-05-11 610
:::::: The code at line 596 was first introduced by commit
:::::: 98f44cb0655cbef0850ba7ff4c8213fb1bf9b6a2 qtnfmac: introduce new FullMAC driver for Quantenna chipsets
:::::: TO: Igor Mitsyanko <igor.mitsyanko.os(a)quantenna.com>
:::::: CC: Kalle Valo <kvalo(a)codeaurora.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
1 year, 3 months
Re: [leon-rdma:rdma-next 59/63] net/core/rtnetlink.c:1279 rtnl_fill_vfinfo() warn: check that 'node_guid' doesn't leak information (struct has a hole after 'vf')
by Dan Carpenter
On Wed, Nov 20, 2019 at 03:45:16PM +0200, Leon Romanovsky wrote:
> On Wed, Nov 20, 2019 at 03:49:00PM +0300, Dan Carpenter wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git rdma-next
> > head: 7f9a863f2a4067a38cc6ad330b9425b3fd2dc67b
> > commit: a209fe95d542e8e566c74a8cbd2ec49452b9d110 [59/63] net/core: Add support for getting VF GUIDs
> >
> > If you fix the issue, kindly add following tag
> > Reported-by: kbuild test robot <lkp(a)intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
> >
> > smatch warnings:
> > net/core/rtnetlink.c:1279 rtnl_fill_vfinfo() warn: check that 'node_guid' doesn't leak information (struct has a hole after 'vf')
> > net/core/rtnetlink.c:1281 rtnl_fill_vfinfo() warn: check that 'port_guid' doesn't leak information (struct has a hole after 'vf')
> >
> > # https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git/commi...
> > git remote add leon-rdma https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git
> > git remote update leon-rdma
> > git checkout a209fe95d542e8e566c74a8cbd2ec49452b9d110
> > vim +1279 net/core/rtnetlink.c
> >
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1189 static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1190 struct net_device *dev,
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1191 int vfs_num,
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1192 struct nlattr *vfinfo)
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1193 {
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1194 struct ifla_vf_rss_query_en vf_rss_query_en;
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1195 struct nlattr *vf, *vfstats, *vfvlanlist;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1196 struct ifla_vf_link_state vf_linkstate;
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1197 struct ifla_vf_vlan_info vf_vlan_info;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1198 struct ifla_vf_spoofchk vf_spoofchk;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1199 struct ifla_vf_tx_rate vf_tx_rate;
> > 3b766cd832328f Eran Ben Elisha 2015-06-15 1200 struct ifla_vf_stats vf_stats;
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1201 struct ifla_vf_trust vf_trust;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1202 struct ifla_vf_vlan vf_vlan;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1203 struct ifla_vf_rate vf_rate;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1204 struct ifla_vf_mac vf_mac;
> > 75345f888f700c Denis Kirjanov 2019-06-17 1205 struct ifla_vf_broadcast vf_broadcast;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1206 struct ifla_vf_info ivi;
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1207 struct ifla_vf_guid node_guid;
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1208 struct ifla_vf_guid port_guid;
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1209
> > 0eed9cf58446b2 Mintz, Yuval 2017-06-07 1210 memset(&ivi, 0, sizeof(ivi));
> > 0eed9cf58446b2 Mintz, Yuval 2017-06-07 1211
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1212 /* Not all SR-IOV capable drivers support the
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1213 * spoofcheck and "RSS query enable" query. Preset to
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1214 * -1 so the user space tool can detect that the driver
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1215 * didn't report anything.
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1216 */
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1217 ivi.spoofchk = -1;
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1218 ivi.rss_query_en = -1;
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1219 ivi.trusted = -1;
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1220 /* The default value for VF link state is "auto"
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1221 * IFLA_VF_LINK_STATE_AUTO which equals zero
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1222 */
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1223 ivi.linkstate = 0;
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1224 /* VLAN Protocol by default is 802.1Q */
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1225 ivi.vlan_proto = htons(ETH_P_8021Q);
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1226 if (dev->netdev_ops->ndo_get_vf_config(dev, vfs_num, &ivi))
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1227 return 0;
> > b22b941b2c253a Hannes Frederic Sowa 2015-11-17 1228
> > 775f4f05501b3e Dan Carpenter 2016-10-13 1229 memset(&vf_vlan_info, 0, sizeof(vf_vlan_info));
> > 775f4f05501b3e Dan Carpenter 2016-10-13 1230
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1231 vf_mac.vf =
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1232 vf_vlan.vf =
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1233 vf_vlan_info.vf =
> > ed616689a3d95e Sucheta Chakraborty 2014-05-22 1234 vf_rate.vf =
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1235 vf_tx_rate.vf =
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1236 vf_spoofchk.vf =
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1237 vf_linkstate.vf =
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1238 vf_rss_query_en.vf =
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1239 vf_trust.vf = ivi.vf;
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1240
> > c02db8c6290bb9 Chris Wright 2010-05-16 1241 memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac));
> > 75345f888f700c Denis Kirjanov 2019-06-17 1242 memcpy(vf_broadcast.broadcast, dev->broadcast, dev->addr_len);
> > c02db8c6290bb9 Chris Wright 2010-05-16 1243 vf_vlan.vlan = ivi.vlan;
> > c02db8c6290bb9 Chris Wright 2010-05-16 1244 vf_vlan.qos = ivi.qos;
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1245 vf_vlan_info.vlan = ivi.vlan;
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1246 vf_vlan_info.qos = ivi.qos;
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1247 vf_vlan_info.vlan_proto = ivi.vlan_proto;
> > ed616689a3d95e Sucheta Chakraborty 2014-05-22 1248 vf_tx_rate.rate = ivi.max_tx_rate;
> > ed616689a3d95e Sucheta Chakraborty 2014-05-22 1249 vf_rate.min_tx_rate = ivi.min_tx_rate;
> > ed616689a3d95e Sucheta Chakraborty 2014-05-22 1250 vf_rate.max_tx_rate = ivi.max_tx_rate;
> > 5f8444a3fa6170 Greg Rose 2011-10-08 1251 vf_spoofchk.setting = ivi.spoofchk;
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1252 vf_linkstate.link_state = ivi.linkstate;
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1253 vf_rss_query_en.setting = ivi.rss_query_en;
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1254 vf_trust.setting = ivi.trusted;
> > ae0be8de9a53cd Michal Kubecek 2019-04-26 1255 vf = nla_nest_start_noflag(skb, IFLA_VF_INFO);
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1256 if (!vf)
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1257 goto nla_put_vfinfo_failure;
> > a6574349d068cb David S. Miller 2012-04-01 1258 if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
> > 75345f888f700c Denis Kirjanov 2019-06-17 1259 nla_put(skb, IFLA_VF_BROADCAST, sizeof(vf_broadcast), &vf_broadcast) ||
> > a6574349d068cb David S. Miller 2012-04-01 1260 nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
> > ed616689a3d95e Sucheta Chakraborty 2014-05-22 1261 nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
> > ed616689a3d95e Sucheta Chakraborty 2014-05-22 1262 &vf_rate) ||
> > a6574349d068cb David S. Miller 2012-04-01 1263 nla_put(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate),
> > a6574349d068cb David S. Miller 2012-04-01 1264 &vf_tx_rate) ||
> > a6574349d068cb David S. Miller 2012-04-01 1265 nla_put(skb, IFLA_VF_SPOOFCHK, sizeof(vf_spoofchk),
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1266 &vf_spoofchk) ||
> > 1d8faf48c74b83 Rony Efraim 2013-06-13 1267 nla_put(skb, IFLA_VF_LINK_STATE, sizeof(vf_linkstate),
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1268 &vf_linkstate) ||
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1269 nla_put(skb, IFLA_VF_RSS_QUERY_EN,
> > 01a3d796813d63 Vlad Zolotarov 2015-03-30 1270 sizeof(vf_rss_query_en),
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1271 &vf_rss_query_en) ||
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1272 nla_put(skb, IFLA_VF_TRUST,
> > dd461d6aa89476 Hiroshi Shimamoto 2015-08-28 1273 sizeof(vf_trust), &vf_trust))
> > 79aab093a0b537 Moshe Shemesh 2016-09-22 1274 goto nla_put_vf_failure;
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1275 if (dev->netdev_ops->ndo_get_vf_guid &&
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1276 !dev->netdev_ops->ndo_get_vf_guid(dev, vfs_num, &node_guid,
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1277 &port_guid)) {
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1278 if (nla_put(skb, IFLA_VF_IB_NODE_GUID, sizeof(node_guid),
> > a209fe95d542e8 Danit Goldberg 2019-11-06 @1279 &node_guid) ||
> > a209fe95d542e8 Danit Goldberg 2019-11-06 1280 nla_put(skb, IFLA_VF_IB_PORT_GUID, sizeof(port_guid),
> > a209fe95d542e8 Danit Goldberg 2019-11-06 @1281 &port_guid))
> >
> > These definitely seem like real bugs. We need to
> >
> > memset(&node_guid, 0, sizeof(node_guid));
> > memset(&port_guid, 0, sizeof(port_guid));
> >
> > Using an initializer = {} is not sufficient to clear struct holes. I
> > hope that we don't need to memzero_explicit() these like the very
> > paranoid folks say. :(
>
>
> Dan,
>
> How is it possible to leak? We are putting node_guid and port_guid after
> successful return of ndo_get_vf_guid(). It will ensure that GUIDs are
> initialized.
There is a 4 byte struct hole after node_guid.vf.
-> ipoib_get_vf_guid()
-> ib_get_vf_guid()
-> mlx5_ib_get_vf_guid()
mlx5_ib_get_vf_guid() doesn't have a memset(), plus relying on drivers
to clear the struct hole is unsafe.
regards,
dan carpenter
1 year, 3 months