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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E555EB64DD for ; Sun, 30 Jul 2023 22:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbjG3Wyq (ORCPT ); Sun, 30 Jul 2023 18:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjG3Wyp (ORCPT ); Sun, 30 Jul 2023 18:54:45 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF6B189; Sun, 30 Jul 2023 15:54:44 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5221f3affe4so5236417a12.0; 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=liveDx/40dLY1JVtpQvW0flCQkVzZWEu3Z0giz6rm2Amj+/+D4vWQ18qvRuocKz6UK ANMfA3e+oCh9wCVfKNcpM2tsX8dqxC3eUkxw+Z2Ljc1cHeldrhefmvRRdyaWkcu5SqqN s4ctW5YSoBlb3ZMhapvZxiDTaPJEavZyksikx5+GSrIKYRqEyjx7tpqSB62VgCDNjwI1 SUySxCqfJE5xgnNCsEPqZ1yMqLFO9OdUQ28LtmrBGM9m2dfwpnAgHamQDTC428/Nruto xU7gy5lZRWSRG6avVFVj6IjXU6LGfCip5bAglwTa1fFEo1JS6PzSTxDSbFbwu6Heazy2 fxCg== X-Gm-Message-State: ABy/qLbB9AydBl8LhVUwAAvlJNWSAjMZQrMcUde8QlBm60vm21Bv+eEC wlECMhUqy3z0XrYnTrDl0Es= 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: Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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)