From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D477D126C03 for ; Thu, 23 Jul 2026 17:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784828637; cv=none; b=kXdcrTCfmslYrE3QM/0KRJRbHcbxX/q3Sgeu6St6M0sUkMGovJJFGS3cmJvsr1mxiGtA3JjStA6tZtysPkDdZdtO5z3U5gfVPeyBRe988rzrmE88CLNuHcBTw27lYwHKanEOhf8KQp0LqYUy31Qm1+oukUUOcim8SUKLxmZ/2lo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784828637; c=relaxed/simple; bh=7CfLiwE5M0TCOSUKAJEyT22HQx9DD5s4V+fJwhTJWV8=; h=Date:Message-ID:MIME-Version:Content-Type:From:To:Cc:Subject: References:In-Reply-To; b=QOlw3p1Rsi7BWCDLaUh5KQ87ezou1t4SQ9jVYWTht5xMhK4/t1xHwk9owQmkNjg/MnJ0DbTPOL3SN5+HKsnc9bNMekEqawnNWMOX+QSVf0O2YArFCDhe7PCJEixNult5MffgJMXY2AtrvZA4+AKT0t8YeBDWLy8+fPU2x2MVrQ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=Vr71dgUz; arc=none smtp.client-ip=209.85.219.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="Vr71dgUz" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-8ef1dc934d1so8694806d6.0 for ; Thu, 23 Jul 2026 10:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1784828621; x=1785433421; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-type:mime-version:message-id:date:from:to:cc:subject:date :message-id:reply-to:content-type; bh=brmtQMY+PCLY5SqHqKFMvLTgXx8Pdh/IhOMrgYqDWxI=; b=Vr71dgUzOAqYSVvjqBnD6ZQCE3SPE5Mmk4qfCKiMbM9zK5Zr4I8p928xXutV5b6dN+ qgIWEu4UiU7JjrDa4b/fmYS/1mGAkKcs8vnDR9BihkanA6IU4TSVc0gY7gO4hTu2D3z2 iMkBy1bOnr6rYTzrO+OgDRZuRPEedoExVPsjfD2V8miArtLe+od5z8UwDMSxPFDM791O HSySg46wlvWky8fNj4rDm7MS/iWMRHLeKpMjF6GEjdk5jCudU61Zv1QSKC5OcyzE4miH QRWLNdXpD5oyRK8mRueLgoJ59UDZJQLfMqeafDuPdrCKWKSvHT7uYiA9DzJqSKPJkgEi nfXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784828621; x=1785433421; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-type:mime-version:message-id:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=brmtQMY+PCLY5SqHqKFMvLTgXx8Pdh/IhOMrgYqDWxI=; b=YeF445ngf/fNsJPw1AH/O6M3ovaE2+WHemCZZk07vDjqLBCuQ4AUudvcgDsgbE7F1Y QqN8dO2uSV4Ve5fxKma7UuBYjZ+6XTrubH6pAdNboMY2kGxKwJwBHTCoXqKdewys4sji E1uB2DemGJEcsSoo0371vWFBOD0izVYqpKtiBTP9hQsQMKo1Cl/5mvSOO4Yysk5GKudY v31SS3rvGEb3EF9w+XCOHykdrHL73Z4cE4ifuASDnhOosN+zU9JrsTfPMKY9dAh3Y4cg 3uAov4VsA1GnygGgsKMhahz62tXOzOCHQ5tG7fyZPPZHAbzt1/BOP4gZHql0ek81ErAu Nzfg== X-Forwarded-Encrypted: i=1; AHgh+Ro9p/8dMgifu+Ke5bw+tQw1m3vcbw0V+7uDdRjLDUYiwx/3cL1NmqvOaQIGa9AZS0od496ERqZrbEqqGX8=@vger.kernel.org X-Gm-Message-State: AOJu0YyJjpSK2XdTSqzwtgnCBh19eQAXSLb3JOZDoscKcKzXQUpgmifY tplqARnyqljmWutGkQM6PG2F7Q5pXkMBjY72sy0IfbmyjCZvfAWKsybvy7xEtx9iwg== X-Gm-Gg: AR+sD11txKPLK7UwrKSRibRxANljIbQOFQfYiXeaT5FIE48SQNsz7debA+7sYxghdk3 bMi3PXxNeGsgilJs8qsRffIZ17U99G89kqqocp297r4ZFyTmQCFKQiCmCB2p1BczQhdPVanOPe6 4kjXIBUM4Yc2nH9M9awz6nRXiBvMEq3DEH7j5UGyLXD4k8yDQvI7rY8+RyAmt2xDg88j9QKdbGm L/xSVrL3JhhUFlJ+pFWtq3OMG5btD8laN4AGUR+YWgaHvLUnWZE8LHpcRrIiOZMUDRbfYSVEmfi Ml/bEvAXLDuW74txZ9XYPtxD6UP+cKx0cvUh+uss8FPBIbMkH9Wex/qc1Zqcuk92YzFKexA+imr w4SRvyLex4CyXLDe3qcUCM8CuinxgJce5AwKIzmaDASmrJ5fva63Q2CggoIfTZfvXnxIND2CWyV MYwyXFXfuzZjzqTeN63+3ptqlrsB3p7TxtBe7/thUBuPNB1b82A4XvTkmVjg== X-Received: by 2002:a05:6214:508d:b0:907:6fce:b82a with SMTP id 6a1803df08f44-907cd19b0a6mr33743506d6.23.1784828620932; Thu, 23 Jul 2026 10:43:40 -0700 (PDT) Received: from localhost (pool-71-126-255-178.bstnma.fios.verizon.net. [71.126.255.178]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-907ba901c24sm49954856d6.21.2026.07.23.10.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 10:43:39 -0700 (PDT) Date: Thu, 23 Jul 2026 13:43:39 -0400 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailer: pstg-pwork:20260723_1338/pstg-lib:20260722_1430/pstg-pwork:20260723_1338 From: Paul Moore To: Zhan Xusheng Cc: Eric Paris , Ricardo Robaina , Richard Guy Briggs , audit@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Zhan Xusheng Subject: Re: [PATCH v2] audit: fix potential integer overflow in audit_log_n_string() References: <20260718050922.1980425-1-zhanxusheng@xiaomi.com> In-Reply-To: <20260718050922.1980425-1-zhanxusheng@xiaomi.com> On Jul 18, 2026 Zhan Xusheng wrote: > > audit_log_n_string() computes new_len as "slen + 3" (enclosing quotes > plus the NUL terminator) and stores it into an int, while slen is a > size_t. For a sufficiently large slen the addition can overflow and/or > the result be truncated when assigned to the int new_len, so the > "new_len > avail" check can be bypassed and the subsequent > memcpy(ptr, string, slen) can write past the skb tail. > > This is the same class of bug that was fixed for the hex sibling in > commit 65dfde57d1e2 ("audit: fix potential integer overflow in > audit_log_n_hex()"); both helpers are reached through > audit_log_n_untrustedstring() with the same length source. > > Make new_len a size_t and use check_add_overflow() to catch the > overflow, mirroring the audit_log_n_hex() fix. No functional change for > the in-tree callers, which all pass bounded lengths. > > Fixes: 168b7173959f ("AUDIT: Clean up logging of untrusted strings") > Cc: stable@vger.kernel.org > Signed-off-by: Zhan Xusheng > --- > v2: > - drop the unnecessary (size_t) cast on the constant (Paul Moore) > - emit "?" instead of "\"?\"" on overflow, matching > audit_log_n_hex() (Paul Moore) > > kernel/audit.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) Merged into audit/stable-7.2 with the intent of sending this up to Linus once it has gone through some testing. Thanks! -- paul-moore.com