Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4620996ioa; Wed, 27 Apr 2022 07:39:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwChrsxeID+VuL9U5DZbt5RWxanPtURrupuMWSyrDZi70BYf+HISIq8Kdt3Mqb8EMTHyQUO X-Received: by 2002:a17:90a:8581:b0:1b2:7541:af6c with SMTP id m1-20020a17090a858100b001b27541af6cmr33442987pjn.48.1651070340262; Wed, 27 Apr 2022 07:39:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651070340; cv=none; d=google.com; s=arc-20160816; b=sX2uKHVlTKYY/IJ1XXGteHSikdoPOVTRcWKGEKL29NaD9zsCerERMTi10U42YOUeUE jdESLvbghmeOFd2WmcmnHj3CagGEZQzVUMjSP+wu5qoUUmM8Xcgf/SQlkEsj3iiWwVhY FrGktGcBQcymLRgVAKO5z5Uo1nplQtP0RFIK0iA0L0W5g1wuek9C2VSLsU5MUohtV+gr 5XqTldk2uhUiLyAzTWTBGx06RnLxE93qHgL8zx5M8fttdAYEa9a5QfYD3Mi3zrZsbGp5 jkxdhkn1qu1c30uheAMp2heMp7RblrBqdjrzU0rBx5IRd1A7U+L4WJXsD/yzTGCBb/L8 iW7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=Fi2Xv8nY46vciG/itOD9WkTkeB6bI1rIUmdV3u4ELoI=; b=tYOfU4FKlNjXq9MZS1FSvD/iU1baOuhi54uqyKdsJnSsVcWvE70uZcHaZVl4xKbFv+ miUMkZIoMlU8AHJb05j4Wopr/jr4FrLSKshEQKPIARwyFLnAhYp/Xro0u5pLZ8vuwYVM xLkwZgBjF617J8a2ZITvycWrACRbwgZc7GjWqBC8b6Tu5/BpHOi3LIBhXjLCeYJF/TRe yCJhe+idCLxdTkT6kZqjqPbPt1zEPQ3vewWjyGeJqUHtWP4q6IsjASkeXopTJZ9DhjBS uxM7seFr5fx2sKPODJDAx1JF0IBUcdtcr/DDjkpAAL8H2DSpmD82qVr18zv7s4rkex0R RMpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bskKkJDm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j16-20020a056a00131000b00505ad6b7610si1575923pfu.63.2022.04.27.07.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 07:39:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bskKkJDm; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5D24250E07; Wed, 27 Apr 2022 07:10:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237389AbiD0ONn (ORCPT + 99 others); Wed, 27 Apr 2022 10:13:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237349AbiD0ONl (ORCPT ); Wed, 27 Apr 2022 10:13:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4DD1450065 for ; Wed, 27 Apr 2022 07:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651068621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Fi2Xv8nY46vciG/itOD9WkTkeB6bI1rIUmdV3u4ELoI=; b=bskKkJDmy9LdB/0c/a8Rw2UGE/wlqDFw+4+cRgYUnpBi8MqdR/J6GQDd1QCjPaqBM2Uz/9 P/qGKy90je6vBmHIMIWt+QM+cHLNl1ZFyY2P/jP0s6t86lyVImhQuXMuGeoeJIjWEo0vFs wGl2M/EPyPEP721/E9POeSIKGYugr2o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-2CVEY-MaPuCTWkkuUlfH7A-1; Wed, 27 Apr 2022 10:10:17 -0400 X-MC-Unique: 2CVEY-MaPuCTWkkuUlfH7A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 67CCC8038E3; Wed, 27 Apr 2022 14:10:17 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 679119D7F; Wed, 27 Apr 2022 14:10:06 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 23REA6cT001893; Wed, 27 Apr 2022 10:10:06 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 23REA6Vc001889; Wed, 27 Apr 2022 10:10:06 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 27 Apr 2022 10:10:06 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Andy Shevchenko cc: Linus Torvalds , Andy Shevchenko , Mimi Zohar , device-mapper development , Linux Kernel Mailing List , Mike Snitzer , Milan Broz Subject: Re: [PATCH v2] hex2bin: fix access beyond string end In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Apr 2022, Andy Shevchenko wrote: > On Tue, Apr 26, 2022 at 5:29 PM Mikulas Patocka wrote: > > On Tue, 26 Apr 2022, Andy Shevchenko wrote: > > > On Tue, Apr 26, 2022 at 08:07:44AM -0400, Mikulas Patocka wrote: > > > > On Tue, 26 Apr 2022, Andy Shevchenko wrote: > > > > > On Sun, Apr 24, 2022 at 10:48 PM Mikulas Patocka wrote: > > ... > > > > Still shadows error codes. > > > > > > > + return -EINVAL; > > > > > > > return -EINVAL; > > > > What do you mean? What's wrong with "return -EINVAL"? > > The actual error code is returned by hex_to_bin(). What is the point > of shadowing it with the explicit value? hex_to_bin returns -1 on error, hex2bin returns -EINVAL on error. This is inconsistent and it may be fixed (after verifying all the hex_to_bin callers - a quick grep over the source shows that there is "if ((k = hex_to_bin(in_str[j--])) != -1)"). But for the purpose of fixing this bug, we should preserve the behavior and return -1 and -EINVAL just like it was before. Mikulas