Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2761014pxb; Tue, 21 Sep 2021 07:08:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx9XAXn/6bsR0+RHWnPS3TrHzCCiftC27xTZyyWOaU8C1dKqUadgzenRYFoZE1nX5eHXex X-Received: by 2002:a50:e1cd:: with SMTP id m13mr2237217edl.93.1632233316060; Tue, 21 Sep 2021 07:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632233316; cv=none; d=google.com; s=arc-20160816; b=VHRf+TSoiO0BYzXszrM5+HLgj5V56VxcwrwNJaHAQDhuk/5j0DdaT5aNOlzY8VsHg8 EnuiFqg2zhk9r1ToJxFDlWw6GDS4sN61aJdRP39i3qdULi17Bk81/94A0S9Q3ldlCWgo beRfxL0tzFmeVvsUZHeLkKBN8OsWLyEpZ57R7MBa8loKeeLDYueOgw6Ff5C3wA2XjT/g G/d8AIzPPIz8bdprrKFwkgRGowVWZLUWpnC+CYzkfZYfajZTBuRg0W3JsaU/JI40S/mj WTq2Ukp3jUReRsm1KY2AwZ6AOrXNghdKZDpK/T27qHOBxrab2ppIKdBOmED7fqzHlmDr iFtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=/B2NGSCXLIfnFHS9xCifjOjI+tDhsRVIKLKZLcc5oOY=; b=Ncu65HTLNuPir/t0qv7m1IJ89QxJ8Lfgh9Gy7SwS6Z4eE23UuUZtreuTy2O+BZaX/H rlJgQiYNhwL7oCKuMMoG8D3Gyga/zOiAbSFP8PHkXlW8tvnbuRRVunmTRJ7gVonEi7nv 1rawL+uHJ6bupDmSoEFlNBQAnbTKDkbXsVSkFioaqQQeu/YANhq+M1bPL213a/Qy3lgk PPY2tnwsHAxZUzu0HS0xE2iwG8PSYw5ycuCRaANwZN9SMbPG2yeDIakIaRh4SfA5X4sK Jh0/gtUv//Y04kMq05VtZJw9ix38M20mlesH9nYu8vNA4fsZVrY5syMqLNyC1tZqdrrk KfZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb8si302521edb.465.2021.09.21.07.07.56; Tue, 21 Sep 2021 07:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233439AbhIUOHH (ORCPT + 99 others); Tue, 21 Sep 2021 10:07:07 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:9896 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233042AbhIUOHG (ORCPT ); Tue, 21 Sep 2021 10:07:06 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HDNPW3wytz8y0F; Tue, 21 Sep 2021 22:01:03 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 21 Sep 2021 22:05:35 +0800 Received: from mdc.huawei.com (10.175.112.208) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 21 Sep 2021 22:05:34 +0800 From: Chen Jun To: , CC: , , , Subject: [PATCH] mm: Fix the uninitialized use in overcommit_policy_handler Date: Tue, 21 Sep 2021 14:03:01 +0000 Message-ID: <20210921140301.9058-1-chenjun102@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An unexpected value of /proc/sys/vm/panic_on_oom we will get, after running the following program int main() { int fd = open("/proc/sys/vm/panic_on_oom", O_RDWR) write(fd, "1", 1); write(fd, "2", 1); close(fd); } write(fd, "2", 1) will pass *ppos = 1 to proc_dointvec_minmax. proc_dointvec_minmax will return 0 without setting new_policy. t.data = &new_policy; ret = proc_dointvec_minmax(&t, write, buffer, lenp, ppos) -->do_proc_dointvec -->__do_proc_dointvec if (write) { if (proc_first_pos_non_zero_ignore(ppos, table)) goto out; sysctl_overcommit_memory = new_policy; so sysctl_overcommit_memory will be set to an uninitialized value. Initialize new_policy with sysctl_overcommit_memory. Fixes: 56f3547bfa4d ("mm: adjust vm_committed_as_batch according to vm overcommit policy" Signed-off-by: Chen Jun --- mm/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/util.c b/mm/util.c index 4ddb6e186dd5..b4af8a1de4f7 100644 --- a/mm/util.c +++ b/mm/util.c @@ -756,7 +756,7 @@ int overcommit_policy_handler(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { struct ctl_table t; - int new_policy; + int new_policy = sysctl_overcommit_memory; int ret; /* -- 2.17.1