From owner-dev-commits-src-main@freebsd.org Sun May 16 16:55:21 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A84D9628C29; Sun, 16 May 2021 16:55:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjpKj49SVz4n53; Sun, 16 May 2021 16:55:21 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qk1-x734.google.com with SMTP id o27so3640219qkj.9; Sun, 16 May 2021 09:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=myAaqOW72vhosiqprMnDFN1trSIm4iOk05JdaY8VWFI=; b=bTnwqbEdRCH2CuLyhfBtDZ5C8Z/ApTAIOEax0932HUdRBrXRcHPe01xYT1TB0D6MFe UOY4g+/oCPd64eRpVBrXh+rpjSsoXVmeL5AESqd6q0lRcsVcaBJqyBf1ui2q/kVrhxUD QJXQ9vp4Zt2RhYZNBl8nHW8OGO/+NIFudGa5mbo096axxJcfGsfLjBjs/5F+HHePX0f2 VmWAFbv+eerHPg0+TQiWLFCu8wMnLF+BFwBIXUUSR6TAZIM6MSOg+Lydpqj13BwTXaBa bxynSpWIkE1Zgua/epdASCL35xtzb9dAGZwf8BSFGkKggdF+L1nXsNSLWPPzDSlW0V8V LgiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=myAaqOW72vhosiqprMnDFN1trSIm4iOk05JdaY8VWFI=; b=H71Q+/dINwShPfSXmoyqMTnrSj/lCq63wd9vMb9m1QdSKYNcHaD6Vthev8ZCbiewbx 0l1SPmzOVzoMlzsjwVja7PEX5iqllZtdmPp2/lz2JuvpgynT/0RWVWViFr5Hn4MzD8pW /VRFYHiFxSnlzzyh59eEihiGyLHp3c6YJdwKRH9MhhmfarWD+qfcJG7EubA7Go/vwDWe wdrmM5ofYQDpxkyrUEgq61ky83RdFgqJpnXVaab15Zc3Q3qdiYMGvFMQTHmLvxvBEu0g bGqNqvcBFZAUZ8yZxuQ/KDefpvWCBs+dgLTY+l0ECjibK4cbK3leUkEvvLXIRiHgRiWj JiHQ== X-Gm-Message-State: AOAM5316mLv3Ru1l7IcO+dd/T04HZRo9sDOTbBdryJyRuRRU4P1QfFFZ DW/wifxLqPzp5vq7YWgBGmvrqdg499naaA== X-Google-Smtp-Source: ABdhPJyt86hQotUc3VmNuJu9uClqlCoeE8mtQTPJOhOcWOMOZ3nhGAcnFe3mRzdXapjuKHq9l+RG2w== X-Received: by 2002:a05:620a:9d6:: with SMTP id y22mr42975860qky.432.1621184120577; Sun, 16 May 2021 09:55:20 -0700 (PDT) Received: from nuc ([142.126.163.177]) by smtp.gmail.com with ESMTPSA id y6sm8841357qkd.106.2021.05.16.09.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 09:55:20 -0700 (PDT) Sender: Mark Johnston Date: Sun, 16 May 2021 12:55:20 -0400 From: Mark Johnston To: Edward Tomasz Napierala Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 0f206cc91279 - main - cam: add missing zeroing of a stack-allocated CCB. Message-ID: References: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202105161045.14GAjZIL093217@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4FjpKj49SVz4n53 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 May 2021 16:55:21 -0000 On Sun, May 16, 2021 at 10:45:35AM +0000, Edward Tomasz Napierala wrote: > The branch main has been updated by trasz: > > URL: https://cgit.FreeBSD.org/src/commit/?id=0f206cc91279e630ad9e733eb6e330b7dbe6c70e > > commit 0f206cc91279e630ad9e733eb6e330b7dbe6c70e > Author: Edward Tomasz Napierala > AuthorDate: 2021-05-16 09:28:04 +0000 > Commit: Edward Tomasz Napierala > CommitDate: 2021-05-16 10:38:26 +0000 > > cam: add missing zeroing of a stack-allocated CCB. > > This could cause a panic at boot. There are other instances of this, for example syzbot is currently hitting an assertion, seemingly because the alloc_flags field of a stack-allocated CCB was not zeroed: https://syzkaller.appspot.com/bug?extid=2e9ce63919709feb3d1c I think the patch below will fix it, but I did not audit other callers. It feels a bit strange to require all callers of xpt_setup_ccb() to manually zero the structure first, can we provide a single routine to initialize stack-allocated CCBs? diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c index 51d9e5f532f7..adf4fd17fc5b 100644 --- a/sys/dev/virtio/scsi/virtio_scsi.c +++ b/sys/dev/virtio/scsi/virtio_scsi.c @@ -700,6 +700,7 @@ vtscsi_register_async(struct vtscsi_softc *sc) { struct ccb_setasync csa; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = AC_LOST_DEVICE | AC_FOUND_DEVICE; @@ -716,6 +717,7 @@ vtscsi_deregister_async(struct vtscsi_softc *sc) { struct ccb_setasync csa; + memset(&csa, 0, sizeof(csa)); xpt_setup_ccb(&csa.ccb_h, sc->vtscsi_path, 5); csa.ccb_h.func_code = XPT_SASYNC_CB; csa.event_enable = 0;