Message ID | nycvar.YFH.7.76.2106241310000.18969@cbobk.fhfr.pm (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] drm/amdgpu: Avoid printing of stack contents on firmware load error | expand |
On Thu, 24 Jun 2021, Jiri Kosina wrote: > From: Jiri Kosina <jkosina@suse.cz> > > In case when psp_init_asd_microcode() fails to load ASD microcode file, > psp_v12_0_init_microcode() tries to print the firmware filename that > failed to load before bailing out. > > This is wrong because: > > - the firmware filename it would want it print is an incorrect one as > psp_init_asd_microcode() and psp_v12_0_init_microcode() are loading > different filenames > - it tries to print fw_name, but that's not yet been initialized by that > time, so it prints random stack contents, e.g. > > amdgpu 0000:04:00.0: Direct firmware load for amdgpu/renoir_asd.bin failed with error -2 > amdgpu 0000:04:00.0: amdgpu: fail to initialize asd microcode > amdgpu 0000:04:00.0: amdgpu: psp v12.0: Failed to load firmware "\xfeTO\x8e\xff\xff" > > Fix that by bailing out immediately, instead of priting the bogus error > message. Friendly ping on this one too; priting a few bytes of stack is not a *huge* info leak, but I believe it should be fixed nevertheless. Thanks. > > Reported-by: Vojtech Pavlik <vojtech@ucw.cz> > Signed-off-by: Jiri Kosina <jkosina@suse.cz> > --- > > v1 -> v2: remove now-unused label > > drivers/gpu/drm/amd/amdgpu/psp_v12_0.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c > index c4828bd3264b..b0ee77ee80b9 100644 > --- a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c > @@ -67,7 +67,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) > > err = psp_init_asd_microcode(psp, chip_name); > if (err) > - goto out; > + return err; > > snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name); > err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev); > @@ -80,7 +80,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) > } else { > err = amdgpu_ucode_validate(adev->psp.ta_fw); > if (err) > - goto out2; > + goto out; > > ta_hdr = (const struct ta_firmware_header_v1_0 *) > adev->psp.ta_fw->data; > @@ -105,10 +105,9 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) > > return 0; > > -out2: > +out: > release_firmware(adev->psp.ta_fw); > adev->psp.ta_fw = NULL; > -out: > if (err) { > dev_err(adev->dev, > "psp v12.0: Failed to load firmware \"%s\"\n", > -- > 2.12.3 >
Applied. Thanks! Alex On Thu, Jul 1, 2021 at 4:33 AM Jiri Kosina <jikos@kernel.org> wrote: > > On Thu, 24 Jun 2021, Jiri Kosina wrote: > > > From: Jiri Kosina <jkosina@suse.cz> > > > > In case when psp_init_asd_microcode() fails to load ASD microcode file, > > psp_v12_0_init_microcode() tries to print the firmware filename that > > failed to load before bailing out. > > > > This is wrong because: > > > > - the firmware filename it would want it print is an incorrect one as > > psp_init_asd_microcode() and psp_v12_0_init_microcode() are loading > > different filenames > > - it tries to print fw_name, but that's not yet been initialized by that > > time, so it prints random stack contents, e.g. > > > > amdgpu 0000:04:00.0: Direct firmware load for amdgpu/renoir_asd.bin failed with error -2 > > amdgpu 0000:04:00.0: amdgpu: fail to initialize asd microcode > > amdgpu 0000:04:00.0: amdgpu: psp v12.0: Failed to load firmware "\xfeTO\x8e\xff\xff" > > > > Fix that by bailing out immediately, instead of priting the bogus error > > message. > > Friendly ping on this one too; priting a few bytes of stack is not a > *huge* info leak, but I believe it should be fixed nevertheless. > > Thanks. > > > > > Reported-by: Vojtech Pavlik <vojtech@ucw.cz> > > Signed-off-by: Jiri Kosina <jkosina@suse.cz> > > > > --- > > > > v1 -> v2: remove now-unused label > > > > drivers/gpu/drm/amd/amdgpu/psp_v12_0.c | 7 +++---- > > 1 file changed, 3 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c > > index c4828bd3264b..b0ee77ee80b9 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c > > +++ b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c > > @@ -67,7 +67,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) > > > > err = psp_init_asd_microcode(psp, chip_name); > > if (err) > > - goto out; > > + return err; > > > > snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name); > > err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev); > > @@ -80,7 +80,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) > > } else { > > err = amdgpu_ucode_validate(adev->psp.ta_fw); > > if (err) > > - goto out2; > > + goto out; > > > > ta_hdr = (const struct ta_firmware_header_v1_0 *) > > adev->psp.ta_fw->data; > > @@ -105,10 +105,9 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) > > > > return 0; > > > > -out2: > > +out: > > release_firmware(adev->psp.ta_fw); > > adev->psp.ta_fw = NULL; > > -out: > > if (err) { > > dev_err(adev->dev, > > "psp v12.0: Failed to load firmware \"%s\"\n", > > -- > > 2.12.3 > > > > -- > Jiri Kosina > SUSE Labs > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c index c4828bd3264b..b0ee77ee80b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v12_0.c @@ -67,7 +67,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) err = psp_init_asd_microcode(psp, chip_name); if (err) - goto out; + return err; snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name); err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev); @@ -80,7 +80,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) } else { err = amdgpu_ucode_validate(adev->psp.ta_fw); if (err) - goto out2; + goto out; ta_hdr = (const struct ta_firmware_header_v1_0 *) adev->psp.ta_fw->data; @@ -105,10 +105,9 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) return 0; -out2: +out: release_firmware(adev->psp.ta_fw); adev->psp.ta_fw = NULL; -out: if (err) { dev_err(adev->dev, "psp v12.0: Failed to load firmware \"%s\"\n",