Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4862891ybl; Mon, 9 Dec 2019 18:32:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyB1xankKQYWzBSw+ZxveKr5Uh6rmLv9pX9ZgwqXjFhdc//4OPPT8lnfLeyzJizyqYA4Kkl X-Received: by 2002:aca:47d7:: with SMTP id u206mr2110335oia.79.1575945120798; Mon, 09 Dec 2019 18:32:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575945120; cv=none; d=google.com; s=arc-20160816; b=Fvb7Cg49wLdd4LMQvNVsW5d+1WWlg/e3/P+NaiTRos8SOrGMu7dbleD8xK2lHH0u/k YS1IONJUS1i79B9ZxTN0dUYu1lD/Kut+p5Qy3kYt7p5MjBM17G3wDgYM6UOqrqzHEyt/ rK+0sLos32jbDrd2Og8XWyBXLG6+lKtUM9jikDbVEGU+dbAwWJfWLG75cgR7q4HSSAm0 SJSjcvBt+Qf/GW7ZhjIfgm107OZKI5vCwPBKBLBJrKvdh9yIH501ffka0/18Jebi+bKm lrtauxZUgjJVkS46sf1k/ezLpxkMiL6ZYWw493X5vfshNDlKNW9zFDPwneXPWy6JvI36 hU1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:organization :references:in-reply-to:date:cc:to:reply-to:from:subject:message-id; bh=3eQYS6CH7YNIncw6ykokKEd9VeuBYnSk7rK5QjcOWUE=; b=lPy0VvY17i3l4M3Vc/cxL8uqVCIIExoKG278eCteG9xGSZMucfh45wf8rCO8b3GiaU hnbQ8wLwaTBPt3r0wPdVhqN23RFt2VCQQNJyVH7B/3oOmoZOqdmyyZeNYMRM/7aQedaj CPOjVqnw7j9WkNaiVAkrAykL3yrZPyhvHVgjgeVcStKQAkp3DwoKIg8VZ7AwmTUe9zrA ZtlcmatjuYO8ClAFUhGX4Uc/zKpvlJH75niKnf64ZnZfdg22QRTYMctVdoEkjPXd985Q MLXG1d5DjQor41WE1pq1Gc+EaNKpe1MVFS88bgBl3HSXU4vcRiBvyGDmprq8r30it45/ KZpg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q65si1210597oic.78.2019.12.09.18.31.48; Mon, 09 Dec 2019 18:32:00 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726673AbfLJCau (ORCPT + 99 others); Mon, 9 Dec 2019 21:30:50 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:52088 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726509AbfLJCat (ORCPT ); Mon, 9 Dec 2019 21:30:49 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id 18DB128ADDD Message-ID: <2a6629b95f9c8a5f41ec783ef2e39f5cba8e7a20.camel@collabora.com> Subject: Re: [PATCH v2] uvcvideo: Also validate buffers in BULK mode From: Nicolas Dufresne Reply-To: Nicolas Dufresne To: Nicolas Dufresne Cc: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 09 Dec 2019 21:30:44 -0500 In-Reply-To: References: <2206409.jVpTcjFX6j@avalon> <20180605234607.5334-1-nicolas.dufresne@collabora.com> Organization: Collabora Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-W5rmSR8ZLiNuf29ErQEm" User-Agent: Evolution 3.34.1 (3.34.1-1.fc31) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-W5rmSR8ZLiNuf29ErQEm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le lundi 09 d=C3=A9cembre 2019 =C3=A0 21:27 -0500, Nicolas Dufresne a =C3= =A9crit : > Le mardi 05 juin 2018 =C3=A0 19:46 -0400, Nicolas Dufresne a =C3=A9crit : > > Just like for ISOC, validate the decoded BULK buffer size when possible= . > > This avoids sending corrupted or partial buffers to userspace, which ma= y > > lead to application crash or run-time failure. > >=20 > > Signed-off-by: Nicolas Dufresne >=20 > Ping. That was a year and a half ago and still applies. Please ignore, I was looking into the wrong branch by accident. Please, update patchwork, that might also help to avoid confusion. >=20 > > --- > > drivers/media/usb/uvc/uvc_video.c | 9 +++------ > > 1 file changed, 3 insertions(+), 6 deletions(-) > >=20 > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/= uvc_video.c > > index aa0082fe5833..025ffac196f3 100644 > > --- a/drivers/media/usb/uvc/uvc_video.c > > +++ b/drivers/media/usb/uvc/uvc_video.c > > @@ -1234,6 +1234,7 @@ static void uvc_video_next_buffers(struct uvc_str= eaming *stream, > > *meta_buf =3D uvc_queue_next_buffer(&stream->meta.queue, > > *meta_buf); > > } > > + uvc_video_validate_buffer(stream, *video_buf); > > *video_buf =3D uvc_queue_next_buffer(&stream->queue, *video_buf); > > } > > =20 > > @@ -1258,10 +1259,8 @@ static void uvc_video_decode_isoc(struct urb *ur= b, struct uvc_streaming *stream, > > do { > > ret =3D uvc_video_decode_start(stream, buf, mem, > > urb->iso_frame_desc[i].actual_length); > > - if (ret =3D=3D -EAGAIN) { > > - uvc_video_validate_buffer(stream, buf); > > + if (ret =3D=3D -EAGAIN) > > uvc_video_next_buffers(stream, &buf, &meta_buf); > > - } > > } while (ret =3D=3D -EAGAIN); > > =20 > > if (ret < 0) > > @@ -1277,10 +1276,8 @@ static void uvc_video_decode_isoc(struct urb *ur= b, struct uvc_streaming *stream, > > uvc_video_decode_end(stream, buf, mem, > > urb->iso_frame_desc[i].actual_length); > > =20 > > - if (buf->state =3D=3D UVC_BUF_STATE_READY) { > > - uvc_video_validate_buffer(stream, buf); > > + if (buf->state =3D=3D UVC_BUF_STATE_READY) > > uvc_video_next_buffers(stream, &buf, &meta_buf); > > - } > > } > > } > > =20 --=-W5rmSR8ZLiNuf29ErQEm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSScpfJiL+hb5vvd45xUwItrAaoHAUCXe8DVAAKCRBxUwItrAao HLiXAKDDXZH4okqc7Ii0nCheYAYH/tLAKQCfSK7KLBI5mTlGuV9GEwlDHaO3U0Y= =pUSr -----END PGP SIGNATURE----- --=-W5rmSR8ZLiNuf29ErQEm--