From patchwork Sat Nov 2 09:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13860054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12A45E677F5 for ; Sat, 2 Nov 2024 09:31:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 634B86B0083; Sat, 2 Nov 2024 05:31:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E43A6B0085; Sat, 2 Nov 2024 05:31:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ABAD6B0088; Sat, 2 Nov 2024 05:31:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2D76A6B0083 for ; Sat, 2 Nov 2024 05:31:22 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A41D2121370 for ; Sat, 2 Nov 2024 09:31:21 +0000 (UTC) X-FDA: 82740636468.28.6EA308E Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by imf21.hostedemail.com (Postfix) with ESMTP id 3CE7F1C0003 for ; Sat, 2 Nov 2024 09:30:24 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=vd6KXSna; spf=pass (imf21.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.128.43 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730539662; h=from:from:sender: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:in-reply-to: references:dkim-signature; bh=Y20IPLl0T1Inu0ZWcS2TQ9J2Ib1jjVRfeGEd17R1p8c=; b=Eq9jD1gj4MtUsXF6E67qU/xSAR8+Ld58B6BgMJQ0adyxzoUWDwvjLE2bLmv2O2z8pFCG1C V9bFnveSmHyY64rN45jxji4MIJmL1HRBxqtVJ80ZX5exvmOXZ0w2Er3SqK/EruIUPpoEQQ p3QqtSUJfRm2qs+a9uKbzPSlW2ymBa4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=vd6KXSna; spf=pass (imf21.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.128.43 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730539662; a=rsa-sha256; cv=none; b=h58m6+oLHot/EJDK1ehBwUOXbv5Z+sszRBOtf3X5c0bqoj8h7eu1UxLi7L1kMKJmXcT0U7 iaHwnSwLL+zWB0H0XISmIvM8bI99DazAhEMMedgNMWHfCgkDg8wWtzUjPeDiMaZRVrtfpY TGVYW7zN7hmTjtbYIH+bK1S77vEtbYI= Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4316a44d1bbso23161795e9.3 for ; Sat, 02 Nov 2024 02:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730539878; x=1731144678; darn=kvack.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Y20IPLl0T1Inu0ZWcS2TQ9J2Ib1jjVRfeGEd17R1p8c=; b=vd6KXSna31pwNv9Jo2DOi+9FplUn/rQefWmXHfrzWJ6Yq7B9CN9vqP/QyPlFgrzpLw sfXsh6BVDK3Gpx7T1Te3Ar52lVTnyjTo1C+6rpWJVWK5XIEB5JOjfKDpdraHXzWhBeGI XnABFEVMa/6KzE9frGB5oYVe16oHXUCF+06iIqC+ooH0HeoYKVnshQ3INdVhK2OcyaAd GA/2pPleJNTlIaJMvY9RmmxZ2p2sliZX0i05KQ36MyDvmMnOC5Jk5cKH/GA8I3OiP4cN vdTPkPAfdOVBIpJrUSIODYSNklhEU0R9TVfLl1MVuv+EnpOBv838kT+4NenOWvutMnXs 5Iiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730539878; x=1731144678; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y20IPLl0T1Inu0ZWcS2TQ9J2Ib1jjVRfeGEd17R1p8c=; b=Ux9wm/5ibYLDr3BO4TAt8kK8Oz25enFniKIUDEyEEgBTYTJZyqJJv8HiCXuwJrClhJ s4ApDesaWUoR1AZXEDi4+FSVZiZJgP375yX8eMDHe6kS1GuGY9Y4ml4bJDa5PF6dIQ6G UgR/JJS3fMQofpo4fRt9ErmldNJ/ET+g8zs+qRj5h1UanqTcM9kPIkxsX6OF23/Q8n+O qmF03XGNgKaoQW1vrCnloq0y9WCyaGBLZJPm7NmSQJ3vfhbFUC3Ax3W6t0MLI952Il/7 NoxwlaeNSpMgZYgVzGjGyAncSPUeOyrNUaY5uFC/TFWAi3OCu5cNW/VeG9OZnjQPhl7a nGgQ== X-Forwarded-Encrypted: i=1; AJvYcCUj4TDaw0cz6ACfwHbVO8020WoSIhPtz8Ky4fCIs0TRpbxTAnLk0iXUsRnPSEo//Ot9BKKaaw4nrQ==@kvack.org X-Gm-Message-State: AOJu0Yx0lyLAItkUkK+e9YbA3FjEzqrpzgdTYUUpZiu2FoDae3Dgeiro 1PsqY2RBsc55u6TFhnDoMSevLOJFkdYVWpJHIQoA0ImaMcajuAhrvy8/1AincmIqaw6JEJNP4+S K X-Google-Smtp-Source: AGHT+IElQhl8RTx1u2Qv+Hf698kNw66wgtCjAXGbW3mdm/POfTMzJMzs4xEy2zd12QkNz0gSnIZD7Q== X-Received: by 2002:a05:600c:a08:b0:431:4a83:2d80 with SMTP id 5b1f17b1804b1-4327b6c1c78mr88114585e9.0.1730539878363; Sat, 02 Nov 2024 02:31:18 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5ac37csm88619985e9.10.2024.11.02.02.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Nov 2024 02:31:17 -0700 (PDT) Date: Sat, 2 Nov 2024 12:31:14 +0300 From: Dan Carpenter To: Tycho Andersen Cc: Kees Cook , Eric Biederman , Alexander Viro , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH next] exec: Fix a NULL vs IS_ERR() test in bprm_add_fixup_comm() Message-ID: <18f60cb9-f0f7-484c-8828-77bd5e6aac59@stanley.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3CE7F1C0003 X-Stat-Signature: jgyb45kpk4rjs3mhssr8gxsiem9u97mz X-Rspam-User: X-HE-Tag: 1730539824-367319 X-HE-Meta: U2FsdGVkX1+x09cJJW0IvzKL6PN579mdY3EidFn5s5C4ffJK45bJ84Uj2TqdPHpmdM3EnnOZonIvmLR16dVFX5AA2+1uqUX0JOuLITucyIePylhCSnrAmxhFTFWCUQfUrjbLRRt34kEds+0Sw8dVT4SQklymu9yfuHgXjHaoZEmF++F48vCeluNJ0vE7nPxVOxSEwM7px9Q/ogGZwoqfHEQClZ03rTFkH42zkR50ZTRE418I9Wv523gkNQsflIg0o5A/7GKnp0wgWMNKEHi4DVnXeZ/GawTA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X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The strndup_user() function doesn't return NULL, it returns error pointers. Fix the check to match. Fixes: 7bdc6fc85c9a ("exec: fix up /proc/pid/comm in the execveat(AT_EMPTY_PATH) case") Signed-off-by: Dan Carpenter Reviewed-by: Tycho Andersen --- fs/exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 7e24d585915e..c5c291502dca 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1512,10 +1512,10 @@ static int bprm_add_fixup_comm(struct linux_binprm *bprm, return 0; bprm->argv0 = strndup_user(p, MAX_ARG_STRLEN); - if (bprm->argv0) - return 0; + if (IS_ERR(bprm->argv0)) + return PTR_ERR(bprm->argv0); - return -EFAULT; + return 0; } static struct linux_binprm *alloc_bprm(int fd, struct filename *filename, int flags)