From patchwork Fri Sep 29 15:42:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13404542 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 60CEDE728C0 for ; Fri, 29 Sep 2023 15:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233517AbjI2PmU (ORCPT ); Fri, 29 Sep 2023 11:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjI2PmT (ORCPT ); Fri, 29 Sep 2023 11:42:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3A8B4; Fri, 29 Sep 2023 08:42:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69593C433C7; Fri, 29 Sep 2023 15:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696002136; bh=Zl9IzDfJ74tSHG7Bo3AkrSgoNzTjNILJUvTaD+C2hpM=; h=Date:From:To:Cc:Subject:From; b=qyDMdW5b+k9YsTcDHVa6jtbOihi/nlM/xncg5bZPJCRQEuUEtK6jXE+OoW58OSQKD ZgwbxqXxdZAEhgaBpWo1c6XxZXkhcZxQDzvkVFpR2DU9DUyFLlUaKG82/Y8YTNd8xi O0d0hVUy/uqd4PbDUTXeIbpEcm8etsmdMnXgFmi3YG/Rq2A8LhFPDcVj5uCKaLcWOc ohsuJ5/hPAQT39aQW/NCjmO153g/RPL8acTQLExpvutAuJQEAvtDUH8TEmcY4LJcTv rMg8SZZn5zoIF+WcA/LUJT8UlLl173AXx+XZ1ysj4XwrpKtIvsUSoTcTAcC9B13QIb /KAO3+pqJztOQ== Date: Fri, 29 Sep 2023 17:42:11 +0200 From: "Gustavo A. R. Silva" To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] media: usb: siano: Fix undefined behavior bug in struct smsusb_urb_t Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org `struct urb` is a flexible structure, which means that it contains a flexible-array member at the bottom. This could potentially lead to an overwrite of the object `wq` at run-time with the contents of `urb`. Fix this by placing object `urb` at the end of `struct smsusb_urb_t`. Fixes: dd47fbd40e6e ("[media] smsusb: don't sleep while atomic") Cc: stable@vger.kernel.org Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- drivers/media/usb/siano/smsusb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c index 9d9e14c858e6..2c048f8e8371 100644 --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -40,10 +40,10 @@ struct smsusb_urb_t { struct smscore_buffer_t *cb; struct smsusb_device_t *dev; - struct urb urb; - /* For the bottom half */ struct work_struct wq; + + struct urb urb; }; struct smsusb_device_t {