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=DKIMWL_WL_HIGH,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 82168C35E0C for ; Tue, 25 Feb 2020 18:36:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4AF0620637 for ; Tue, 25 Feb 2020 18:36:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DS824e58" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4AF0620637 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 E0F636B0006; Tue, 25 Feb 2020 13:35:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBFA26B0007; Tue, 25 Feb 2020 13:35:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE6896B0008; Tue, 25 Feb 2020 13:35:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id B38006B0006 for ; Tue, 25 Feb 2020 13:35:59 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 765843A82 for ; Tue, 25 Feb 2020 18:35:59 +0000 (UTC) X-FDA: 76529503638.19.chess87_6e73acc01635e X-HE-Tag: chess87_6e73acc01635e X-Filterd-Recvd-Size: 3765 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Feb 2020 18:35:58 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id n96so68536pjc.3 for ; Tue, 25 Feb 2020 10:35: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=/Oq7ZlHByEKisw958sDxdjAX7fiFkXlFc5ymByAOxAI=; b=DS824e58go8okeMKOqEHEbHc21x7FkHA0PkE7JjUV/ffMD1jaGlRVRKQiy5G78ZSYi w1g8VqpgDd0aOt7TLWrv9NKqWgKZYpnTPxeD6k9lHXhVVPmM22eWvb8eWDmVot6ePvL1 8WChB0KvbivUsKRrpzgsb+e+Tym3KoTwLEdn4= 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=/Oq7ZlHByEKisw958sDxdjAX7fiFkXlFc5ymByAOxAI=; b=UyWhCs2YMptK/HX84Aq8v7y2M38CUtB4z8/XE2ZjbML2X0F1ZTQsheJcKFg+tbJj3z MHcj7nfHLtk9qNgdg/5fHqB91aaRcm5vsUBRhpxNirjnmEyXnDwxEiu3eIEn58mBSkHZ DXkljda7Z1aUGAsSJAB/Yv68CHdOBB3Q4RhG+ptM/dRmCKLIBzctAWJlLTWcXoRKdQgZ 0ThsJCsRJZHGJv07TPnCW03tfbg7qBg/z2f7z4Yr4NgmXagjWjg8CKpFa6QyVTxy+GOh X9ox8+GTiyO7MF4ZCXjoZZgtJRrdm5puKwwpLCL/z0KHvZ5BSh75Qerluv9ws5UvRQqb ZKEw== X-Gm-Message-State: APjAAAXrjMTlvg0N5JqWuIDrLxqwbd9UIurODY6qP4ELf7jvpWvr2uMc NC4xfZQCUs0NKD+35H3hoOL3/Q== X-Google-Smtp-Source: APXvYqyPmhYJr4gUqySGuqxkFqZHzAJ4hcxUjGcAw4ErEw4uaojqet99DnUp7LnumFp67PKFXpJf/w== X-Received: by 2002:a17:90a:7187:: with SMTP id i7mr379790pjk.6.1582655757813; Tue, 25 Feb 2020 10:35:57 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d3sm4311417pjx.10.2020.02.25.10.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 10:35:57 -0800 (PST) Date: Tue, 25 Feb 2020 10:35:56 -0800 From: Kees Cook To: Daniel Micay Cc: Daniel Axtens , Kernel Hardening , Linux-MM , kernel list , Andrew Morton Subject: Re: [PATCH 5/5] [RFC] mm: annotate memory allocation functions with their sizes Message-ID: <202002251035.AD29F84@keescook> References: <20200120074344.504-1-dja@axtens.net> <20200120074344.504-6-dja@axtens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. -- Kees Cook