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.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 A8208C3F2D1 for ; Thu, 5 Mar 2020 05:49:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BB7C208C3 for ; Thu, 5 Mar 2020 05:49:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="foVA/Eqx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BB7C208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 09D856B0003; Thu, 5 Mar 2020 00:49:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 04F056B0005; Thu, 5 Mar 2020 00:49:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA5CD6B0007; Thu, 5 Mar 2020 00:49:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id D10456B0003 for ; Thu, 5 Mar 2020 00:49:02 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7BC1B442B for ; Thu, 5 Mar 2020 05:49:02 +0000 (UTC) X-FDA: 76560230124.21.dress32_319a89c1dce2a X-HE-Tag: dress32_319a89c1dce2a X-Filterd-Recvd-Size: 4451 Received: from mail27.static.mailgun.info (mail27.static.mailgun.info [104.130.122.27]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Mar 2020 05:49:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583387342; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=e9oOjtcJtvi7qKpVf2giGi1FIlSAIhOxeJLKzzQB65w=; b=foVA/EqxHFWIq44/BquujlSs0YByDI9L0IkL9cVgP0e5sZc2wei+dj9SveX1X2YLxnqmddWj ZACXQCeub5XjHDf8fhhLtl2yPQv27wHv+qHTd9u6dLbmUlo2tYOSbW90gf02y1TDSrDfEY4s 1a82Z0a0jvLwlNKStXep2FbxCwY= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e6092c8.7fa75212c7d8-smtp-out-n02; Thu, 05 Mar 2020 05:48:56 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A7642C4479D; Thu, 5 Mar 2020 05:48:56 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: vjitta) by smtp.codeaurora.org (Postfix) with ESMTPSA id E0371C43383; Thu, 5 Mar 2020 05:48:55 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 05 Mar 2020 11:18:55 +0530 From: vjitta@codeaurora.org To: Vlastimil Babka Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, vinmenon@codeaurora.org, kernel-team@android.com Subject: Re: [PATCH] mm: slub: reinitialize random sequence cache on slab object update In-Reply-To: References: <1580379523-32272-1-git-send-email-vjitta@codeaurora.org> <1580383064-16536-1-git-send-email-vjitta@codeaurora.org> Message-ID: X-Sender: vjitta@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 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 2020-02-27 22:23, Vlastimil Babka wrote: > On 1/30/20 12:17 PM, vjitta@codeaurora.org wrote: >> From: Vijayanand Jitta >> >> Random sequence cache is precomputed during slab object creation >> based up on the object size and no of objects per slab. These could >> be changed when flags like SLAB_STORE_USER, SLAB_POISON are updated >> from sysfs. So when shuffle_freelist is called during slab_alloc it >> uses updated object count to access the precomputed random sequence >> cache. This could result in incorrect access of the random sequence >> cache which could further result in slab corruption. Fix this by >> reinitializing the random sequence cache up on slab object update. >> >> A sample panic trace when write to slab_store_user was attempted. > > A more complete oops report would have been better, e.g. if anyone was > googling > it, to find this patch. > > Also I was checking where else calculate_sizes() is called and found > order_store(). So if somebody changes (especially increases) the order, > shouldn't the reinitialization also be done? Yes, reinitialization must be done here aswell , will update the patch. > > This is even more nasty as it doesn't seem to require that no objects > exist. > Also there is no synchronization against concurrent allocations/frees? > Gasp. Since, random sequence cache is only used to update the freelist in shuffle_freelist which is done only when a new slab is created incase if objects allocations are done without a need of new slab creation they will use the existing freelist which should be fine as object size doesn't change after order_store() and incase if a new slab is created we will get the updated freelist. so in both cases i think it should be fine.