Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1005620imm; Tue, 5 Jun 2018 07:47:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJY92WhumjDxma8IXXLXsQ0JSC7N/UQbbRdCQc0QFjuIDwzmz6hXNz+kQN2+wUkWsyoNHnZ X-Received: by 2002:a63:b407:: with SMTP id s7-v6mr18380987pgf.334.1528210032242; Tue, 05 Jun 2018 07:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528210032; cv=none; d=google.com; s=arc-20160816; b=T3PTncJ26aaWYkkWTtg2t0H30OU6cX0tAfosBbv7t2813ipC093n2/dONlMLwIOjps CtaE7Iqp0h/59RfhibnZK90U3LLqTUO1vf0pyE7CCI4Awf3/oCwJbFdf/kkJWooVj659 LBYuctB6Gjo8GmXa2gc6FKGfbd6D4Wv1QP9i5VIQb1QeI58DIGWvCG006t6Qzv39DRDr bCyra9QFZNHjm/dcKAM/mk1t9LISglrK9ywHrO6RkTl8K6AuJUhJWfVzPqGbmJqxe6U6 PP4yZzqsrM6+c1o1WJV/YO78Z6aAx9drnQJY+y0NP1EKE9sVRKucsGBHtO+ZL6+ewWAS rYig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=R46IDeelLB1cK8Sy6NYnjB7qpaJR4KemN0JZDtUbX5Y=; b=pZklcbGyyV19G+0bSZha22aHb+sbVN356tLntlQCtJfDxHReipbZhf1Z5thSlG6R4S MgUlW1+yJP9vd2l3pQVQrIEo9lu3HCwnfXLJLGGxyuvs09Fz+I3xer1VZOZNf+/tZ4MW 8gjtk+ntEfuN6okgDXOMRKJkNi5zvvWNnZdksBLGVBYfUXq9APR8azjS+pMIcDRws2OR RD42wUkpFrARRg2dpS7NFG78NLiGOtk5gG1K8R+rGddmI+AVr5pDJ/72brejjmtATAAG iCA3B5Kj447Tm8tzVLb0k2xnCOitksN0hUtUStetHrOT4vi4c0qjaKHku1OO0CiIC2dn JRfw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2-v6si14922483plx.88.2018.06.05.07.46.57; Tue, 05 Jun 2018 07:47:12 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbeFEOpK (ORCPT + 99 others); Tue, 5 Jun 2018 10:45:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51950 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752518AbeFEOpJ (ORCPT ); Tue, 5 Jun 2018 10:45:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8D3AC12A4; Tue, 5 Jun 2018 14:45:08 +0000 (UTC) Received: from localhost (ovpn-112-63.rdu2.redhat.com [10.10.112.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6010020628A1; Tue, 5 Jun 2018 14:45:08 +0000 (UTC) Date: Tue, 5 Jun 2018 10:45:07 -0400 From: Mike Snitzer To: Jens Axboe Cc: Kent Overstreet , torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: dm: Use kzalloc for all structs with embedded biosets/mempools Message-ID: <20180605144506.GA13100@redhat.com> References: <20180605092633.29583-1-kent.overstreet@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 05 Jun 2018 14:45:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 05 Jun 2018 14:45:08 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'msnitzer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 05 2018 at 10:22P -0400, Jens Axboe wrote: > On 6/5/18 3:26 AM, Kent Overstreet wrote: > > mempool_init()/bioset_init() require that the mempools/biosets be zeroed > > first; they probably should not _require_ this, but not allocating those > > structs with kzalloc is a fairly nonsensical thing to do (calling > > mempool_exit()/bioset_exit() on an uninitialized mempool/bioset is legal > > and safe, but only works if said memory was zeroed.) > > > > Signed-off-by: Kent Overstreet > > --- > > > > Linus, > > > > I fucked up majorly on the bioset/mempool conversion - I forgot to check that > > everything biosets/mempools were being embedded in was actually being zeroed on > > allocation. Device mapper currently explodes, you'll probably want to apply this > > patch post haste. > > > > I have now done that auditing, for every single conversion - this patch fixes > > everything I found. There do not seem to be any incorrect ones outside of device > > mapper... > > > > We'll probably want a second patch that either a) changes > > bioset_init()/mempool_init() to zero the passed in bioset/mempool first, or b) > > my preference, WARN() or BUG() if they're passed memory that isn't zeroed. > > Odd, haven't seen a crash, but probably requires kasan or poisoning to > trigger anything? Mike's tree also had the changes, since they were based > on the block tree. > > I can queue this up and ship it later today. Mike, you want to review > this one? Yes, looks good. From the start of revisiting these changes last week, Kent and I discussed whether it was safe to call mempool_exit() even if mempool_init() failed or was never called. He advised that it was so long as the containing structure was zeroed. But I forgot to audit that aspect. So this was an oversight by both of us. DM core uses kvzalloc_node for struct mapped_device and cache, crypt, integrity, verity-fec and zoned targets are already using kzalloc as needed. Acked-by: Mike Snitzer