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=-5.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 C2D7CC4BA21 for ; Wed, 26 Feb 2020 21:57:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8287C24653 for ; Wed, 26 Feb 2020 21:57:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CVWa98Uw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8287C24653 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19E816B0003; Wed, 26 Feb 2020 16:57:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 150716B0005; Wed, 26 Feb 2020 16:57:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 017896B0006; Wed, 26 Feb 2020 16:56:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id DE7686B0003 for ; Wed, 26 Feb 2020 16:56:59 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 94778180AD807 for ; Wed, 26 Feb 2020 21:56:59 +0000 (UTC) X-FDA: 76533638958.10.way90_1fe26a3aa3b60 X-HE-Tag: way90_1fe26a3aa3b60 X-Filterd-Recvd-Size: 4326 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Wed, 26 Feb 2020 21:56:58 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id l7so41726pff.6 for ; Wed, 26 Feb 2020 13:56:58 -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=agTSg4xTvTJ902v/wRSeSnCJDmYFaVhC2jp/Gq4x83M=; b=CVWa98Uw4W2DSuAZ6nw8SSnOHBSkNazKVCAoUkannuWdT6ct919lXMS1jGfBN/0TGA vi1r29dNanFqfnfQjHgMsWQeCfa8dPlKyRhtjdPBabDi/YdPfx1Nd5hK0amb+n6+XDYz 3A6pmEuOxzK9cvXLOsHwTn/z5Ld4PVK8tO180= 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=agTSg4xTvTJ902v/wRSeSnCJDmYFaVhC2jp/Gq4x83M=; b=pEHKVo679ipV7eidanUls5EqXerzgzQsvsoeLQXxThDoDhUWJb7iC/cBZjTTv0TC2h sH5tRLBtwC0C5Bt4weRjelR8I4EpxUiKY2WCpFPQsZg3gId+8X3fBEbcoGe9qvXzxyS+ nt0eZs1yBxbL5sf8XqjMuhp7qpT1t+lAx9xokinnQWZcLvFtkvc//IXrPueTr/sJYJr5 efiQDoDRnpf/5UdvxxwRDZYbnzGBDvNy4zdpYiHq4DuVJE67lcdKZyz1Xck6/CKq5zWR Z0YgUbV5yldvSoTh76RLKZQEjTK7VtArQGjwtukszwCJ/VxT8Q/svr98/6Os8b8s1aIE IPjQ== X-Gm-Message-State: APjAAAXAHlLG/OPqLjajbrFDnLzMVygYd9WuXgtJByF6B0YfL4CYk55I 00sKn8k4T3oUvKVS/mfz7R6LyQ== X-Google-Smtp-Source: APXvYqyJGeL4QW5uWg6MxaWO+Pm23Yck/xgVU4oSTq3yCWFAC8LuFM9MWFMSX+jv/vuaDnFk8SNXQA== X-Received: by 2002:aa7:95b0:: with SMTP id a16mr688779pfk.253.1582754217916; Wed, 26 Feb 2020 13:56:57 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j38sm616348pgi.51.2020.02.26.13.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 13:56:57 -0800 (PST) Date: Wed, 26 Feb 2020 13:56:56 -0800 From: Kees Cook To: Daniel Axtens Cc: Daniel Micay , Kernel Hardening , Linux-MM , kernel list , Andrew Morton Subject: Re: [PATCH 5/5] [RFC] mm: annotate memory allocation functions with their sizes Message-ID: <202002261356.B632368@keescook> References: <20200120074344.504-1-dja@axtens.net> <20200120074344.504-6-dja@axtens.net> <202002251035.AD29F84@keescook> <87wo89rieh.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87wo89rieh.fsf@dja-thinkpad.axtens.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 26, 2020 at 05:07:18PM +1100, Daniel Axtens wrote: > Kees Cook writes: > > > On Fri, Feb 07, 2020 at 03:38:22PM -0500, Daniel Micay wrote: > >> There are some uses of ksize in the kernel making use of the real > >> usable size of memory allocations rather than only the requested > >> amount. It's incorrect when mixed with alloc_size markers, since if a > >> number like 14 is passed that's used as the upper bound, rather than a > >> rounded size like 16 returned by ksize. It's unlikely to trigger any > >> issues with only CONFIG_FORTIFY_SOURCE, but it becomes more likely > >> with -fsanitize=object-size or other library-based usage of > >> __builtin_object_size. > > > > I think the solution here is to use a macro that does the per-bucket > > rounding and applies them to the attributes. Keep the bucket size lists > > in sync will likely need some BUILD_BUG_ON()s or similar. > > I can have a go at this but with various other work projects it has > unfortunately slipped way down the to-do list. So I've very happy for > anyone else to take this and run with it. Sounds good. I've added the above note from Micay to the KSPP bug tracker: https://github.com/KSPP/linux/issues/5 Thanks for bringing this topic back up! -- Kees Cook