From patchwork Wed Feb 3 17:34:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1435492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=suuZ2sZY; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DW81x1kNJz9tk0 for ; Thu, 4 Feb 2021 04:34:29 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A121E385481F; Wed, 3 Feb 2021 17:34:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A121E385481F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1612373665; bh=LvOIFY+fVjIzCtNvk45KSByHKGlImjmVu+xnLhtJ/nI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=suuZ2sZYw8YBuuoWotWub7kqb1GAiUOhs97xXbSW6FJEge2pBn18v8IzYcmQ91zVg fDUemXvEqFg3Fr4bNi1JoAnwzAfOOHB7WL0TeY1+9bgwHCxoSaO5ZoGqzPfYbnV+KX xBdPBj7P5Db8Y1Y3hLGPyR678reu4sQPWkA5EuUI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by sourceware.org (Postfix) with ESMTPS id 35EC5388C02A for ; Wed, 3 Feb 2021 17:34:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 35EC5388C02A X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 14B9C21E0B; Wed, 3 Feb 2021 17:34:21 +0000 (UTC) Received: from pdx1-sub0-mail-a56.g.dreamhost.com (100-96-18-11.trex.outbound.svc.cluster.local [100.96.18.11]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 79BA5219B2; Wed, 3 Feb 2021 17:34:20 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a56.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.11 (trex/6.0.2); Wed, 03 Feb 2021 17:34:21 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Glossy-Lyrical: 08c76f744ee994a1_1612373660739_2062100688 X-MC-Loop-Signature: 1612373660739:2333049422 X-MC-Ingress-Time: 1612373660739 Received: from pdx1-sub0-mail-a56.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a56.g.dreamhost.com (Postfix) with ESMTP id EA19D7ED30; Wed, 3 Feb 2021 09:34:19 -0800 (PST) Received: from rhbox.intra.reserved-bit.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a56.g.dreamhost.com (Postfix) with ESMTPSA id D2DB77E372; Wed, 3 Feb 2021 09:34:17 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a56 To: libc-alpha@sourceware.org Subject: [PATCH 1/3] Fix casts when setting tunable range Date: Wed, 3 Feb 2021 23:04:04 +0530 Message-Id: <20210203173406.2075480-2-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210203173406.2075480-1-siddhesh@sourceware.org> References: <20210203173406.2075480-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3495.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Cast tunable min and max to target type before comparison so that we don't mix comparison of signed and unsigned types. --- elf/dl-tunables.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index b1a50b8469..488be4bbf1 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -107,6 +107,8 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val, #define TUNABLE_SET_BOUNDS_IF_VALID(__cur, __minp, __maxp, __type) \ ({ \ + __type curmin = (__cur)->type.min; \ + __type curmax = (__cur)->type.max; \ if (__minp != NULL) \ { \ /* MIN is specified. */ \ @@ -115,15 +117,13 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val, { \ /* Both MIN and MAX are specified. */ \ __type max = *((__type *) __maxp); \ - if (max >= min \ - && max <= (__cur)->type.max \ - && min >= (__cur)->type.min) \ + if (max >= min && max <= curmax && min >= curmin) \ { \ (__cur)->type.min = min; \ (__cur)->type.max = max; \ } \ } \ - else if (min > (__cur)->type.min && min <= (__cur)->type.max) \ + else if (min > curmin && min <= curmax) \ { \ /* Only MIN is specified. */ \ (__cur)->type.min = min; \ @@ -133,7 +133,7 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val, { \ /* Only MAX is specified. */ \ __type max = *((__type *) __maxp); \ - if (max < (__cur)->type.max && max >= (__cur)->type.min) \ + if (max < curmax && max >= curmin) \ (__cur)->type.max = max; \ } \ })