Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp611484pxb; Thu, 20 Jan 2022 22:02:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyswAveUfA4YKGowwb5NUN5pAhXV1axSQ81rNS/QBHLowGjDBaoKPnukVu2LhSS9AWPPGsH X-Received: by 2002:a63:7543:: with SMTP id f3mr1919677pgn.360.1642744952201; Thu, 20 Jan 2022 22:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642744952; cv=none; d=google.com; s=arc-20160816; b=vjD++fqeYDwfqT5tSZKXkUU6b3PHtlJtUtoMQ3AtON9dtLHmBd5gG7yM0Mt4QYzym7 DxYDMnQHjsJi22fNV7hl1Cd7Sohwb10PGHM5r4ZNYVov+XkUr7HZhm3EIDqrgl7CXMqf /2zAT+rJVVm/Did5X/yfFgJw8H04tWzbqwSTKzaGTk0mN2Npn8swtzbdJZsyCWNlJkGG rPOYtpI0M5XVqlfe4MzGj8UbEl2Kc7sqQwpurYAOxE7cPqP2+mdU3+V+hG53c/LrKAbv fSExkaHeFBqSQn0g6kgbM0DxTg4sofKHvLr5gLU89O+caVo+PYrCjPN4gFdTJtshJ5jb lWyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3bBy3CYfuqFnCx19HkSiY69nlsVaIO8zSqvCrUbGJzY=; b=fzUXbjFEzwD45SB+CSX+7WB49GktU2GxjlRGjoSlF1SbQP0Eo4+azaaQSBGe3M64Dr JrzehzdHT4b2MGTJWovm8FziRtsbmRfYIgV77ub5F6lXW9uc+z+EMaJIDivhSF5Ld/w1 +r2tnw73bgtY9s97nHWK03pxW9K+eggTCSQDtytZ/LyTyUqAnlfUohPBO+oMGliRVcKo w2KJO3kZ4tCPr9YiJpScbpLfHyf9KByg5o8HQaCrbIywgMELpY0MqDGXimFCyZtylTdt wGOymeNZ1tQ6G11JbA8F/a9ePXWCTAqW33ngm0VohXaKcqCKh/VM0uN1x1X3M009jmbR czzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RjAQS+Ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si5913560pfl.31.2022.01.20.22.02.20; Thu, 20 Jan 2022 22:02:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RjAQS+Ky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348462AbiARTdO (ORCPT + 99 others); Tue, 18 Jan 2022 14:33:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245420AbiARTdN (ORCPT ); Tue, 18 Jan 2022 14:33:13 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6EE0C06173E for ; Tue, 18 Jan 2022 11:33:12 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id d3so74891127lfv.13 for ; Tue, 18 Jan 2022 11:33:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3bBy3CYfuqFnCx19HkSiY69nlsVaIO8zSqvCrUbGJzY=; b=RjAQS+KyvgKkaoHdBY2N3PbAm/v/bKvuVFQNdVRXI7Kp3tlMojLprMh/stW/djIQh0 0KV4Wa79IPFP0qCWrUtcEO5xJ+8faGi1s7dGhhI2SmUg77bhyLBTRrsYjOtx8UTi0nXn F3YBlrbedzBkw2Nyg2T2cnBzoyfhRbdfGya8luZjl+xej0SA9VD4XZ3Q0WhE6mim0k52 gc/lTJBG1bNpyWhgxP3ucWqs3x26JW7F89dYKtzJ93mPVInp8VtPkd7v3oxun/wj4x68 FwldQs1jy6Kgh6dl5Uhhsmz1MmGUu6uiWwvuvx0pxTF5ak/S3e2LWK6ZTL0WhPFkiz76 F0IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3bBy3CYfuqFnCx19HkSiY69nlsVaIO8zSqvCrUbGJzY=; b=SKGfPHGrlhMPBJgry22cbKSJeoYMxvP1MrVxQcKIohNQw0/B02z7gTn5sV6uKZe9nw +V91adMiHAJVNWtu4M2W/r3J/HVpt02oiIysE83fuaK9r1itpCQBLwTtNpHOV5DNHjWq +WDYuGVF6CigvPuy7Dc85JfGPyt8V+Mm3BSzfvuJJb/zM73bm0s0Xi9U2Z1tbnAtA6/q Pw7OqRFE6zJIrQD7Ujuew54Erx2fYuiM5GQ+NvMxaBfWqX7s0lO7Z7ykWuhJ3jJDf7DN KeFbbnV3vojDFcqD4xLSJ95T9/9wKIWK57qHNH5deHLTgjnGbqN4eqCtT25oI+X9cVFa cG5A== X-Gm-Message-State: AOAM5314F9X/7SCtANUSW8+LYxLnjXQ/C4S12/z109xKfusSz7C00gcO +13m5cKu1FoDevrWfh0DluBmmm+Hv/1X0ONsZRnsQA== X-Received: by 2002:a2e:964e:: with SMTP id z14mr14936557ljh.375.1642534390901; Tue, 18 Jan 2022 11:33:10 -0800 (PST) MIME-Version: 1.0 References: <20220118183650.3386989-1-keescook@chromium.org> In-Reply-To: <20220118183650.3386989-1-keescook@chromium.org> From: Jann Horn Date: Tue, 18 Jan 2022 20:32:43 +0100 Message-ID: Subject: Re: [PATCH v2] tpm: vtpm_proxy: Double-check to avoid buffer overflow To: Kees Cook Cc: Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , linux-integrity@vger.kernel.org, Stefan Berger , 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 On Tue, Jan 18, 2022 at 7:37 PM Kees Cook wrote: > When building with -Warray-bounds, this warning was emitted: > > In function 'memset', > inlined from 'vtpm_proxy_fops_read' at drivers/char/tpm/tpm_vtpm_proxy.c:102:2: > ./include/linux/fortify-string.h:43:33: warning: '__builtin_memset' pointer overflow between offset 164 and size [2147483648, 4294967295] > [-Warray-bounds] > 43 | #define __underlying_memset __builtin_memset > | ^ Can you explain what that compiler warning actually means, and which compiler it is from? Is this from a 32-bit or a 64-bit architecture? It sounds like the compiler (GCC?) is hallucinating a codepath on which "len" is guaranteed to be >=2147483648, right? Why is it doing that? Is this some kinda side effect from the fortify code?