From patchwork Fri Aug 6 12:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Mitchell X-Patchwork-Id: 12423387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0C8EC4338F for ; Fri, 6 Aug 2021 12:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4B6E61164 for ; Fri, 6 Aug 2021 12:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242963AbhHFMb7 (ORCPT ); Fri, 6 Aug 2021 08:31:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44127 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240236AbhHFMb6 (ORCPT ); Fri, 6 Aug 2021 08:31:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628253102; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KixNqcHb8bfLfBeFccLz/WI0Jy7E7rn7CMMF9Jr+bLc=; b=eWrtWkHslDoRLTe0nwIJs0grVvYl0Y4Xrw102gto6zJlXX8/OIylbKz+FgPhJZ5lH7CE2E VxB2jRv28qHmE+KP+eEhXLb4qCNRREd1L4jAd7sgYCBf+a7DL2hPNVqVu7VSWTx0no05LD MOPy1RQlz5yvlxyQ46IRtZeR/k4Exd0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-XhD7dNHNPE2lA3PSW_engQ-1; Fri, 06 Aug 2021 08:31:41 -0400 X-MC-Unique: XhD7dNHNPE2lA3PSW_engQ-1 Received: by mail-wr1-f69.google.com with SMTP id s22-20020adf97960000b02901535eae4100so3097558wrb.14 for ; Fri, 06 Aug 2021 05:31:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=KixNqcHb8bfLfBeFccLz/WI0Jy7E7rn7CMMF9Jr+bLc=; b=JxB+1rERYOHfDQFU28uB7ZtAhBlmWgM+B4umg2mskh+5Z+L05Af4XoPQT/J2Yj4Z3N Qn6UvkSWl2tZcp7yMtxgEF4tRdxaHc9CRH6bQvpP7uSoz7u3fD10zCtIfRhd96tyJAHP wbAbeYPXQTpjoUIekjoOL2BSVfg9twd3yvZXTCzbajCKVNV+W+zcYscg9MIP+0ezNP9Y eJxUGyTj+BycWq3MYRxhBlmXazfC3lFHj3VcomhM6dxQZAZ+2uXYBUasT9vHlBoXu8yN XfzWoBim8xWwqOk9MkIKmebPDb5GnKPxeuIIJME/BDkMRpE9QfhHzj0SYyOgsON59LP2 tsJg== X-Gm-Message-State: AOAM531DDkw8AEuFRpobJN7SSaCSg3tWuoWxRBEYBenUKQ3rDaSoXspA Yxxe0zNalqhMo/FdBHwZADwiLyVYGwwjWA6hMOl/1QIvtEbnj5h0V5iU9N1d1LZeg03VqODtgtx KoR01N1R4sJxkwHl+eef2f/WVNblMYYGHQVk1rf6LGuv2xWhK5A4b9kZty8fihRIhG6yYKt07bo Y= X-Received: by 2002:a5d:540d:: with SMTP id g13mr10401046wrv.329.1628253099753; Fri, 06 Aug 2021 05:31:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwtScdnrXL9jtnengO2/2qgWeG1lgQbbF9bBRYmT72xXpg832E5gQqwZd3e5NjCiIu3mzh0A== X-Received: by 2002:a5d:540d:: with SMTP id g13mr10401025wrv.329.1628253099549; Fri, 06 Aug 2021 05:31:39 -0700 (PDT) Received: from ajmitchell.remote.csb ([95.145.245.173]) by smtp.gmail.com with ESMTPSA id l9sm9257484wro.92.2021.08.06.05.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 05:31:39 -0700 (PDT) Message-ID: Subject: [PATCH 1/4] nfs-utils: Fix potential memory leaks in idmap From: Alice Mitchell To: linux-nfs@vger.kernel.org Cc: Steve Dickson Date: Fri, 06 Aug 2021 13:31:38 +0100 In-Reply-To: References: X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Alice Mitchell --- support/nfsidmap/nss.c | 4 ++-- support/nfsidmap/regex.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/support/nfsidmap/nss.c b/support/nfsidmap/nss.c index 669760b..f00bd9b 100644 --- a/support/nfsidmap/nss.c +++ b/support/nfsidmap/nss.c @@ -365,9 +365,9 @@ static int _nss_name_to_gid(char *name, gid_t *gid, int dostrip) out_buf: free(buf); out_name: - if (dostrip) + if (localname) free(localname); - if (get_reformat_group()) + if (ref_name) free(ref_name); out: return err; diff --git a/support/nfsidmap/regex.c b/support/nfsidmap/regex.c index fdbb2e2..958b4ac 100644 --- a/support/nfsidmap/regex.c +++ b/support/nfsidmap/regex.c @@ -157,6 +157,7 @@ again: IDMAP_LOG(4, ("regexp_getpwnam: name '%s' mapped to '%s'", name, localname)); + free(localname); *err_p = 0; return pw; From patchwork Fri Aug 6 12:32:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Mitchell X-Patchwork-Id: 12423389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 174D6C4338F for ; Fri, 6 Aug 2021 12:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE65961164 for ; Fri, 6 Aug 2021 12:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343704AbhHFMcm (ORCPT ); Fri, 6 Aug 2021 08:32:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54609 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343699AbhHFMcm (ORCPT ); Fri, 6 Aug 2021 08:32:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628253146; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zCJcYHDj5auKge+/03UDfyPE2VgSp2GxYsZu4Bcf2fo=; b=PUXWm/srwrR5z0p2lLp80hf0iA0SC3fj8TR5f+KL/9n49wv65yquwS8ZOPMuvqMAxye7Db TNo6y4zIBKcmQd+fwei1+ahzorQt+p2w3IsxvPAwYrcUOV7TifguKs9ujRDpKczPadVCIl vmgOvXrQNzBTu4gJEF9EFGS8OPeSJ8w= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-wAnAUSLPPKOrl9w0WEtAeg-1; Fri, 06 Aug 2021 08:32:25 -0400 X-MC-Unique: wAnAUSLPPKOrl9w0WEtAeg-1 Received: by mail-wr1-f72.google.com with SMTP id o11-20020a5d474b0000b02901533f8ed22cso3093432wrs.22 for ; Fri, 06 Aug 2021 05:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=zCJcYHDj5auKge+/03UDfyPE2VgSp2GxYsZu4Bcf2fo=; b=e5KgxPirJmzwCkTsC5fNhMEYiZcjlobao6RXNjbE/bxy/uPpCu4OQ2vzwuJcmny2u2 Abmc7vBAZBnmsKz6hp+EPX81mxgwtP5eHsb7AicE4tJ67E4SZGGccvrAyc9rI4Iew//5 +wrqtW3Xoq2B1mCBvg7Gm/zmt4za43OqvmRq0t/abNBwkGDEL2k8dJOFjKiWTX0GDHmZ d7EDI3O7e6ssGDUQ3dBQAZV9TdovIEz/8nn2L+niG34Um/ULuSBW6bqQHy7KeYKMXhBF XyyW5KxM8GHIcL/kNfo4KkGahbzFqHW5uIrJ4eljCDQMLWbCvmxJbf6uFL2JMbya5ujy s9TQ== X-Gm-Message-State: AOAM533JV2ASyBHIOKA5dQx6qiFPhX1UoRnvXHG8w7IpJbOdLXHOzAx9 yuEr9Pb8mGcrn4+8sefWToauW8c/aEQWANcsQjn80eTbrh6W6PkWi0lHzAcIZYY8KXnd8GiiCJt ZBj0JQRBKJfdNyB3FjICw5cgB40UJbQ36SuM6JHNYFegq+gmAEZbGvDbStfw8OzVSjYmVvqhv2S Q= X-Received: by 2002:adf:f845:: with SMTP id d5mr10376403wrq.267.1628253143776; Fri, 06 Aug 2021 05:32:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE1F13IvQ6Q12V9LWNsTWFR1xLw+9avz9flvqfGHWuH06XiQLM7euObAZyg3MuyiRUUIwoVQ== X-Received: by 2002:adf:f845:: with SMTP id d5mr10376383wrq.267.1628253143623; Fri, 06 Aug 2021 05:32:23 -0700 (PDT) Received: from ajmitchell.remote.csb ([95.145.245.173]) by smtp.gmail.com with ESMTPSA id s14sm8212809wmc.25.2021.08.06.05.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 05:32:23 -0700 (PDT) Message-ID: Subject: [PATCH 2/4] nfs-utils: Fix mem leaks in gssd From: Alice Mitchell To: linux-nfs@vger.kernel.org Cc: Steve Dickson Date: Fri, 06 Aug 2021 13:32:22 +0100 In-Reply-To: References: X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Also fix the modification of a returned config value which should be treated as const. Signed-off-by: Alice Mitchell --- utils/gssd/gssd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c index 4113cba..0815665 100644 --- a/utils/gssd/gssd.c +++ b/utils/gssd/gssd.c @@ -1016,7 +1016,7 @@ read_gss_conf(void) keytabfile = s; s = conf_get_str("gssd", "cred-cache-directory"); if (s) - ccachedir = s; + ccachedir = strdup(s); s = conf_get_str("gssd", "preferred-realm"); if (s) preferred_realm = s; @@ -1070,7 +1070,7 @@ main(int argc, char *argv[]) keytabfile = optarg; break; case 'd': - ccachedir = optarg; + ccachedir = strdup(optarg); break; case 't': context_timeout = atoi(optarg); @@ -1133,7 +1133,6 @@ main(int argc, char *argv[]) } if (ccachedir) { - char *ccachedir_copy; char *ptr; for (ptr = ccachedir, i = 2; *ptr; ptr++) @@ -1141,8 +1140,7 @@ main(int argc, char *argv[]) i++; ccachesearch = malloc(i * sizeof(char *)); - ccachedir_copy = strdup(ccachedir); - if (!ccachedir_copy || !ccachesearch) { + if (!ccachesearch) { printerr(0, "malloc failure\n"); exit(EXIT_FAILURE); } @@ -1274,6 +1272,8 @@ main(int argc, char *argv[]) free(preferred_realm); free(ccachesearch); + if (ccachedir) + free(ccachedir); return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } From patchwork Fri Aug 6 12:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Mitchell X-Patchwork-Id: 12423391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1437C4338F for ; Fri, 6 Aug 2021 12:33:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A39760F25 for ; Fri, 6 Aug 2021 12:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240311AbhHFMeC (ORCPT ); Fri, 6 Aug 2021 08:34:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57681 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238794AbhHFMeC (ORCPT ); Fri, 6 Aug 2021 08:34:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628253226; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aESQJrjRjEGA2KBzRJNS+CI346f4W84tNzuVuGynsGk=; b=ffefhdAN3yD1EfZFZ63hTdH7qzl3nwYwiq+zfXO4aomh7iLOtDiwglKI6PH1DHBnULXJte rPvxNoD4RjoFtD3ysdk80K/fa1DkIsrP7U/5G7Wvr0xyTzwE5cMkvulrUYVaeRIxKDsMuw nWHvq/ipkpqbhrY7FFynqJkTAdri7wY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-26wt8Yr7MrOYfzg-49YItw-1; Fri, 06 Aug 2021 08:33:44 -0400 X-MC-Unique: 26wt8Yr7MrOYfzg-49YItw-1 Received: by mail-wr1-f71.google.com with SMTP id f6-20020adfe9060000b0290153abe88c2dso3103058wrm.20 for ; Fri, 06 Aug 2021 05:33:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=aESQJrjRjEGA2KBzRJNS+CI346f4W84tNzuVuGynsGk=; b=abF3nJBdaPn76FM+krBoOTPyOwZR7cdsmHBp/7xPrgPevPx3r5BzcAeXaWbEvDDnPe lavT9QpMhu+bWmPpEO/rYUI3ZTL4T8Gvqo8ecIEbGN02+2EwYr5rAQZvkxYhnQmq7Wuq 8L5Q7wAJ3sBkl3IKAgi1s9dYGnSoBbmfGQ3wUNXdkGsMNnEE2FGPTM4OKQsBTnA0s4sA oo5RLl2i8Xt0XMMCOenoNcwCAWMml7RUQSlS8g/kUzvujHVsGL6PES6HJr+v+oNbmqSU wbaF0CPiqjDLgpILV2wiHk5e2MboVu1t1CbyCTw+F5+LhgyohBRQfNNoRX+ElsqROZp4 4hUQ== X-Gm-Message-State: AOAM530n2FBjPi+S3NKL8aWURdBCsrbDkS5oaZYeu/nY7ws4OIy0Rlqh Lukkpm90c6Lzrria/WP61x6a473LuiNwAp0BSsN9ejsJ8yPnIBOroioc/Cwqwu/XOy9Zg3SBS39 JQE125bqLTM/i2ygQdDoRN4wpi7GR/7LvTiGn0+E0fsto/tjkhoezDgHB8ZaAEbMNMjlE5sJoI0 Y= X-Received: by 2002:adf:ec50:: with SMTP id w16mr10704074wrn.56.1628253223618; Fri, 06 Aug 2021 05:33:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0Y49ueJ/Wz2xCnuuQ6uLrfCI8s48uMCVD+9PCB0uxsKKhUe21xHZeAm+f1HGkzdBUtHmjRg== X-Received: by 2002:adf:ec50:: with SMTP id w16mr10704063wrn.56.1628253223492; Fri, 06 Aug 2021 05:33:43 -0700 (PDT) Received: from ajmitchell.remote.csb ([95.145.245.173]) by smtp.gmail.com with ESMTPSA id y4sm8412147wmi.22.2021.08.06.05.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 05:33:43 -0700 (PDT) Message-ID: Subject: [PATCH 4/4] nfs-utils: Fix mem leak in mountd From: Alice Mitchell To: linux-nfs@vger.kernel.org Cc: Steve Dickson Date: Fri, 06 Aug 2021 13:33:42 +0100 In-Reply-To: References: X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Alice Mitchell --- utils/mountd/rmtab.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/mountd/rmtab.c b/utils/mountd/rmtab.c index 2da9761..752fdb6 100644 --- a/utils/mountd/rmtab.c +++ b/utils/mountd/rmtab.c @@ -233,6 +233,9 @@ mountlist_list(void) m->ml_directory = strdup(rep->r_path); if (m->ml_hostname == NULL || m->ml_directory == NULL) { + free(m->ml_hostname); + free(m->ml_directory); + free(m); mountlist_freeall(mlist); mlist = NULL; xlog(L_ERROR, "%s: memory allocation failed",