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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01E2EC432C0 for ; Fri, 22 Nov 2019 11:22:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CAAF720718 for ; Fri, 22 Nov 2019 11:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574421726; bh=SWnbQ6ESsCx2svhKme4+smyFG/NDFa640/NUKAqdQIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zeIzZchbUvniFxEMY5+VYafCz+BoBTfDuPBCtRffRm/DD5Pyaz/0JdEetUReOhC1u kb/G6seNXBRJ7j+bcs2xHQcQWBSksuDciASano/N6G6MwZwrTSHax2wLXwUjTTcdKn JtKIlv+WW3EvyMvYJcYaNEN+fIUGg/Mx4+H7qeRg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727894AbfKVLWC (ORCPT ); Fri, 22 Nov 2019 06:22:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:49982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729313AbfKVKoI (ORCPT ); Fri, 22 Nov 2019 05:44:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6213C20715; Fri, 22 Nov 2019 10:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419447; bh=SWnbQ6ESsCx2svhKme4+smyFG/NDFa640/NUKAqdQIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Db4ORN48y/HTZuLuvlKrNTlIfqGf9zrT4+7RayxMjAnx+/iQ2qgxRWNwK+IrXKvL4 FhhMpRl2fWRAzs+sx0MkgEKqXO3HGSIWP3vFhGOn5vhlkZx5B/ggRP/xF4lCWF4nC8 u24Bw8+SQSxoG2gdRpTZW6uUETMpuw9UZ9rP6Ogw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joel Pepper , Kieran Bingham , Laurent Pinchart , Sasha Levin Subject: [PATCH 4.9 113/222] usb: gadget: uvc: configfs: Prevent format changes after linking header Date: Fri, 22 Nov 2019 11:27:33 +0100 Message-Id: <20191122100911.383044288@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100830.874290814@linuxfoundation.org> References: <20191122100830.874290814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Joel Pepper [ Upstream commit cb2200f7af8341aaf0c6abd7ba37e4c667c41639 ] While checks are in place to avoid attributes and children of a format being manipulated after the format is linked into the streaming header, the linked flag was never actually set, invalidating the protections. Update the flag as appropriate in the header link calls. Signed-off-by: Joel Pepper Reviewed-by: Kieran Bingham Signed-off-by: Laurent Pinchart Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/uvc_configfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index 3803dda54666b..3d843e14447bb 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c @@ -772,6 +772,7 @@ static int uvcg_streaming_header_allow_link(struct config_item *src, format_ptr->fmt = target_fmt; list_add_tail(&format_ptr->entry, &src_hdr->formats); ++src_hdr->num_fmt; + ++target_fmt->linked; out: mutex_unlock(&opts->lock); @@ -810,6 +811,8 @@ static int uvcg_streaming_header_drop_link(struct config_item *src, break; } + --target_fmt->linked; + out: mutex_unlock(&opts->lock); mutex_unlock(su_mutex); -- 2.20.1