From patchwork Thu Jul 18 19:14:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13736655 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 760EA53E22 for ; Thu, 18 Jul 2024 19:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330069; cv=none; b=omyN5vvJXKab3CPf3BUH66cr3HWxSNe5htDmMRAnvJg2n17q+QaZc0tBMtYGCyK+OQJR/P4cBvqJrH1KbNumFdvl9APmLTEyM4lc8bNxySBGp6LAsFemVy/O692+xLYKuXEGMHL+nhLnhANf91a8FDF64PXYdJCq7xe92BhSEck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330069; c=relaxed/simple; bh=G7ysSdN4nbQM4/YGx4XqgeIVFmGfJW7kLbjDh4sffmc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fg/YvP9gkB61zIN7Q0Bq+JUNkV8FgFM2epmd/M6dGqyjxjDN3ssyMr2ysLL1MesWi1hDhsaVhOnejfoq7R395IQ9L4TpHWlBtUFgvXW7C5VCsaSTzX7AMhOKVoo2PerT0cowqD8V/yTJJR3yu8rDFK7fXLhLYnrWHGnSSzCwPE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=gJDaFU6K; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="gJDaFU6K" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2eeb1051360so14137811fa.0 for ; Thu, 18 Jul 2024 12:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1721330065; x=1721934865; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2BDoJEQcF+B94OM1h6B3wCPV/MSMOCb79YIwrru+A6s=; b=gJDaFU6KxmER3lOTpPT2fK9gK+/KUT1hz7V4athLIsX8C7KEpqQHzx1zhAtXP5h1Wq 61japQpcaZEJDv5xcFBkHydjn/+aNHsu4VJ/KYg+LkX0G4ZszQ83qmz7nj/hzp+vvQLi 6Hj5Ul/3okVJx5a8ZdMiA4Esfyly9DetFmDORsETNSO7E4KklIWkF5CB2qS7N28V0Wpb D41CFpOJ5TtvtnJq8dhiBIvCjj1UTjPOq/GmA7BENxjg/Cj2Ow4udT3zNmXm0bIvkJi7 RJkfatsV3Z3nhIc8TX0LESd9Q0OVJkP0z5Ju8TrmlH2fvxsgU5h0aEkxEXM7b23m8sY8 Pl7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721330065; x=1721934865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2BDoJEQcF+B94OM1h6B3wCPV/MSMOCb79YIwrru+A6s=; b=GMA+5eHS1z0uqwuoSxJpoMrnOXD2QOrMZr5IG0JGo8YGVTJNwBpLfYsW+RTjSosO55 SIrIigdF4N9b5vbZeGzFKn/UEtUd+y07zaN4B+nTd3iQ/VwKFpd1/DFko6Olr9I6Ju+5 dQPrvT5qDqGFBMZ70fTbmdazNfOvwU6v8oowoun8FoDorptTIjr/G3oJhLhffzw5ljnP l7gsER017R7QGb2Nsvbf4wJBYeDJ2ttvS3RHN+bCdxl+G3gM0tHaDom1YtChLWrUPd2G AHg52hKDZeWhgDDn7keB6Tsn3iFEGNVJSmBzRclPyRyMSMBCPSzgEVi+TpAkVwv5YCrG LI+Q== X-Gm-Message-State: AOJu0Yydm4RAo1WbjKaT5V4LclpuBI/YByiNs/PHNhKbhBcHJeG1V8Kt p8j0lFzcnumySjebHme5LyIBR+MFxS2PQ2b0sFAuq4hgnVOLo2wxBzq38mGvphE= X-Google-Smtp-Source: AGHT+IF+pGMaVrKnMPCNMcIF7nSu0saMUnvZ2ffMzGvU8XeLCaGJNph9aNY3I1uy4d8iwEdIjUTgTg== X-Received: by 2002:a2e:914d:0:b0:2ee:4b17:dab9 with SMTP id 38308e7fff4ca-2ef05c4f868mr22392321fa.4.1721330065261; Thu, 18 Jul 2024 12:14:25 -0700 (PDT) Received: from localhost (p200300de37360a00d7e56139e90929dd.dip0.t-ipconnect.de. [2003:de:3736:a00:d7e5:6139:e909:29dd]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5a2b73036f5sm209718a12.53.2024.07.18.12.14.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jul 2024 12:14:25 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev Subject: [PATCH 1/4] libmpathcmd: check len parameter in mpath_recv_reply_data() Date: Thu, 18 Jul 2024 21:14:18 +0200 Message-ID: <20240718191421.110487-2-mwilck@suse.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718191421.110487-1-mwilck@suse.com> References: <20240718191421.110487-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Found by coverity. Callers check this parameter already, but the function is exported by libmpathcmd, so make sure we don't write '\0' to reply[-1]. Signed-off-by: Martin Wilck --- libmpathcmd/mpath_cmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmpathcmd/mpath_cmd.c b/libmpathcmd/mpath_cmd.c index 60b2d96..d7c3371 100644 --- a/libmpathcmd/mpath_cmd.c +++ b/libmpathcmd/mpath_cmd.c @@ -170,6 +170,8 @@ int mpath_recv_reply_data(int fd, char *reply, size_t len, { ssize_t ret; + if (len <= 0) + return 0; ret = read_all(fd, reply, len, timeout); if (ret < 0) return ret; From patchwork Thu Jul 18 19:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13736658 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C774145A12 for ; Thu, 18 Jul 2024 19:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330072; cv=none; b=KIxt36AWmCdRjGwvemDMaHBAddyQaPoW+1aFEYHD20kR72R65aPM9w98Y9fghBjpR1v8Wn1wPl94Jg0Pv7EPiWLVy8liN1RtGcFOaL8/CSYRF1QNmNHt/Y+VjPKjxl5KJ7wrOf3/vwfETGkEolOiAxbnkOUFHC5OOSa+pv8ZEnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330072; c=relaxed/simple; bh=nfAj7YTzofZYIU+z28DQZbdhsiA6ApZ5o0hBnk+PE3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YDZynwETq8o/6rpA/PArOFiwewNsgq7ZtE8Dd3C/PKGuqt9i7KP3LUVkiE/FezlKCoijJfDmMFwVmW/rJDuaGv0zmw9AbAh4XKjh2qoByh6ALI4/BqUTRezivGh4XSI2Cb/Pj4eLE2Yg3/lx+WIBTc24yb35Z93L8vIjjNhabfw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Gqb/j0Y8; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Gqb/j0Y8" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-52ea34ffcdaso815323e87.1 for ; Thu, 18 Jul 2024 12:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1721330066; x=1721934866; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d9WJCFuN1tvI6IUVsLnHSr7Ls9KijzOlDzyxqa86w6A=; b=Gqb/j0Y8au5LJdsHjGyXGCFHkb6mSk24lWmpQbwfnX2SiCnzEesVI65w2UTd8xtjPa PuaoBAj34mnj2t2k//sTmoVNcD6ig6hwWD6zCqo8c55HHSNyI0pOpshauBPWTAXuvwFY MPB0hft7Q9rpG59e7/r82V+alRCghbwI5X6+c9n1nbuRi7k/XJ4Mf4EP5u8rRjXVWfVZ Eqh+3gMjUjJ46Zn51C5TEoXThxh5efWFGxsZD2Z5McYVtt07FyA+0ex9+7AptD7tNOc7 pGv2Mz/UywXfZ8+1XsM0kN9ERUa1kEMgpbf4HXz3d1HycMywJqpQKsurtGa8TmUotn5e ofBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721330066; x=1721934866; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d9WJCFuN1tvI6IUVsLnHSr7Ls9KijzOlDzyxqa86w6A=; b=DUHIO5QcJ+oLmxEGNtn9WQyKB4/QaPkO/2t+71TxYbvGxaOdokhIGk0/3lfT4sxUEd DDiTpKon1oxvWBav103AiZ+lvmJQYxKPFeWtKjiC+84nkMY8WTmG7A7REzDePvJNd4Nl jIcw9mAGowa+zH3f0tPCa4Smh+CQZCdb/kbamYFOVUrMPLtZvBVON7wTYB/hHuZhzbjH +9tLZQ1HkOti15epXB9paldhdlVwzXugMIGX5x4U7SpzW1VRdbf6xFrOjYd6aOTbe3Wz nyEmRULSd3BVeL67RZ+db3O/ai3G6sULuHH+Uc8Q2EVLjqdebifMsYWrLAwZxno2s5Pr DqjQ== X-Gm-Message-State: AOJu0YyLLnowMBFuf/gyuJGdOA+Mm1n37zw2m9RNFgxWGI+aOrXraV0P CdGkw44majSLxXNpOc6YyFVDYr1c+HFiO9vMTUQjr7mvp7XNdrb5tGlRbvVsgSQ= X-Google-Smtp-Source: AGHT+IGpM2+ZRFY6uLXCVXBoPMqF/HaNWZbmwoOGAKTWawEwdHQtiRUPbYWMZR/+x0yvr4uN3mojyQ== X-Received: by 2002:a05:6512:1318:b0:52c:dba6:b4cb with SMTP id 2adb3069b0e04-52ee53c3e0amr3736987e87.13.1721330066160; Thu, 18 Jul 2024 12:14:26 -0700 (PDT) Received: from localhost (p200300de37360a00d7e56139e90929dd.dip0.t-ipconnect.de. [2003:de:3736:a00:d7e5:6139:e909:29dd]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-a79bc820e92sm585436766b.205.2024.07.18.12.14.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jul 2024 12:14:26 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev Subject: [PATCH 2/4] multipath-tools: use signed loop variable in vector_foreach_slot Date: Thu, 18 Jul 2024 21:14:19 +0200 Message-ID: <20240718191421.110487-3-mwilck@suse.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718191421.110487-1-mwilck@suse.com> References: <20240718191421.110487-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If we delete entries in the vector_foreach_slot loop, the loop index may underflow. It's not a big issue because we re-increment it in the next iteration and use a cast to int in the loop end condition, but it's cleaner to use an int here. Found by coverity. Signed-off-by: Martin Wilck --- multipathd/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 13ed6d0..be35038 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -762,7 +762,7 @@ coalesce_maps(struct vectors *vecs, vector nmpv) { struct multipath * ompp; vector ompv = vecs->mpvec; - unsigned int i, reassign_maps; + int i, reassign_maps; struct config *conf; conf = get_multipath_config(); @@ -1748,7 +1748,7 @@ static int map_discovery (struct vectors * vecs) { struct multipath * mpp; - unsigned int i; + int i; if (dm_get_maps(vecs->mpvec)) return 1; @@ -1970,7 +1970,7 @@ static void mpvec_garbage_collector (struct vectors * vecs) { struct multipath * mpp; - unsigned int i; + int i; if (!vecs->mpvec) return; @@ -2014,7 +2014,7 @@ static void missing_uev_wait_tick(struct vectors *vecs) { struct multipath * mpp; - unsigned int i; + int i; int timed_out = 0; vector_foreach_slot (vecs->mpvec, mpp, i) { @@ -2039,7 +2039,7 @@ static void ghost_delay_tick(struct vectors *vecs) { struct multipath * mpp; - unsigned int i; + int i; vector_foreach_slot (vecs->mpvec, mpp, i) { if (mpp->ghost_delay_tick <= 0) From patchwork Thu Jul 18 19:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13736656 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0D40145A19 for ; Thu, 18 Jul 2024 19:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330071; cv=none; b=K/qDUa96+B0/xsK49tghoWJKYC9hWRGEZcSlY++5SJWPhJph3OjAgs9qweIMcoRxS5aht+hTxOWO4k7QwmZ1CA92BKbXRmimVmivrQBZRTyjABrfmbYJvW4jHxBFwgQaTbzFWERSYvMEaRt7WYbzqh+ku+6+FOQSlUmSLWKFsEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330071; c=relaxed/simple; bh=9QQxOAw+n25rBXISDTmgxfYJc1cAC7AQgR/RM+R4aMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NIrjfbaA9BUPngOnqFhj5i0Sd5Aj0/JeG62NRN79DFtqNKLeSMPZZ0sPpAFxB4Wjtdc2b5ctKERGTqNjIIyIYc4Kgl8r4l05Pklv1BaQ9XSfurXz8QDoIH3j7kWv0RIZjmVHoYpZbfDw0NQinzupNROawxQ6nQT11+OsRF3Z7Y4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=dYE599EZ; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="dYE599EZ" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a797c62565aso109505866b.2 for ; Thu, 18 Jul 2024 12:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1721330067; x=1721934867; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f4a9A3z0g26oo6z860dEh5Y67eH0jzn3fNhDi+LhVgU=; b=dYE599EZcEfham87hXcSV0W2jv3Skp/0mbaHJyUlVU3gY3e6Pe4Or8LjxKk2k5ufN7 EHohdQ4r1YHBYqmERwzDZS5tew1CmgHcr52LrZn+0lS0W4DE7NknhnydVzeSQ9KwXeDB EO0udyLg/yW6e7KStm7AZm7V8Ll/AfxpOO4pJS74j6o9m1sZAius5GxXhePIlCRw8dov OEkAq4DqqiS2Ipnu5mJAocQbK8kifqEhROrCDll1TNAOmbwsUbajEY+2rxDM+5H+zu4Y 2dF8Ov+AduBo6QFhX3fi6fR9HcjQt2L9zK5GQgVHs9M4HMTNB3TmfD4WBIhOxLB21Uq1 g1wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721330067; x=1721934867; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f4a9A3z0g26oo6z860dEh5Y67eH0jzn3fNhDi+LhVgU=; b=CCJYQ1UF+spzi80OUwwH/5rbcgbShqpziE4H07foBDeUe5svuGJo0TF+zqbpwTLnnp vS2FQRpvxA9aajCJzqrlFa9Upalwr8TDk3IIMHVct9hGjKlYUZCl5GLkILJuC/u++Dqq h/mYXwR5nExQVhubAchWxz6smSa/fmxa/4/pfYEb76OT1pHpwptzyMQNHsGtK5CmlMm+ s15qZZbyx8l24onaHxVdPfRte4mtlk6MDUI3Dv91Agx63YY7z50iP9dqYneqJzk9t9qY O2Ha5RWhrsxGgMyVtHP6RlkT+Vcp5OF1cJQcuc12aHsM/k5ZrD9vZ5KAQXAFrp1wMDg4 Jqrw== X-Gm-Message-State: AOJu0YycHXesZs4nRocEuOyLMzhkAXDoTtMLGu0nt6Vu7URAA0jvnieT yx/n3ZkL4WL2kV861TJJpIqyKYzYwI/c1HyKuScqQk9BaBEFj02dzZnS6gsw4xk= X-Google-Smtp-Source: AGHT+IGAUnKL2WdUkJZKwZoRTSsadocq8Y09cAdt5Ufi4QdBlIXuVbyhg2E1S1qiioP/cdYlBBxi0Q== X-Received: by 2002:a17:906:3858:b0:a75:25b8:ffc with SMTP id a640c23a62f3a-a7a013369d6mr398378866b.57.1721330067028; Thu, 18 Jul 2024 12:14:27 -0700 (PDT) Received: from localhost (p200300de37360a00d7e56139e90929dd.dip0.t-ipconnect.de. [2003:de:3736:a00:d7e5:6139:e909:29dd]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-a79bc5d1a95sm591396766b.79.2024.07.18.12.14.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jul 2024 12:14:26 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev Subject: [PATCH 3/4] libmpathutil: avoid size_t underflow in strchop() Date: Thu, 18 Jul 2024 21:14:20 +0200 Message-ID: <20240718191421.110487-4-mwilck@suse.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718191421.110487-1-mwilck@suse.com> References: <20240718191421.110487-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Found by coverity. Signed-off-by: Martin Wilck --- libmpathutil/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmpathutil/util.c b/libmpathutil/util.c index 67db3c8..9c422f1 100644 --- a/libmpathutil/util.c +++ b/libmpathutil/util.c @@ -27,8 +27,8 @@ strchop(char *str) { size_t i; - for (i = strlen(str) - 1; i != (size_t) -1 && isspace(str[i]); i--) ; - str[++i] = '\0'; + for (i = strlen(str); i != 0 && isspace(str[i - 1]); i--) ; + str[i] = '\0'; return i; } From patchwork Thu Jul 18 19:14:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 13736657 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3B02145A1C for ; Thu, 18 Jul 2024 19:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330071; cv=none; b=E2FKTy2TQiDjmv4wLLlPNK+//wk97K2sJqtUHXZmKZ+I40cGNcddQppJplk5n2jVqGPim7MroBCa+dZ4M1fCorWrceBlwZmNyO8x6DeIbS4ZFASuwkJlt758qKUPCXde8+R2oAKFFNS6XPt2ry5Cp6tMf8ex1B4QjAi0vGY6Fjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721330071; c=relaxed/simple; bh=8W6vsdN86mClo99esXRdC3/jAL5K5Br8Z4kl8fFK8VU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K5x8ptjyLxYFr3ZgDbEA279zyYKW5mZWunVFtktE++3oSRKy+UaDMXjLcQ240wovnUstdpJ95Qf8vtXA+t/gpPLU6XICFEIW+K0t1jy8ZFjLj2Wgjc8uaW9OXpNX217b/7D5Cehi/QzMqICipvacKHjM2PNEOGkc/MWMTZhpe7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=TC+3vaHI; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="TC+3vaHI" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2ebe40673d8so15189981fa.3 for ; Thu, 18 Jul 2024 12:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1721330068; x=1721934868; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vWURQ6/hqvrXHEWST7ku8P4rUskhLBLuPDjw9+eSQyI=; b=TC+3vaHIYl+WtpQ/TQRGLTFK1HSqLrCzCw16rwqjvQ0FpC1ELX8Gycz0bQEbshZdir DvSInBIQqaLPr19AeKDKlYahN01/uHJ8YrWiPFLIzYJOVagm2aQ6AkjKNm+SBYfC2fuA CXg/lXh/8b/vbmC2RdVMBTUVWzx0q4HXwwyh4W4DJzR1+Iqv+ESAHmluUXOAEi80ZanB Zi2If5essCPKuYcL0qWa5LWcNNf41E+EC28157sEvZGxcvl+7v5X6n0UsUMZNKzbWZ05 9451beQM6a4SYE9EMk75ZjunV+7aheM8kLVdNd6O+L2PIHOU9p2ioDSydJd5gvL6npqo eRNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721330068; x=1721934868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vWURQ6/hqvrXHEWST7ku8P4rUskhLBLuPDjw9+eSQyI=; b=ZVK3cwneNa48WZ0gqhlBJZ46FjgcIqcSLR9RowKoZrktgSs4ZTa/m3OSsEMz9XTH6j C6lwn4mIetKyPdGrNxSYmdcYPvro20VnJQ+IgCNFlRv6OsAPKYC/dzayTDHlj9KbA3yO yA0d2G30rV5/g90YaS8NrV38lzbL4Fa0Es3Ckqo5iuDmpr3+w1qEontGcQnpPiVCtFhT 2lfHyOCWnHzcmkTNK1UlP0FIQv/D/2Gtmkw6UJN8o5x60ipV4vXGtwN+z7N5aMVKl31z Fqxbx6fKuO9xxri5ey5B0m7J00yXoRD5hJ23vThANqMTaRlIKn1uiqZK4AcmVcauJacN FLpQ== X-Gm-Message-State: AOJu0Yx2Gh3GUzo0JFZPhjdRoDfS1NXYIVsHynD3rCYLM1yl4C1kUZsN 1ofCR/vAhA2KpyegpLodx67UfvA5aNS1xenckLEGJY6Nad+1LuwHXCvxQWX4jHM= X-Google-Smtp-Source: AGHT+IG/uIkkRptEDhoZcRMKa4ub+LN49HyKx3/XFBlARQHSKObwYih/UEW/9hnyLlUWEDgE9mNoyQ== X-Received: by 2002:a05:6512:6cf:b0:52e:9ec8:a407 with SMTP id 2adb3069b0e04-52ee543ff4fmr4319616e87.63.1721330067958; Thu, 18 Jul 2024 12:14:27 -0700 (PDT) Received: from localhost (p200300de37360a00d7e56139e90929dd.dip0.t-ipconnect.de. [2003:de:3736:a00:d7e5:6139:e909:29dd]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-a79bc7f236esm593036666b.138.2024.07.18.12.14.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jul 2024 12:14:27 -0700 (PDT) From: Martin Wilck X-Google-Original-From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Cc: dm-devel@lists.linux.dev Subject: [PATCH 4/4] fixup "libmultipath: use libmp_pathinfo() in update_multipath_table()" Date: Thu, 18 Jul 2024 21:14:21 +0200 Message-ID: <20240718191421.110487-5-mwilck@suse.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718191421.110487-1-mwilck@suse.com> References: <20240718191421.110487-1-mwilck@suse.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We need to check for NULL before dereferencing mpp. Found by coverity. Signed-off-by: Martin Wilck --- libmultipath/structs_vec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 731b1bc..d58ef5a 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -504,11 +504,12 @@ update_multipath_table (struct multipath *mpp, vector pathvec, int flags) int r = DMP_ERR; char __attribute__((cleanup(cleanup_charp))) *params = NULL; char __attribute__((cleanup(cleanup_charp))) *status = NULL; - unsigned long long size = mpp->size; + unsigned long long size; if (!mpp) return r; + size = mpp->size; r = libmp_mapinfo(DM_MAP_BY_NAME | MAPINFO_MPATH_ONLY, (mapid_t) { .str = mpp->alias }, (mapinfo_t) {