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=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 328EDC433DF for ; Thu, 21 May 2020 03:26:19 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A71E20678 for ; Thu, 21 May 2020 03:26:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dQODjFoC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A71E20678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49SFQH23XQzDqnB for ; Thu, 21 May 2020 13:26:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=keescook@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=dQODjFoC; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49SFN65LHtzDqjQ for ; Thu, 21 May 2020 13:24:22 +1000 (AEST) Received: by mail-pg1-x543.google.com with SMTP id f4so2438323pgi.10 for ; Wed, 20 May 2020 20:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mWnBjl1zYC8g8arTkDhsLL1NSSPTMEKdZHG0NVZD9M8=; b=dQODjFoCNsXPgZtIsjjHamdC4Pu+mSJd0GckTyPx551zr98aODM5dJFMdkhXgPjklf VYPAt85gs5oCBBSY8ECg8cFn31wUYDRLAAh9PNMfsCMF8a+/KTkDsHPt9m0Jc9PtxSpU 8wZgJVSDe5kxAm3oAtQuqWMfKgxPEZGlO2rzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mWnBjl1zYC8g8arTkDhsLL1NSSPTMEKdZHG0NVZD9M8=; b=Q/JqleJz02Qz7Eg1fHDdNrUGw2NH9/roXGtukXSsSQxKbD6w84fzEv4s5RaR/if9rL kyMqPRK8nHoVjyQOkWcxjRFRpkRzoZhtYwWGLm5p2Oad6Scrturo6hCeq5CQVI6A0vLq uGPZRn0mOyKfwoT5eg6zJo3FsWRVLYyj6DlhGdXkB5ievpmJMeKkziIv4aAQVZ4CAmor vao5Dy84dF3zflMhKrjcicdmosYhseEWYNAufuIob7qgk2sm2HR+sxTvMvCnN/6IWCP9 7MVY+tDgj4NoDECZPm6FX5ChC51WYZBxSsG7LsgQ9DrqAec+kFz9lTlyNWBr8e1LtH8s 53Ag== X-Gm-Message-State: AOAM532UgPYdwdYnxjP/UmGvgnAiBrcDotSZOJtDx+uXCWLU4h1r3URd IA8hlaT0H03tcq5H4LjFPNBWPw== X-Google-Smtp-Source: ABdhPJwEXKl6A+KQbb5Fp68HNAuocmXXpqB85QaVdfl5nI9EFTDUjgRqSfp1CPCQYOESq1iPuYQ3Xw== X-Received: by 2002:a63:f242:: with SMTP id d2mr7158481pgk.212.1590031458617; Wed, 20 May 2020 20:24:18 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s206sm3325954pfc.31.2020.05.20.20.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 20:24:16 -0700 (PDT) Date: Wed, 20 May 2020 20:24:15 -0700 From: Kees Cook To: Li Yang Subject: Re: [PATCH] soc: fsl: qe: Replace one-element array and use struct_size() helper Message-ID: <202005202022.588918E61@keescook> References: <20200518221904.GA22274@embeddedor> <202005181529.C0CB448FBB@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gustavo A. R. Silva" , lkml , "Gustavo A. R. Silva" , linuxppc-dev , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Qiang Zhao Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, May 20, 2020 at 06:52:21PM -0500, Li Yang wrote: > On Mon, May 18, 2020 at 5:57 PM Kees Cook wrote: > > Hm, looking at this code, I see a few other things that need to be > > fixed: > > > > 1) drivers/tty/serial/ucc_uart.c does not do a be32_to_cpu() conversion > > on the length test (understandably, a little-endian system has never run > > this code since it's ppc specific), but it's still wrong: > > > > if (firmware->header.length != fw->size) { > > > > compare to the firmware loader: > > > > length = be32_to_cpu(hdr->length); > > > > 2) drivers/soc/fsl/qe/qe.c does not perform bounds checking on the > > per-microcode offsets, so the uploader might send data outside the > > firmware buffer. Perhaps: > > We do validate the CRC for each microcode, it is unlikely the CRC > check can pass if the offset or length is not correct. But you are > probably right that it will be safer to check the boundary and fail Right, but a malicious firmware file could still match CRC but trick the kernel code. > quicker before we actually start the CRC check. Will you come up with > a formal patch or you want us to deal with it? It sounds like Gustavo will be sending one, though I don't think either of us have the hardware to test it with, so if you could do that part, that would be great! :) -- Kees Cook