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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E22BFC433FE for ; Mon, 28 Feb 2022 23:16:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DE4F8D0002; Mon, 28 Feb 2022 18:16:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 48C808D0001; Mon, 28 Feb 2022 18:16:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 353F48D0002; Mon, 28 Feb 2022 18:16:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 216A28D0001 for ; Mon, 28 Feb 2022 18:16:48 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C6E64181951E7 for ; Mon, 28 Feb 2022 23:16:47 +0000 (UTC) X-FDA: 79193750454.22.344CA1D Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 42E6CC000A for ; Mon, 28 Feb 2022 23:16:47 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id n15so9761716plf.4 for ; Mon, 28 Feb 2022 15:16:47 -0800 (PST) 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=qcyuF/rJ3v9adXS1wD5x79Nrhi3MVFgnMBiDVeVK628=; b=H84ukViLP1I1WQwJ555fTIX5iY07fF8mJhYhLLqFrxRU/v/5c13BT2oHieKtQ28QtB vTu/WJ1QzVGt7t0JrWP9EZxzFSuISG7rgQ18dkd1w1PdOvc/6kHgHln31L/hqrFgSqbN iT+TUK5ORx7x3+XzVmrBCQtrgm3FCzB0zo30Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qcyuF/rJ3v9adXS1wD5x79Nrhi3MVFgnMBiDVeVK628=; b=P1ehzlRSVLpC6nVPyy8BYQf3Z3tBpZBnov/eOiRV40/egFRnvawvtkBjJKxfsr4N+a hUy/UPQAoRUgms+LyckG8EVfKlp18FbtnYeCH60yTyaVZ8i2kmPvn0HcOsfQbIB4Y8bG piTMWugZN2WAne2PRZ7kQNT1GK5+vjHbWwDxppI20h/ay439C1tWWQV62FRKOZ7RQ9l5 vT/Zv6zoQ/voxqfuna8OwrC7hLwxSLIiVNcmPca80uqu5ZfCcSw8LDJe9GSJ2iFC/+b7 vwgLziy9ZL6zCdjuvkoovJeISzrlimVucfR07+P4Mbti8WezsOhFOJJJP4oq5c1lxQLW A9jw== X-Gm-Message-State: AOAM530uZXZ1CGTJShZNYQjMeWZgOQfg6HhOIU/TfR/5Znzm7tDgjlJz m0YlDh1b97D3km0AkUN8PJT5gQ== X-Google-Smtp-Source: ABdhPJyUO4WdPD4D+EwN7uSB3399f8EhL9c8HcIjeCpMcQrsQdmLfXFfXqDsDs2KAc/EYgd95j5zzQ== X-Received: by 2002:a17:90a:6542:b0:1bd:149f:1c29 with SMTP id f2-20020a17090a654200b001bd149f1c29mr13946279pjs.240.1646090206307; Mon, 28 Feb 2022 15:16:46 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id np11-20020a17090b4c4b00b001bd4aa67bafsm774491pjb.3.2022.02.28.15.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 15:16:45 -0800 (PST) Date: Mon, 28 Feb 2022 15:16:45 -0800 From: Kees Cook To: Andrew Morton Cc: llvm@lists.linux.dev, Marco Elver , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , linux-mm@kvack.org, stable@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Christoph Lameter , Nathan Chancellor , Nick Desaulniers , Daniel Micay , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mm: Handle ksize() vs __alloc_size by forgetting size Message-ID: <202202251823.45E09CF@keescook> References: <20220225221625.3531852-1-keescook@chromium.org> <20220225154518.0d1159fdc6f37ee38e39e90c@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220225154518.0d1159fdc6f37ee38e39e90c@linux-foundation.org> X-Rspamd-Queue-Id: 42E6CC000A X-Stat-Signature: ut5uhyw5x1s3joq3umcdx3cqhbgsrq71 X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=H84ukViL; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf28.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.172 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Rspamd-Server: rspam03 X-HE-Tag: 1646090207-572741 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Feb 25, 2022 at 03:45:18PM -0800, Andrew Morton wrote: > On Fri, 25 Feb 2022 14:16:25 -0800 Kees Cook wrote: > > > If ksize() is used on an allocation, the compiler cannot make any > > assumptions about its size any more (as hinted by __alloc_size). Force > > it to forget. > > > > One caller was using a container_of() construction that needed to be > > worked around. > > Please, when fixing something do fully explain what that thing is. I, > for one, simply cannot understand why this change is being proposed. > > Especially when proposing a -stable backport! Tell readers what was > the end-user impact of the bug. > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1599 > > Even that didn't tell me. Is it just a clang warning? Does the kernel > post your private keys on reddit then scribble all over your disk > drive? I dunno. Yup, sorry. I tend to get so deep changes like this that I forget to give an appropriately detailed summary. As others have mentioned, this is trying to fix a miscompilation issue, triggered by what can be considered either a mis-application of __alloc_size, or a failure to correctly disable compiler optimizations in the face of ksize(). -- Kees Cook