From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 008C5C433FE for ; Thu, 16 Dec 2021 15:12:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235345AbhLPPMj convert rfc822-to-8bit (ORCPT ); Thu, 16 Dec 2021 10:12:39 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:4300 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbhLPPMh (ORCPT ); Thu, 16 Dec 2021 10:12:37 -0500 Received: from fraeml715-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JFFtb1m2gz67DWp; Thu, 16 Dec 2021 23:11:03 +0800 (CST) Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by fraeml715-chm.china.huawei.com (10.206.15.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 16 Dec 2021 16:12:35 +0100 Received: from fraeml714-chm.china.huawei.com ([10.206.15.33]) by fraeml714-chm.china.huawei.com ([10.206.15.33]) with mapi id 15.01.2308.020; Thu, 16 Dec 2021 16:12:35 +0100 From: Roberto Sassu To: "airlied@linux.ie" , "kraxel@redhat.com" , "daniel@ffwll.ch" CC: "dri-devel@lists.freedesktop.org" , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com" Subject: RE: [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Thread-Topic: [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Thread-Index: AQHX8E+19jelqmPilEqoid7n1sYbcaw1Pc8Q Date: Thu, 16 Dec 2021 15:12:35 +0000 Message-ID: <4b0d93611e8740afbf25870e8b54a8e9@huawei.com> References: <20211213183122.838119-1-roberto.sassu@huawei.com> In-Reply-To: <20211213183122.838119-1-roberto.sassu@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.204.63.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Roberto Sassu > Sent: Monday, December 13, 2021 7:31 PM > If virtio_gpu_object_shmem_init() fails (e.g. due to fault injection, as it > happened in the bug report by syzbot), virtio_gpu_array_put_free() could be > called with objs equal to NULL. > > Ensure that objs is not NULL in virtio_gpu_array_put_free(), or otherwise > return from the function. Hello did you have the chance to look at this patch? Thanks Roberto HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Li Peng, Zhong Ronghua > Cc: stable@vger.kernel.org # 5.13.x > Signed-off-by: Roberto Sassu > Reported-by: syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com > Fixes: 377f8331d0565 ("drm/virtio: fix possible leak/unlock > virtio_gpu_object_array") > --- > drivers/gpu/drm/virtio/virtgpu_gem.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c > b/drivers/gpu/drm/virtio/virtgpu_gem.c > index 2de61b63ef91..48d3c9955f0d 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_gem.c > +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c > @@ -248,6 +248,9 @@ void virtio_gpu_array_put_free(struct > virtio_gpu_object_array *objs) > { > u32 i; > > + if (!objs) > + return; > + > for (i = 0; i < objs->nents; i++) > drm_gem_object_put(objs->objs[i]); > virtio_gpu_array_free(objs); > -- > 2.32.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21EC3C433F5 for ; Thu, 16 Dec 2021 15:12:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DB3C10E90F; Thu, 16 Dec 2021 15:12:39 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id B477E10E917 for ; Thu, 16 Dec 2021 15:12:38 +0000 (UTC) Received: from fraeml715-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JFFtb1m2gz67DWp; Thu, 16 Dec 2021 23:11:03 +0800 (CST) Received: from fraeml714-chm.china.huawei.com (10.206.15.33) by fraeml715-chm.china.huawei.com (10.206.15.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 16 Dec 2021 16:12:35 +0100 Received: from fraeml714-chm.china.huawei.com ([10.206.15.33]) by fraeml714-chm.china.huawei.com ([10.206.15.33]) with mapi id 15.01.2308.020; Thu, 16 Dec 2021 16:12:35 +0100 From: Roberto Sassu To: "airlied@linux.ie" , "kraxel@redhat.com" , "daniel@ffwll.ch" Subject: RE: [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Thread-Topic: [PATCH] drm/virtio: Ensure that objs is not NULL in virtio_gpu_array_put_free() Thread-Index: AQHX8E+19jelqmPilEqoid7n1sYbcaw1Pc8Q Date: Thu, 16 Dec 2021 15:12:35 +0000 Message-ID: <4b0d93611e8740afbf25870e8b54a8e9@huawei.com> References: <20211213183122.838119-1-roberto.sassu@huawei.com> In-Reply-To: <20211213183122.838119-1-roberto.sassu@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.204.63.33] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "stable@vger.kernel.org" , "syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "virtualization@lists.linux-foundation.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" > From: Roberto Sassu > Sent: Monday, December 13, 2021 7:31 PM > If virtio_gpu_object_shmem_init() fails (e.g. due to fault injection, as = it > happened in the bug report by syzbot), virtio_gpu_array_put_free() could = be > called with objs equal to NULL. >=20 > Ensure that objs is not NULL in virtio_gpu_array_put_free(), or otherwise > return from the function. Hello did you have the chance to look at this patch? Thanks Roberto HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Li Peng, Zhong Ronghua > Cc: stable@vger.kernel.org # 5.13.x > Signed-off-by: Roberto Sassu > Reported-by: syzbot+e9072e90624a31dfa85f@syzkaller.appspotmail.com > Fixes: 377f8331d0565 ("drm/virtio: fix possible leak/unlock > virtio_gpu_object_array") > --- > drivers/gpu/drm/virtio/virtgpu_gem.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c > b/drivers/gpu/drm/virtio/virtgpu_gem.c > index 2de61b63ef91..48d3c9955f0d 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_gem.c > +++ b/drivers/gpu/drm/virtio/virtgpu_gem.c > @@ -248,6 +248,9 @@ void virtio_gpu_array_put_free(struct > virtio_gpu_object_array *objs) > { > u32 i; >=20 > + if (!objs) > + return; > + > for (i =3D 0; i < objs->nents; i++) > drm_gem_object_put(objs->objs[i]); > virtio_gpu_array_free(objs); > -- > 2.32.0