From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9B061212E470D for ; Tue, 30 Jul 2019 15:18:13 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id k8so131873880iot.1 for ; Tue, 30 Jul 2019 15:15:42 -0700 (PDT) MIME-Version: 1.0 References: <20190730113708.14660-1-pagupta@redhat.com> <2030283543.5419072.1564486701158.JavaMail.zimbra@redhat.com> <20190730190737.GA14873@redhat.com> <20190730220102.GA15604@redhat.com> In-Reply-To: <20190730220102.GA15604@redhat.com> From: Dan Williams Date: Tue, 30 Jul 2019 15:15:30 -0700 Message-ID: Subject: Re: dm: fix dax_dev NULL dereference List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Mike Snitzer Cc: linux-fsdevel , device-mapper development , Linux Kernel Mailing List , Alasdair Kergon , linux-nvdimm List-ID: On Tue, Jul 30, 2019 at 3:01 PM Mike Snitzer wrote: > > On Tue, Jul 30 2019 at 5:38pm -0400, > Dan Williams wrote: > > > On Tue, Jul 30, 2019 at 12:07 PM Mike Snitzer wrote: > > > > > > I staged the fix (which I tweaked) here: > > > https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-5.3&id=95b9ebb78c4c733f8912a195fbd0bc19960e726e > > > > Thanks for picking this up Mike, but I'd prefer to just teach > > dax_synchronous() to return false if the passed in dax_dev is NULL. > > Thoughts? > > I considered that too but I moved away from it because I'm so used to > the various block interfaces requiring the caller pass a non-NULL > pointer (e.g. request_queue): > > $ grep -ri return drivers/md/dm-table.c | grep \&\& > drivers/md/dm-table.c: return dev->dax_dev && dax_synchronous(dev->dax_dev); > drivers/md/dm-table.c: return q && blk_queue_zoned_model(q) == *zoned_model; > drivers/md/dm-table.c: return q && blk_queue_zone_sectors(q) == *zone_sectors; > drivers/md/dm-table.c: return q && (q->queue_flags & flush); > drivers/md/dm-table.c: return q && blk_queue_nonrot(q); > drivers/md/dm-table.c: return q && !blk_queue_add_random(q); > drivers/md/dm-table.c: return q && !q->limits.max_write_same_sectors; > drivers/md/dm-table.c: return q && !q->limits.max_write_zeroes_sectors; > drivers/md/dm-table.c: return q && !blk_queue_discard(q); > drivers/md/dm-table.c: return q && !blk_queue_secure_erase(q); > drivers/md/dm-table.c: return q && bdi_cap_stable_pages_required(q->backing_dev_info); > > I'm fine with however you'd like to skin this cat though. > > Just let me know and I'll keep/drop this patch accordingly. Ok, since you've already got it queued, and there are no other required "if (!dax_dev)" fixups go ahead with what you have. Acked-by: Dan Williams I just reserve the right to go push it down a level if the kernel ever grows more dax_synchronous() users that do that safety check. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm