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.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 D0FFDC4BA0B for ; Wed, 26 Feb 2020 06:07:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8212420838 for ; Wed, 26 Feb 2020 06:07:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=axtens.net header.i=@axtens.net header.b="iAunlpGu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8212420838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0E4A46B0003; Wed, 26 Feb 2020 01:07:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 095D96B0005; Wed, 26 Feb 2020 01:07:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EED1E6B0006; Wed, 26 Feb 2020 01:07:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id D86476B0003 for ; Wed, 26 Feb 2020 01:07:24 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 88948180AD811 for ; Wed, 26 Feb 2020 06:07:24 +0000 (UTC) X-FDA: 76531246008.08.bead35_2384d3e674405 X-HE-Tag: bead35_2384d3e674405 X-Filterd-Recvd-Size: 4007 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 26 Feb 2020 06:07:23 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id d6so772839pgn.5 for ; Tue, 25 Feb 2020 22:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=wHnRWSkI/KPKw6tQwkKo0dZto1+RLrsK9CfP2hBdd44=; b=iAunlpGumDfMTCDwa2qDpliEwWgJJRKO4KOJHWiktC2X4lt65wcUnHSGHs3l6UP66Q d4Ocycbdkd/amh/DmSUexBB8vr8aDXUlPM5nn55YLs9ozjynb0f/G6A0DRUqp4fDNKUq 72517XtJWuA4U0Cd0PsZA7s2vZe51bPW/k6s8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=wHnRWSkI/KPKw6tQwkKo0dZto1+RLrsK9CfP2hBdd44=; b=e28mXEhnoKdHMMdf3lvzYECyn+Co+LlPyT0zI2N4R3HfM0gXeQBnAcPPzqmRfVs87r KIW/7Kku/FbYTwWiDybwMQ2wN+PiyosIzFQSnjg/GgN0SJO80kj0nP0cXK7muBQ11Vxi d9tkyTCMbB+C4Bw/D8ClMAahdBNJmcV53lBdlYGEZQQAL6PlnpooKuCLb1JS4/dGH6R2 PCV0nUiitot6PS9pBqH+eIPY2haP5MD/VMK9Dd0wLhylcRsdgSjmniNsbAQeywwbjcNn HWUxg8Hg7yvoIETiqCC1mM4kwgI2F9lA2BcBwcxlT5NiSwO66y+zs1xYaixlWuBWi7ZJ 9rSg== X-Gm-Message-State: APjAAAVcTv31kfmCt3opXnrgQyplGkZXnKRdmUXbkwYzgej7O6gBlyqG Lv8HHgjD5BvkzXnH4mjZUAf0QA== X-Google-Smtp-Source: APXvYqy/xqWhxm0yEB7fap02Q6GRzScFy9XqEbLyCX3qDDPYVkQGakX1z25WIIR7ekand399s53kfA== X-Received: by 2002:a63:4707:: with SMTP id u7mr2226588pga.221.1582697242816; Tue, 25 Feb 2020 22:07:22 -0800 (PST) Received: from localhost (2001-44b8-111e-5c00-5952-947b-051c-ea5f.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:5952:947b:51c:ea5f]) by smtp.gmail.com with ESMTPSA id o14sm1008351pgm.67.2020.02.25.22.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 22:07:21 -0800 (PST) From: Daniel Axtens To: Kees Cook , Daniel Micay Cc: Kernel Hardening , Linux-MM , kernel list , Andrew Morton Subject: Re: [PATCH 5/5] [RFC] mm: annotate memory allocation functions with their sizes In-Reply-To: <202002251035.AD29F84@keescook> References: <20200120074344.504-1-dja@axtens.net> <20200120074344.504-6-dja@axtens.net> <202002251035.AD29F84@keescook> Date: Wed, 26 Feb 2020 17:07:18 +1100 Message-ID: <87wo89rieh.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain 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: 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. Regards, Daniel > > -- > Kees Cook