Skip to contentSkip to conversation

lsm: use lsm_blob_alloc() in lsm_bdev_alloc()

PATCH In review Paul Moore 3 participants 5 messages Aug 6, 2025 – Aug 11, 2025 Security (LSM)

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 lsm: use lsm_blob_alloc() in lsm_bdev_alloc()

Convert the lsm_bdev_alloc() function to use the lsm_blob_alloc() helper like all of the other LSM security blob allocators.

---
 security/security.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
security/security.c +2 -10
index ad163f06bf7a..a88ebfca3224 100644
@@ -823,16 +823,8 @@ static int lsm_msg_msg_alloc(struct msg_msg *mp)
  */
 static int lsm_bdev_alloc(struct block_device *bdev)
 {
-	if (blob_sizes.lbs_bdev == 0) {
-		bdev->bd_security = NULL;
-		return 0;
-	}
-
-	bdev->bd_security = kzalloc(blob_sizes.lbs_bdev, GFP_KERNEL);
-	if (!bdev->bd_security)
-		return -ENOMEM;
-
-	return 0;
+	return lsm_blob_alloc(&bdev->bd_security, blob_sizes.lbs_bdev,
+			      GFP_KERNEL);
 }
 
 /**
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Paul Moore

Convert the lsm_bdev_alloc() function to use the lsm_blob_alloc() helper like all of the other LSM security blob allocators.

Quoted 27 lines
---
 security/security.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
security/security.c +2 -10
index ad163f06bf7a..a88ebfca3224 100644
@@ -823,16 +823,8 @@ static int lsm_msg_msg_alloc(struct msg_msg *mp)
  */
 static int lsm_bdev_alloc(struct block_device *bdev)
 {
-	if (blob_sizes.lbs_bdev == 0) {
-		bdev->bd_security = NULL;
-		return 0;
-	}
-
-	bdev->bd_security = kzalloc(blob_sizes.lbs_bdev, GFP_KERNEL);
-	if (!bdev->bd_security)
-		return -ENOMEM;
-
-	return 0;
+	return lsm_blob_alloc(&bdev->bd_security, blob_sizes.lbs_bdev,
+			      GFP_KERNEL);
 }
 
 /**
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Paul Moore
Quoted 4 lines · Paul Moore

Convert the lsm_bdev_alloc() function to use the lsm_blob_alloc() helper like all of the other LSM security blob allocators.

Quoted 30 lines
---
 security/security.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
security/security.c +2 -10
index ad163f06bf7a..a88ebfca3224 100644
@@ -823,16 +823,8 @@ static int lsm_msg_msg_alloc(struct msg_msg *mp)
  */
 static int lsm_bdev_alloc(struct block_device *bdev)
 {
-	if (blob_sizes.lbs_bdev == 0) {
-		bdev->bd_security = NULL;
-		return 0;
-	}
-
-	bdev->bd_security = kzalloc(blob_sizes.lbs_bdev, GFP_KERNEL);
-	if (!bdev->bd_security)
-		return -ENOMEM;
-
-	return 0;
+	return lsm_blob_alloc(&bdev->bd_security, blob_sizes.lbs_bdev,
+			      GFP_KERNEL);
 }
 
 /**
Signature · 1 line
2.50.1
author maintainer
#3 lore raw
In reply to Paul Moore
Quoted 8 lines · Paul Moore

Convert the lsm_bdev_alloc() function to use the lsm_blob_alloc() helper like all of the other LSM security blob allocators.

---
 security/security.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Normally I might let this sit a bit longer on the mailing list, but considering how trivial this is along with a Reviewed-by and an ACK I'm going to go ahead and merge this into lsm/dev-staging for testing and lsm/dev once the merge window closes.

Signature · 1 line
paul-moore.com
author maintainer
#4 lore raw
Quoted 10 lines · Paul Moore
Quoted 8 lines · Paul Moore

Convert the lsm_bdev_alloc() function to use the lsm_blob_alloc() helper like all of the other LSM security blob allocators.

---
 security/security.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
Quoted 4 lines

Normally I might let this sit a bit longer on the mailing list, but considering how trivial this is along with a Reviewed-by and an ACK I'm going to go ahead and merge this into lsm/dev-staging for testing and lsm/dev once the merge window closes.

This is now in lsm/dev, thanks all.

Signature · 1 line
paul-moore.com