Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5262084imu; Tue, 13 Nov 2018 03:57:06 -0800 (PST) X-Google-Smtp-Source: AJdET5ddon70vPk57+wHJE/kde1encOTEs/4e/uI3nXqVUlmnTuP/L5l/Z0q7SvXWJLgZOoyTpQd X-Received: by 2002:a17:902:32a4:: with SMTP id z33-v6mr4674529plb.168.1542110226692; Tue, 13 Nov 2018 03:57:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542110226; cv=none; d=google.com; s=arc-20160816; b=0qJqegURBLgYtxSrpI3Dwb0YFT0z1t8KsJdfCesbL6mhZ8QiUSL6EGP63KqF60dve1 pBlBgQhBfVBcmh+IBAz5cUraivzvilRQRulsJu0X7dWuEpxWHPruLaYkcdPwoI9uwoXr +9mAXz31F0fOcICmIqSA+W6XSH3zorG7NDxEy+ryPHn0tPiUd4Gcod071d2xbRxlXeqO 8lQHlLXNRvin5m1AYSGBNJBw4pJx+KcjjeH/NVHnARvyezaGNpA/gKgxyRHloJGuiEET dHfPlPME3hdDLAxyZGWnru6+grfXRxmpargGQ9vdBc44pTGaiWph7qpmOc1LcVQOkRuB ynRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ivDOzBEtlyPbPYctVqqFx6VO1Rok336D40Hewx59/EQ=; b=IhxaGIxjuNTNQHdnJ2s2X6wha/hGLY3hujpTQhzc0ELD/YIUWCY8ldv4q51d/u9yMs iPJxlBH7lIMuEnsJHOgAlIAdvQVklUZ938D77bdf8H7BoDfHsVljbV5u6EqnLG1Oe91V 99OAP4cfxtQWPJYx0YG1rHCFgpRexcKRWNdK81BpLYcu+LPSY7trpo+UhExfoMImld+N WPlRy8yViwc7wTqyETkqIa+IUiqxDM55M7s5bwJ6unsxrA+WCnQk/X9waG8bN5KEqp2M zJjO74wES0LnL2t9qrVTfwXbXItZ4NDwmEbFbbyztSL8Q5hwXgIIuv2m5xjgSXh2Y4Aq 5ZLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2si19093991pgo.483.2018.11.13.03.56.51; Tue, 13 Nov 2018 03:57:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732766AbeKMVyL (ORCPT + 99 others); Tue, 13 Nov 2018 16:54:11 -0500 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:35241 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbeKMVyL (ORCPT ); Tue, 13 Nov 2018 16:54:11 -0500 Received: from [IPv6:2001:420:44c1:2579:cc8b:c08b:b11b:69b9] ([IPv6:2001:420:44c1:2579:cc8b:c08b:b11b:69b9]) by smtp-cloud7.xs4all.net with ESMTPA id MXIogpYNQRKKoMXIrgIG8V; Tue, 13 Nov 2018 12:56:21 +0100 Subject: Re: [PATCH] media: videobuf2-core: Fix error handling when fileio is deallocated To: Marek Szyprowski , Myungho Jung , pawel@osciak.com, kyungmin.park@samsung.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181112004951.GA3948@myunghoj-Precision-5530> <9402424d-6e0c-b628-c6c2-8f87b5276a36@samsung.com> From: Hans Verkuil Message-ID: <636c6ed7-25ef-fd51-4555-3aeb28e96f89@xs4all.nl> Date: Tue, 13 Nov 2018 12:56:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <9402424d-6e0c-b628-c6c2-8f87b5276a36@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfMGbsIzdaBLUSPh+IQe4kaKPqKkZ/6RSQ3hMGP5fNDzhxWzIiFuWXF2HQZG6xcM/0RLDo1nio+UKR9EJktGMiCM1uzkPXp7pU+VcM9fxDlcsRKlm01R7 hx0R7LoBoVwP8L8vQNmuZFmkH0X3o22Mkuz7EAuudlU2uPYy4eg3SXz3/el8JyeDcvx38FeAT+f5lUUYnauUk2Me66M1kEFMdIZWUtYMU/Ksqi/guYyO2vvf uQCLPj3gR496QY3J9t9i9B+CVGyNukv+OsluewyFFMdZN/VlSdzN2FttdiIT7jr0ZVVdbP2/MAvMmDccbsua1xE64T71L78Di/762AM0iTtyyEA/Y8AKesef g3Z5TbaYlf11HVN8Fr0oaxc6cSLia8Zc0iaIP/FIw48rWZZVLuXCQFySL03tM88jdMWWMcqzQRy6ExUijXnaBca3jsw88Q7DHCDOlwIE9UM0ll1SSV4ktzXS Yn8NnNCBSsHdBLNa Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/13/18 11:27, Marek Szyprowski wrote: > Hi Myungho, > > On 2018-11-12 01:49, Myungho Jung wrote: >> The mutex that is held from vb2_fop_read() can be unlocked while waiting >> for a buffer if the queue is streaming and blocking. Meanwhile, fileio >> can be released. So, it should return an error if the fileio address is >> changed. >> >> Signed-off-by: Myungho Jung >> Reported-by: syzbot+4180ff9ca6810b06c1e9@syzkaller.appspotmail.com > > Acked-by: Marek Szyprowski Sorry: Nacked-by: Hans Verkuil This addresses the symptom, not the underlying cause. I have a patch that fixes the actual cause that I plan to post soon after I review it a bit more. Regards, Hans > > Thanks for analyzing the code and fixing this issue! > >> --- >> drivers/media/common/videobuf2/videobuf2-core.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c >> index 975ff5669f72..bff94752eb27 100644 >> --- a/drivers/media/common/videobuf2/videobuf2-core.c >> +++ b/drivers/media/common/videobuf2/videobuf2-core.c >> @@ -2564,6 +2564,10 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ >> dprintk(5, "vb2_dqbuf result: %d\n", ret); >> if (ret) >> return ret; >> + if (fileio != q->fileio) { >> + dprintk(3, "fileio deallocated\n"); >> + return -EFAULT; >> + } >> fileio->dq_count += 1; >> >> fileio->cur_index = index; > > Best regards >