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 2DA00C636D6 for ; Wed, 22 Feb 2023 13:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbjBVNPE (ORCPT ); Wed, 22 Feb 2023 08:15:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbjBVNPC (ORCPT ); Wed, 22 Feb 2023 08:15:02 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8845738E8B for ; Wed, 22 Feb 2023 05:15:00 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so633850pjb.3 for ; Wed, 22 Feb 2023 05:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LXwDDYUk3+Q4/nNJtasmLY4w5AET06sCuMInR3j34Fk=; b=WVUUpyjOVVsoYXGoEZoyfG1Mdqsy+Exa2PxS+69m0zj35qS5THqNyXOfJtB0m5eCY+ dGp0oHsLLr2vWjikDNF2/YRZNgBg5aRPV3dpW2KdjaOsK7E7UHpBcaDjWA9JYyJS7YA9 2kIyhkYv8OqfnXcY2sXz+p/qhUSkiOqKu4jTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LXwDDYUk3+Q4/nNJtasmLY4w5AET06sCuMInR3j34Fk=; b=2klWXr51aMk5GFlyzKPB9IS4EETLU9i+jOTi0oh14L9q9TjTsvraxFfmKECfmiZpLU K0Hzf0AlnUJxwO0fHOWzvRhQip2V6fJo4h6ffbR00U548kT/ocWQ5Yt0ULgv71eTbwkC cd8egKw9wUPTQWEClSdlQU7PZvIjnG7DAKPj/nIX4f7q5Mu837bs1JJBDBOqaxILunkm o4PQmKqw1HCOFMaBmvm6eznKABsBbm9DdaAZ7367jfvFAJA7m/Xuj35xPYusAGOQhcy0 vrq8Zb/OCH6mOSH/vKIAsfHbafTzeUgz+5ziDMwYnl5KtaPxHMMSbqz9UMcSIT21AXm1 BmpQ== X-Gm-Message-State: AO0yUKVyMz9zdCRwWIxbWa4M+A6hgc2mcZyIw0DWMFCy4KKP3nnmKu9+ FDn75DS5Hq/tocBgKAmpXlB3CduCGsS0950s X-Google-Smtp-Source: AK7set8ghI8iXqpjhMQ//Cyexs4/VsbHQ0yJc5VZVjs5PppE8Rl6di4RgB0wB2V1tCR+V3DMcX23MA== X-Received: by 2002:a17:902:facd:b0:19a:a647:1881 with SMTP id ld13-20020a170902facd00b0019aa6471881mr7551300plb.62.1677071699463; Wed, 22 Feb 2023 05:14:59 -0800 (PST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com. [209.85.210.175]) by smtp.gmail.com with ESMTPSA id c2-20020a170902d90200b00199193e5ea1sm8008142plz.61.2023.02.22.05.14.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Feb 2023 05:14:58 -0800 (PST) Received: by mail-pf1-f175.google.com with SMTP id b20so5111506pfo.6 for ; Wed, 22 Feb 2023 05:14:58 -0800 (PST) X-Received: by 2002:a62:c143:0:b0:593:d4cb:dba2 with SMTP id i64-20020a62c143000000b00593d4cbdba2mr1125866pfg.13.1677071697448; Wed, 22 Feb 2023 05:14:57 -0800 (PST) MIME-Version: 1.0 References: <20230106061659.never.817-kees@kernel.org> <202301061217.816FC0313D@keescook> In-Reply-To: From: Ricardo Ribalda Date: Wed, 22 Feb 2023 14:14:46 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: uvcvideo: Silence memcpy() run-time false positive warnings To: Andy Shevchenko Cc: Laurent Pinchart , Kees Cook , ionut_n2001@yahoo.com, Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy On Tue, 7 Feb 2023 at 23:07, Andy Shevchenko wrote: > > On Mon, Jan 09, 2023 at 11:46:00AM +0100, Ricardo Ribalda wrote: > > Hi Laurent > > > > I was thinking about something on the line of the attached patch, > > > > uvc_frame_header->data could also be replaced with a union. > > > > Warning, not tested ;) > > ... > > > +struct uvc_frame_header { > > + u8 length; > > + u8 flags; > > + u8 data[]; > > +} __packed; > > __packed! (See below) > > ... > > > + pts = (u32 *) header->data; > > Ai-ai-ai. > Here is just a yellow flag... > > ... > > > uvc_dbg(stream->dev, FRAME, > > "%s(): t-sys %lluns, SOF %u, len %u, flags 0x%x, PTS %u, STC %u frame SOF %u\n", > > __func__, ktime_to_ns(time), meta->sof, meta->length, > > meta->flags, > > + has_pts ? *pts : 0, > > ...and here is a red flag. What you need to have is Thanks! you are absolutely right :) Luckily Laurent merged the original patch not mine. Regards! > > void *pts; > u32 pts_val; > > pts_val = get_unaligned_be32(); // or le32 > > ...use pts_val... > > > + has_scr ? scr->scr : 0, > > + has_scr ? scr->frame_sof & 0x7ff : 0); > > > -- > With Best Regards, > Andy Shevchenko > > -- Ricardo Ribalda