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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D6FAC001E0 for ; Sun, 30 Jul 2023 22:54:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BD6A6B0095; Sun, 30 Jul 2023 18:54:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76E316B0096; Sun, 30 Jul 2023 18:54:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60E006B0098; Sun, 30 Jul 2023 18:54:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4CF046B0095 for ; Sun, 30 Jul 2023 18:54:48 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 17EF4C09AC for ; Sun, 30 Jul 2023 22:54:48 +0000 (UTC) X-FDA: 81069784656.08.47449B1 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by imf17.hostedemail.com (Postfix) with ESMTP id B51EE4000B for ; Sun, 30 Jul 2023 22:54:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=pfLzsG0g; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.218.51 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690757684; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5id/UpecirppNKHw6frQ7LNJC/s0/wNTJgIw2H535Gg=; b=wN9aZdwzTzorQIkXBHvKRcJDk6caNq0Ncnb8z5S8/lGNxeUB/xR8JlISLQV2HEK0CaDfKb 1cBVs6FymKVs8DdVdCsLlSefoSbFxYTIE8K1E+4inAYHH6iV6r2zs5BX3bzz7c+9HqHxKx U/NOnuskICqLuU8plPcw/Z3MwSz6+2k= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=pfLzsG0g; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of boqun.feng@gmail.com designates 209.85.218.51 as permitted sender) smtp.mailfrom=boqun.feng@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690757684; a=rsa-sha256; cv=none; b=ifyJBC7s1l1p15dA7PYB6H0ZoLny7bIth6jRchZDxxHvw0GMh6tPu9h+0zlMptqLidjpxe NIymaCS65ZggG6UomKA9/MY4762j6VCGF5WzB9BmvHew+P/WUu2oizSFdQ9HpvUQ+/c1Rn G3M7EsHdeiTwo99zolPcbTCXBsi7XPI= Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-98377c5d53eso554413866b.0 for ; Sun, 30 Jul 2023 15:54:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690757683; x=1691362483; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:from:to:cc:subject:date:message-id:reply-to; bh=5id/UpecirppNKHw6frQ7LNJC/s0/wNTJgIw2H535Gg=; b=pfLzsG0gwcGduiDbOQnsiHv9rXg4h/DTOju4W/hI9JKQcFbVYt7/Oj/dmPlZDZl4mn Zl2G6q6rG/Io1ShjiNrIpZM6Ggyoqd2iGmNLh4+4B+YUdmzpqxLPkeIF+RT6OgRUbCCh pfuPZvvJ48JW+eXz+k5cEFOvlW1OE9nSM/WgBpvM+wseJoqfm7hzmQvE9WqFNudHFizL 2SHlWAIOIQ/Hd9mcpLCxl+Tw3ZHdHmsoDvSaFVhia8ne0CoZVgKzTX/OtbjN5TM9uRl2 SndIiRJ9wUfKaXVDYHpsPmyxnZjdZAid+HOqooQ1zxYgBdSPqlduAKdvNpvVeb/cUga5 mnQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690757683; x=1691362483; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5id/UpecirppNKHw6frQ7LNJC/s0/wNTJgIw2H535Gg=; b=J24EgGh0lfhRuHXT3EH7bRoxmFVb/lPek/yKJgFetHn4vcNDcTluv9gPvbKfHHsVjz d1d1xGir4s7VJ0W2A130yPVjx1CSvZKhDKQqc08oNJNvatAB1Y0eV4gUbE0qoo5OLxZp bgxpqU+dgGGGt5eVVWsKtkMdrSOBE0vhh6CdtnsJwD5oHy3LENg5RXrRFuZs98EdhXXb 8qOgzrW8CVkWGVgiDGzQCFYKYXFY+7uDXBfscyTCw1Xi1TB/1qc/v/y66Q+6rA2J0m4v 9yhVUfWXjvBhStIMBCN7sMkoRw0ga8SHDe7W3yKoanYGrNCb979rxRNzDXRo9qagEyge Vq2A== X-Gm-Message-State: ABy/qLYptTnFSZ4eBMXQo+OyeucEstOwjAdIVnqNXIiUCPzHVBePWzMk ZO7P1IGCGVwj9i3WgyHD5tw= X-Google-Smtp-Source: APBJJlGIQFooEtH+R4RbuRtOKCXAMUOZDuMNzPQFGdNFlju1t+lp6Tmxh/pX9CZ3dxaXuokbu6R9hQ== X-Received: by 2002:a17:906:a097:b0:99b:d89c:9dd7 with SMTP id q23-20020a170906a09700b0099bd89c9dd7mr3938179ejy.77.1690757683086; Sun, 30 Jul 2023 15:54:43 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id bq6-20020a170906d0c600b00992ca779f42sm5215809ejb.97.2023.07.30.15.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 15:54:42 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 6224F27C0054; Sun, 30 Jul 2023 18:54:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 30 Jul 2023 18:54:39 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrjedvgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtugfgjgesthekredttddtjeenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeevgffhueevkedutefgveduuedujeefledthffgheegkeekiefgudekhffg geelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 30 Jul 2023 18:54:37 -0400 (EDT) Date: Sun, 30 Jul 2023 15:53:57 -0700 From: Boqun Feng To: =?iso-8859-1?Q?Bj=F6rn?= Roy Baron Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Gary Guo , Benno Lossin , Martin Rodriguez Reboredo , Alice Ryhl , Dariusz Sosnowski , Geoffrey Thomas , Fox Chen , John Baublitz , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Kees Cook , stable@vger.kernel.org, Andreas Hindborg Subject: Re: [PATCH 1/3] rust: allocator: Prevent mis-aligned allocation Message-ID: References: <20230730012905.643822-1-boqun.feng@gmail.com> <20230730012905.643822-2-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: B51EE4000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: i8hp8kr97944nda1e7s7sxae43y4u6nc X-HE-Tag: 1690757684-645702 X-HE-Meta: U2FsdGVkX1+CRnrEKUFUfvbk/usjhKslMkm/fVGGfSf0v2Dk/gVnLtgD/WRkV+VWzODXsfEgfPPL8vr4ayj/14t88O1GkgbwVY6+RXEQns2OKzH/YoiSKwpuJhmBmn4R4z8JFPHOgDV4ciN0qu0r2gfxF25jO9iYNWkhc5FK15ZAKIskniZX2x0UlFDL3iwGUQLnYFOtElG2rXowIP141Py0bVqXyfgJFeSKWo599eS06ei5B2bq9/OKBv5wA8Y+eD5BrgH0iz+Eb/sm51xKLR4cLhUfLCXRPMBDzxn6L+NMNy6NpEXl74Stcbv1HQ3PmIjHFDcFa3xdb9EyPfM1/fQIXgLl1wOFGMR1qOSH8XPIJAFm6qASNSRmZsdtF26uhzTL9bcLDm2G3h6S0F5Te4r2vS2y/ahAWNydVMPJL0qwhHy7Or4Wvc06/351mhIaVcV2e8EJevWxprQNvb0zqhdoEGghzKmbc9QXtFnjaFXSIVgar4YMJPvVVh+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ack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Jul 30, 2023 at 10:41:54PM +0000, Björn Roy Baron wrote: > On Jul 30, 2023, 10:43 PM, Miguel Ojeda < miguel.ojeda.sandonis@gmail.com> wrote: > > On Sun, Jul 30, 2023 at 3:29 AM Boqun > Feng wrote: > > > > > > +// Note: Although these are *safe* functions, but they are only generated at > > > +// `GlobalAlloc` callsites, hence we assume the parameters obey the same > > > +// `GlobalAlloc` function safety requirements: size and align should form a > > > +// valid layout, and size is greater than 0. > > > > Thanks for adding all the `// SAFETY` comments here Boqun! > > > > Björn, do they look good to you? (since you fixed the issue in the compiler) > > Based on a quick look, yes. The __rust_* methods that are normally generated by the compiled directly jump to the respective global allocator method, so they have the same safety requirements. > Good to know, thanks! > > > > On this comment in particular, "generated at `GlobalAlloc` callsites" > sounds a bit confusing to me. Would "... called by the compiler with > parameters that obey ..." make sense? Or does the sentence refer to Agreed. It's better. So reword as below: // Note: Although these are *safe* functions, but they are called by the // compiler with the parameters that obey the same `GlobalAlloc` // function safety requirements: size and align should form a valid // layout, and size is greater than 0. Regards, Boqun > the normal case (i.e. when the functions are generated)? Anyway, it is > not a big deal. > > > > Cheers, > > Miguel > > Cheers, > Björn > > (resent as I accidentally sent html instead of plain text)