From patchwork Wed Jul 1 22:39:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11637441 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02989618 for ; Wed, 1 Jul 2020 22:42:55 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B61C62082F for ; Wed, 1 Jul 2020 22:42:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z38pEtAz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B61C62082F Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593643373; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qdjcuBNpHRB8+5v1LoeeB6NsLfOqK4Ad5eOn+GHX5pc=; b=Z38pEtAzFmPqaFGpn4k66Sg6nxqSvCdWgdLi9K7VwPgjbLkDcuutBucGrrT+lcCxlpz91O RsSm2eLAm64JGfeMqE0JGFLFWtF5dun3UjYrG9qSmCi7znx/0P6dF8G/56gLzV/4LOA4En kwNd0YEXielSHUMuCjGpCIdAiK9jvg8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-xPYU0loKMEuCIj4JU1dXRQ-1; Wed, 01 Jul 2020 18:42:51 -0400 X-MC-Unique: xPYU0loKMEuCIj4JU1dXRQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19224107ACF5; Wed, 1 Jul 2020 22:42:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A388B1D1; Wed, 1 Jul 2020 22:42:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7D1926C9C6; Wed, 1 Jul 2020 22:42:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 061Mdgg4020010 for ; Wed, 1 Jul 2020 18:39:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57EA579226; Wed, 1 Jul 2020 22:39:42 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C3B179222; Wed, 1 Jul 2020 22:39:39 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 061Mdbvn006248; Wed, 1 Jul 2020 17:39:38 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 061MdbEU006247; Wed, 1 Jul 2020 17:39:37 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 1 Jul 2020 17:39:33 -0500 Message-Id: <1593643176-6206-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1593643176-6206-1-git-send-email-bmarzins@redhat.com> References: <1593643176-6206-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 1/4] libmultipath: fix sysfs dev_loss_tmo parsing X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com dev_loss_tmo is a u32 value. However the kernel sysfs code prints it as a signed integer. This means that if dev_loss_tmo is above INT_MAX, the sysfs value will be a negative number. Parsing this was causing sysfs_set_rport_tmo() to fail. Signed-off-by: Benjamin Marzinski Signed-off-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/discovery.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index ffec5162..6a45979a 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -583,7 +583,8 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) struct udev_device *rport_dev = NULL; char value[16], *eptr; char rport_id[32]; - unsigned long long tmo = 0; + long long ll_tmo; + unsigned int tmo = 0; int ret; sprintf(rport_id, "rport-%d:%d-%d", @@ -607,13 +608,13 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp) "error %d", rport_id, -ret); goto out; } - tmo = strtoull(value, &eptr, 0); - if (value == eptr || tmo == ULLONG_MAX) { + ll_tmo = strtoll(value, &eptr, 0); + if (value == eptr || ll_tmo > UINT_MAX || ll_tmo < INT_MIN) { condlog(0, "%s: Cannot parse dev_loss_tmo " "attribute '%s'", rport_id, value); goto out; } - + tmo = (unsigned int)ll_tmo; /* * This is tricky. * dev_loss_tmo will be limited to 600 if fast_io_fail