Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp555509yba; Thu, 18 Apr 2019 06:00:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuCP+Ng/nosHAn0P405XjOu7+A2SkL/05j1sR0ia0CBOVJtC15Eb+Q+x7PemnfP2Dgsnzm X-Received: by 2002:a63:c40c:: with SMTP id h12mr76818528pgd.39.1555592418245; Thu, 18 Apr 2019 06:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555592418; cv=none; d=google.com; s=arc-20160816; b=xwneXOO0l+ctOZSfg/dyAsOR6JWiKM7G3PYfIx+oBSZzx8hGhK/hivyc8p90QltZTq Zlhj4eQTu5r7yoitxTFC8IL8y9x8hUsl5eUGo0nymGI0ZLpCxJnGIEUshPgjOatbS+6Q lseYssD8bqAkmAzOrtWvP5VnvmOeNODAYkdpZMfgDH4iSkx6piHS5cHT5G57hOELDbjY GFG2zCNMaIWrtPQwxhEGRXV/OKVInQ/ffBlleVEdMnrXOC//WceqMJUtCHyJWEstiHom mqmR+9WDwzChLVd+Hdn+K6mqwwsX3kxIrLNI2JeYmmsADpPKS5A8VAPHrFnUfH5jgYvD OojQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:date:subject:cc:to:from; bh=JnX0iCr1knkPciHRtd4SE0+1coMYysK+bNjv3CnXclU=; b=WupXJWj6vKkEVhdzUIuqnz7l2YwRnERnMkmPc3zXmNv7cE7WDpZk8P1f2O/xf8Cgrl nYgASSjjm2Y9fbsgyX4NugbN2bVv0XsxqvaQpTnMwZrzsZI4NsTIosMERN585xBMWBlx G85AtXYXZcObF/nNLATMuXceUyrUPs8y3/Mn/TEKNye+MOwu1XsPj5Kp80WK0LXVLUBc IFe5y/SpmXiJFw92lgmmF2hSKpFJ9uXv6Xog8TxOMDPr0VdlUt9238HKDHK1VbF61EX/ RJBGguFWgN5LpFHf89eBvnQvndSmHbkj9yaJLPUd7Be8B0uythUC2l+0qfz4wj9DUiVQ aY+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q142si2373644pfq.175.2019.04.18.06.00.03; Thu, 18 Apr 2019 06:00:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388681AbfDRM6g (ORCPT + 99 others); Thu, 18 Apr 2019 08:58:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41282 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfDRM6f (ORCPT ); Thu, 18 Apr 2019 08:58:35 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3ICrqZw039681 for ; Thu, 18 Apr 2019 08:58:34 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rxrg83ex9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Apr 2019 08:58:33 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Apr 2019 13:58:31 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 18 Apr 2019 13:58:29 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3ICwSBE5636218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Apr 2019 12:58:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CD154C04A; Thu, 18 Apr 2019 12:58:28 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2E7E4C046; Thu, 18 Apr 2019 12:58:27 +0000 (GMT) Received: from pomme.aus.stglabs.ibm.com (unknown [9.145.32.15]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 18 Apr 2019 12:58:27 +0000 (GMT) From: Laurent Dufour To: mhocko@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yang Shi Subject: [PATCH] mm: use mm.arg_lock in get_cmdline() Date: Thu, 18 Apr 2019 14:58:27 +0200 X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19041812-0008-0000-0000-000002DB3862 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19041812-0009-0000-0000-0000224779C7 Message-Id: <20190418125827.57479-1-ldufour@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-18_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=566 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904180092 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct") introduce the spinlock arg_lock to protect the arg_* and env_* field of the mm_struct structure. While reading the code, I found that this new spinlock was not used in get_cmdline() to protect access to these fields. Fixing this even if there is no issue reported yet for this. Fixes: 88aa7cc688d4 ("mm: introduce arg_lock to protect arg_start|end and env_start|end in mm_struct") Cc: Yang Shi Signed-off-by: Laurent Dufour --- mm/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/util.c b/mm/util.c index 05a464929b3e..789760c3028b 100644 --- a/mm/util.c +++ b/mm/util.c @@ -758,12 +758,12 @@ int get_cmdline(struct task_struct *task, char *buffer, int buflen) if (!mm->arg_end) goto out_mm; /* Shh! No looking before we're done */ - down_read(&mm->mmap_sem); + spin_lock(&mm->arg_lock); arg_start = mm->arg_start; arg_end = mm->arg_end; env_start = mm->env_start; env_end = mm->env_end; - up_read(&mm->mmap_sem); + spin_unlock(&mm->arg_lock); len = arg_end - arg_start; -- 2.21.0