Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp324909ybf; Wed, 26 Feb 2020 13:57:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxSJ1T0p+w0dVOoBeitoRTxCoSYYEfQQjz3jn5MogApN3KQpk0F3BrNVXF+ArfxO2Fj1AOX X-Received: by 2002:a9d:6289:: with SMTP id x9mr784566otk.8.1582754265213; Wed, 26 Feb 2020 13:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582754265; cv=none; d=google.com; s=arc-20160816; b=gzsTBNr1Jr/0wmzQo+BkcOKWdzMvB8sBvBU3d8T/eH3N6CaT3RTz04wOWhYXzJZUXU LjE1+fnDzDJU1ZGi40y4W0aq8nmXBkodPwO4EOGhnVtKU0gZjbn9oYK3EpC3mgpzFJuj cv8fx6MKhIWZKZSNKJLNMtA7gROZDl/rm8qn3s/cwplWEg0nfF8wDHfzutC9gJHiRXLe buIy00p3oZRXX9TJvV0cYkDrDRJmscfXlXTcZyoT4/e6BXOwLEQt3h4J6/3g2w5MW/7/ aAqjnl/bqWBrUSqES7eAw50TbC4ShUMKZUy5XtETQYxD/YThJLfmyCYoOy86Abz8Gs5S qxDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=agTSg4xTvTJ902v/wRSeSnCJDmYFaVhC2jp/Gq4x83M=; b=Qsp1T1PsQaAeWjo/YfU/QD76MA1nBL7FvZ2DnpnECOV1Dxn7SOLiayrzV3gE0+3m7E OVowlVjkWxEIf0RyMLgub1pT2mgdbpyICXTQ1Q77ilTNhGmpu46fjFYbT3XkoYcnO7ej q6O+fwyYI2LfxNohRtYWU4U46aKiYKFjGclszJbQGq2BbRQAiIyrCWgvoWeV1KpaF91x /Mo5T0tRGuT0s+rSsjWJUvR4EZ4HMBdvYDpN03ECeRfcyGCdduy6zXNF8M70Mc//4qgH cYJ9dQrBli6QIP4y/yt5TuSSI9e0KWzfnd9RgwyQuV4gx+pARASHcGCbYh6vZ+5cYPgN LhiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CVWa98Uw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si427163oti.44.2020.02.26.13.57.33; Wed, 26 Feb 2020 13:57:45 -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=@chromium.org header.s=google header.b=CVWa98Uw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727740AbgBZV5A (ORCPT + 99 others); Wed, 26 Feb 2020 16:57:00 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46360 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727584AbgBZV5A (ORCPT ); Wed, 26 Feb 2020 16:57:00 -0500 Received: by mail-pf1-f196.google.com with SMTP id o24so167609pfp.13 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=DPV7d4Fmiusk6kf9icHfHFjlR0KcX15RY2qJFZ46GIWXN4rf/d8/+ZgytCsLLuG6h2 4GxGOHNpiJ/6gTlmTM5/RplaPivMng7xueoi9bGMZPRrWCa2FjdpW+C/Mg3UZrSjX2ZI NS2jmw0GY/cbU6pZmjz+kBC4Hj42ddiJfx8h8AMYYqaZ3vTLqgvtTkp0osrdOrwojV32 Ygy+eySbqRPO3m23Wn+NntPKIToCWHY8xtq3ORxHYv8dLh6RSiGbZmlmPFSXJNWxf0Hf LgKktm19kXk9fCtn2XSeb3EXnb8SWMe+j86EvMb/4GH/8iXWI7Oc5379cNJh/z5WFO6p DwVA== X-Gm-Message-State: APjAAAXV6zAUidSUNVKKRCl6AjKtYcvJ4CK7Dp7nLUf/1gsrFic0rw6k 0eednmBHbBWjJ3t+wdaAPh5pWg== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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