Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4526066ybv; Tue, 25 Feb 2020 22:09:39 -0800 (PST) X-Google-Smtp-Source: APXvYqwM3pd4yzXe+y7g/TTJ/px/JAd08pAqaaetAjArtxGlucSmFLIH14s2ZEy5tjKoIrNbCnZF X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr1712446otc.123.1582697379507; Tue, 25 Feb 2020 22:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582697379; cv=none; d=google.com; s=arc-20160816; b=Gmtw8lr6akHn574r6Je0VpyIiAHYp7qWs2bx2dAfS3PiqyrI4Pt/XaB+EYNZ4sUfZ0 ibK0hU5FJLQsE4xHLabUujmfXD/kpnalQ5DMytPdGHOc3S95BsurSzweii7iepJhE+Oq gdaWCiC1N6TjgreK8dTSgcC7eHVAxusGzfWHi02RW2XPTjNpoWT4gKBN7NFKrj+4INXN tKRtyGBoftQXTP6n80MmgzZvh2DzRUfq84ncbuR0hDo+oKdGaUVcbAu/dBPyhdq3PRvw em7eXwYyjSFpusTxr6mYpmykkGdY7zWyA4OcQ7T8j6SYe1a8BQvCejH2QZtEJ7KY+TKY +5sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=wHnRWSkI/KPKw6tQwkKo0dZto1+RLrsK9CfP2hBdd44=; b=EB1j6h3ky7TLuezbo2t6SBDU0AMXSw2av7N3lO96ifY9zwYj/GrQIsgfGcuZNn6QXJ 2MQLx6tlDppfLdrfxuEziiD7iCcTR/3t6m2DxQ+jx6qmRIInTeCI5QJL59Sp0/PZXyNK DDPzmvZOKLo53mvGRyvb0MEsX9ixfTWIuivcSs9FJz8xK1X7dA/NlkzM2isa5tGuA3VR +epIYK7UNTnDYaj1dp3S0L9xGQLyqrDK15JcvAkczbsroNvd6rH+iZdCOTGkjLv1Mwk9 nL4kzcfTmT2ll9WloV8m+0Y9d5wRiwC7Bp55tXHwW3s7yAzY4lhTX8JH58hCxDfwcYQc Uvkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=iAunlpGu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r21si703200ota.204.2020.02.25.22.09.27; Tue, 25 Feb 2020 22:09:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@axtens.net header.s=google header.b=iAunlpGu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbgBZGHZ (ORCPT + 99 others); Wed, 26 Feb 2020 01:07:25 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43833 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbgBZGHZ (ORCPT ); Wed, 26 Feb 2020 01:07:25 -0500 Received: by mail-pg1-f195.google.com with SMTP id u12so758784pgb.10 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=hibdObsjuBmBQtgBB9c9kXeHxQYDVnCmobdXEgQ1vajJ5D1TNaTcT/QESzvhao8i1O q3rGLsOOuYYBZfwkesczwFq68M4BeoPrKfh7BGw6HCcHZaq+v5BuH6rdLz0dCWL0SNxD K6WMjAU1INTqrRxwT87eXqklkhjBeWOETtT/2tpF9Y1TjQ9OFO3XQQReW5wGgR7DsfE+ UW/wl299I82nxcKQTS4gCJ9t2LhVCCgOqIAUMixDG/9x7eMneJrmszk/W5QntapHgPTI dsFSbFZBf8IUCbIb6oR3GbdkFqn7jC3DAR0S0t/qh/JWqqHd1aW0G2Uwu/6DIX8+6S3b ukqA== X-Gm-Message-State: APjAAAUEpill9HyjsRbKXNURwnFwR0kpUBamtp9cl3AlhYoPjAbaslrm 7mzeaJICB/xHYvYqp6ffHfc54w== 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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