Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1328313ybf; Thu, 27 Feb 2020 08:54:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwu77FCx/6vPpuGnbFMAp52e6DeUS9DOJ3y3xkPFZRC9FcrKpJ9yW6bTViXfgHaWVX4ArJZ X-Received: by 2002:a9d:7d9a:: with SMTP id j26mr509331otn.21.1582822466758; Thu, 27 Feb 2020 08:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582822466; cv=none; d=google.com; s=arc-20160816; b=tF2cHu3Or9H6jBXatmeB38EqvFgdjC80CahXkop3ACZzDX/G0lEx50CbBHkN0ogvr0 VQF0u/oh+jHiECfgFemn8zzw9CJKSn5eFlM4bIPRS3goPsFSvqe0F6sGxntUv8kZup1/ lKEpHeQn5W7p2hWFTjqm+vcXRv0FFZFT8zic0uCHFFA/SLo8yQwVpfnXJ91mgPxa3qRI VXqzyzqeOA8DSKPNuSabaxOJJE39Iq8/VbUsz5dnwsRkDQdzRpQn6BnfRV+qavXSWo5E k3OfkcAgzdIs12UzXB8ifh34CArjZNDwR6No1z+536Wg7BeS6efILjWHgL6qdnk4mIxr wvag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=067FTtJLHYK++Q/Dz6jmzO4oYhtHljiSkM5TkmQTIhg=; b=xa4+2PkAPh4oY9EI0uxsUeH5JPtmB8oLAUlhDN4dD5r6fXKRDWEsxn8jR9yllp84Vn NSQbmxxwFLnGXGIBSxqnP3TE8kWQ4jU8EDd/vd2zYsz0g6EJ6Swyb7W3IGZBl/q9+kk/ ouT2YH+4rAWVmBeZSwGtxDn59d2A+nxqHwZ3epUz5mKM7XNnDQimjfFMu6QrvVv5j7LQ b/ovZuyAuPvRmiUUSVCkntwFrypiPdfpozfOMr+Kx/nZ5hjC3rWns8NQLvqhkPZmXJHR hKN8nmg93S2sRfKGdb0cSsrrsLJLXvQudp3OEFpwj2AsNuE61Sbeb1W9OPlYo2Ow2Bw6 7r0Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si168333oii.42.2020.02.27.08.54.13; Thu, 27 Feb 2020 08:54:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbgB0QyC (ORCPT + 99 others); Thu, 27 Feb 2020 11:54:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:60158 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727211AbgB0QyC (ORCPT ); Thu, 27 Feb 2020 11:54:02 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 79C7FAE06; Thu, 27 Feb 2020 16:53:58 +0000 (UTC) Subject: Re: [PATCH] mm: slub: reinitialize random sequence cache on slab object update To: vjitta@codeaurora.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, vinmenon@codeaurora.org, kernel-team@android.com References: <1580379523-32272-1-git-send-email-vjitta@codeaurora.org> <1580383064-16536-1-git-send-email-vjitta@codeaurora.org> From: Vlastimil Babka Message-ID: Date: Thu, 27 Feb 2020 17:53:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1580383064-16536-1-git-send-email-vjitta@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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.