From nobody Mon Jan 20 12:42:16 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yc92w6FR8z5lJ9v; Mon, 20 Jan 2025 12:42:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yc92w4ZZdz3vd7; Mon, 20 Jan 2025 12:42:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737376936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PnhsoaDeTzCjpwTU0M1eSlclO57vS3Hz5B0BGDLG3LY=; b=pxDjdrua1nsfRJOJHvO1QkvUdIS5JtjVCVTxkG7TvWJ+C7M1tna/hMom7OTShFkfgXKQyo oX3TvcNdxzjEJjwLk3nbpaWlWfIHRMld5nTRgidNAo06456AZmNVU0M6I6T28rrw8lAChj Gj25Zzw71GVL7meQ3F8R0jv6qRVjq/r7SH6Ufz4JZGOYlju6mPWZmDH2cb3rwC3S98uWnK Shx903cv2Nt7a92CuZXtVs5Wo+s/E/rGXMbuqF7Rmy5W/sicQntpo1AxNVA6p+u//6+/Vc hyZVFthobzBBHDUtLTCNKnrWVSf/iikPV/MgSR8gg+T3I1lkhJwn8JRvpjd7PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737376936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PnhsoaDeTzCjpwTU0M1eSlclO57vS3Hz5B0BGDLG3LY=; b=yVaIVM27fNT7bn05gFws/Lu5fPsPZ0RIiIF6G/W6UOopteTF27QWBtPcFnYjoAIelS/8D8 vl1xjE0+0PTR0uGJYut4oTQkIY/LN183QUaG7OX9BiKaGWGFqgjJ0OXsmBsZwPbHZ6hf2Y 3dsTZCIQ9KFjb4KsNgrD9LRUGLK1DQQQTixy+fkHm05iQ4METN4BpyBt1OwcYfdnsSopf7 4GK1VIhDPyqPs2w24tgM819KRmhrRyw3GyOIG7iTemWgDQv9erxNPIWSb66yFGT60rU4YZ LQLn4zKz0Aq73Hq7yANayLplMbaqUdPuZrlldGZZ15sU1wAaiGn2e1IQhgJdXg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737376936; a=rsa-sha256; cv=none; b=BUAOxaf05oaBDuLsE7J22vzm6BjTtbHAYcKH+fQIyBIuh9jAJoGc7mEyDID9f7N4toOLnO qo9cUXqUqPHtjXlpC+GJDwksKY785h9m4uGmMfG9cmGFq3n0ES++1quw7L5ADubXvwE+7q 7WsaN+YDhf4jz6vV2OQGhrlQSeGlb0truqf8DEKqyCR2hoa26RXZV5XHQ+fykIE9EgR+sb Hsu3cDO+WkWzdvXL25HH70QzTqYtvdbVWhIRd7xPwcCy1O2eC10uJlnhn6hB3S5ZQLFXDw eDLgUKTPQ0oDd6wEE3DL798EEsqpXVREkpTCMCZ1MN6VP7ild0/RXl9fJCuDog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Yc92w4BBdz5hH; Mon, 20 Jan 2025 12:42:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50KCgG5Z098810; Mon, 20 Jan 2025 12:42:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50KCgGT2098794; Mon, 20 Jan 2025 12:42:16 GMT (envelope-from git) Date: Mon, 20 Jan 2025 12:42:16 GMT Message-Id: <202501201242.50KCgGT2098794@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: eeecaa064c8d - stable/13 - cam: clear stack-allocated CCB in the target layer List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eeecaa064c8d4ba0f4a17739527ef285ee56fd36 Auto-Submitted: auto-generated The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=eeecaa064c8d4ba0f4a17739527ef285ee56fd36 commit eeecaa064c8d4ba0f4a17739527ef285ee56fd36 Author: Edward Tomasz Napierala AuthorDate: 2021-07-21 09:18:15 +0000 Commit: Zhenlei Huang CommitDate: 2025-01-20 12:39:27 +0000 cam: clear stack-allocated CCB in the target layer Note that, as pointed out by scottl@, this code should really look a bit different, in that the stack allocations should be replaced with dynamic allocation, and the periph creation should be moved to a context where one can use M_WAITOK. See the review for more details. For now let's go with a minimal fix until we're done with UMA CCBs. Reviewed By: mav, imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30298 (cherry picked from commit 616a676a0535eca78ce6b02a6226d0bcb69d7d4e) --- sys/cam/ctl/scsi_ctl.c | 3 +++ sys/cam/scsi/scsi_targ_bh.c | 7 +++++-- sys/cam/scsi/scsi_target.c | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/cam/ctl/scsi_ctl.c b/sys/cam/ctl/scsi_ctl.c index 4bc7091337ca..d3a3e299a213 100644 --- a/sys/cam/ctl/scsi_ctl.c +++ b/sys/cam/ctl/scsi_ctl.c @@ -477,6 +477,7 @@ ctlferegister(struct cam_periph *periph, void *arg) /*getcount_only*/1); } + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); ccb.ccb_h.func_code = XPT_EN_LUN; ccb.cel.grp6_len = 0; @@ -611,6 +612,7 @@ ctlfeoninvalidate(struct cam_periph *periph) cam_status status; /* Abort all ATIOs and INOTs queued to SIM. */ + memset(&ccb, 0, sizeof(ccb)); xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NONE); ccb.ccb_h.func_code = XPT_ABORT; LIST_FOREACH(hdr, &softc->atio_list, periph_links.le) { @@ -1850,6 +1852,7 @@ ctlfe_dump_queue(struct ctlfe_lun_softc *softc) struct ccb_getdevstats cgds; int num_items; + memset(&cgds, 0, sizeof(cgds)); xpt_setup_ccb(&cgds.ccb_h, periph->path, CAM_PRIORITY_NORMAL); cgds.ccb_h.func_code = XPT_GDEV_STATS; xpt_action((union ccb *)&cgds); diff --git a/sys/cam/scsi/scsi_targ_bh.c b/sys/cam/scsi/scsi_targ_bh.c index ae105ea03356..7b543763c521 100644 --- a/sys/cam/scsi/scsi_targ_bh.c +++ b/sys/cam/scsi/scsi_targ_bh.c @@ -239,6 +239,7 @@ targbhenlun(struct cam_periph *periph) if ((softc->flags & TARGBH_FLAG_LUN_ENABLED) != 0) return (CAM_REQ_CMP); + memset(&immed_ccb, 0, sizeof(immed_ccb)); xpt_setup_ccb(&immed_ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL); immed_ccb.ccb_h.func_code = XPT_EN_LUN; @@ -265,7 +266,7 @@ targbhenlun(struct cam_periph *periph) struct ccb_accept_tio *atio; atio = (struct ccb_accept_tio*)malloc(sizeof(*atio), M_SCSIBH, - M_NOWAIT); + M_ZERO | M_NOWAIT); if (atio == NULL) { status = CAM_RESRC_UNAVAIL; break; @@ -307,7 +308,7 @@ targbhenlun(struct cam_periph *periph) struct ccb_immediate_notify *inot; inot = (struct ccb_immediate_notify*)malloc(sizeof(*inot), - M_SCSIBH, M_NOWAIT); + M_SCSIBH, M_ZERO | M_NOWAIT); if (inot == NULL) { status = CAM_RESRC_UNAVAIL; @@ -348,6 +349,8 @@ targbhdislun(struct cam_periph *periph) if ((softc->flags & TARGBH_FLAG_LUN_ENABLED) == 0) return CAM_REQ_CMP; + memset(&ccb, 0, sizeof(ccb)); + /* XXX Block for Continue I/O completion */ /* Kill off all ACCECPT and IMMEDIATE CCBs */ diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index 4cb8024545e1..dcec777d1604 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -360,6 +360,7 @@ targendislun(struct cam_path *path, int enable, int grp6_len, int grp7_len) cam_status status; /* Tell the lun to begin answering selects */ + memset(&en_ccb, 0, sizeof(en_ccb)); xpt_setup_ccb(&en_ccb.ccb_h, path, CAM_PRIORITY_NORMAL); en_ccb.ccb_h.func_code = XPT_EN_LUN; /* Don't need support for any vendor specific commands */ @@ -933,7 +934,7 @@ targgetccb(struct targ_softc *softc, xpt_opcode type, int priority) int ccb_len; ccb_len = targccblen(type); - ccb = malloc(ccb_len, M_TARG, M_NOWAIT); + ccb = malloc(ccb_len, M_TARG, M_NOWAIT | M_ZERO); CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("getccb %p\n", ccb)); if (ccb == NULL) { return (ccb); @@ -1030,6 +1031,7 @@ abort_all_pending(struct targ_softc *softc) * Then abort all pending CCBs. * targdone() will return the aborted CCB via user_ccb_queue */ + memset(&cab, 0, sizeof(cab)); xpt_setup_ccb(&cab.ccb_h, softc->path, CAM_PRIORITY_NORMAL); cab.ccb_h.func_code = XPT_ABORT; cab.ccb_h.status = CAM_REQ_CMP_ERR;